> ## Documentation Index
> Fetch the complete documentation index at: https://whatsapp-docs.kap.so/llms.txt
> Use this file to discover all available pages before exploring further.

# Sendingaflow

# Send a Flow

On this page, we will explore the different ways of sending a Flow to users.

## Prerequisites

You will need to [verify your business](https://developers.facebook.com/docs/development/release/business-verification/) and maintain a [high message quality](https://developers.facebook.com/docs/whatsapp/messaging-limits#messaging-quality).

## Postman Collection

All the API requests mentioned below are documented in the [Flows API postman collection](https://l.facebook.com/l.php?u=https%3A%2F%2Fwww.postman.com%2Fmeta%2Fworkspace%2Fwhatsapp-business-platform%2Fdocumentation%2F24926895-7bf51205-92ed-49d1-af4a-0130cf84b6f6\&h=AT2DsFJ5eBv4FDgkj1dy51ChUqPB6YM2IA0nYXohXTwbt6JftU7JMT1UMEsjVcMJM0fx4dvNNK3jZT9EzHXTP6HezlmJqUfeCe9Uxg2JhUmNj1uFsz7EI6dBf78NOqPtA1zIevXIIVBA8g) which you can use to make API requests and generate code in different languages.

## Business Initiated Messages

To send a business initiated message with a Flow, you can create and send a [message template](https://developers.facebook.com/docs/whatsapp/business-management-api/message-templates) with a WhatsApp Flow attached to it. We introduced a new button type called FLOW. Use this type to specify the Flow to be sent with the message template.

To send a Flow message template you need to:

1. Create a message template with a Flow
2. Send a message template with a Flow

### Create a message template with a Flow

You can quickly build a Flow in the [playground](https://developers.facebook.com/docs/whatsapp/flows/playground) and pass the Flow JSON in the message template creation request. Or you can specify the ID or name of an already published Flow.

Below is an example request to create a message template with a Flow, [see this page for full reference](https://developers.facebook.com/docs/graph-api/reference/whats-app-business-account/message_templates/#Creating):

#### Sample request

```curl theme={null}
curl -i -X POST \
https://graph.facebook.com/v16.0/<waba-id>/message_templates \
-H 'Authorization: Bearer TOKEN' \
-H 'Content-Type: application/json' \
-d'
\{
  "name": "example_template_name",
  "language": "en_US",
  "category": "MARKETING",
  "components": [\
    {\
      "type": "body",\
      "text": "This is a flows as template demo"\
    },\
    {\
      "type": "BUTTONS",\
      "buttons": [\
        {\
          "type": "FLOW",\
          "text": "Open flow!",\
          "flow_id" : "<flow_id>",\
          // or\
          "flow_name" : "<flow_name>",\
          // or\
          "flow_json" : "{\"version\":\"5.0\",\"screens\":[{\"id\":\"WELCOME_SCREEN\",\"layout\":{\"type\":\"SingleColumnLayout\",\"children\":[{\"type\":\"TextHeading\",\"text\":\"Hello World\"},{\"type\":\"Footer\",\"label\":\"Complete\",\"on-click-action\":{\"name\":\"complete\",\"payload\":{}}}]},\"title\":\"Welcome\",\"terminal\":true,\"success\":true,\"data\":{}}]}"\
       }\
      ]\
    }\
  ]
}'
```

| buttons object Parameters  | Description                                                                                                                                                                                                                                                                                                           |
| -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `type` *string*            | **Required.** Button type. Default value is `FLOW`                                                                                                                                                                                                                                                                    |
| `text` *string*            | **Required.** Button label text. 25 characters maximum.                                                                                                                                                                                                                                                               |
| `flow_id` *string*         | **Required.** The unique ID of the Flow. Cannot be used if `flow_name` or `flow_json` parameters are provided. **Only one of these parameters is required.**                                                                                                                                                          |
| `flow_name` *string*       | **Required.** The name of the Flow. Supported in Cloud API only. The Flow ID is stored in the message template, not the name, so changing the Flow name will not affect existing message templates. Cannot be used if `flow_id` or `flow_json` parameters are provided. **Only one of these parameters is required.** |
| `flow_json` *string*       | **Required.** The Flow JSON encoded as string with escaping. The Flow JSON specifies the content of the Flow. Supported in Cloud API only. Cannot be used if `flow_id` or `flow_name` parameters are provided. **Only one of these parameters is required.**                                                          |
| `flow_action` *string*     | Default value is `navigate`. Either `navigate` or `data_exchange`.                                                                                                                                                                                                                                                    |
| `nagivate_screen` *string* | The unique ID of the Screen in the Flow. Default value is `FIRST_ENTRY_SCREEN`. Optional if `flow_action` is `navigate`.                                                                                                                                                                                              |

Message templates can be created and sent in [these languages](https://developers.facebook.com/docs/whatsapp/business-management-api/message-templates/supported-languages).

#### Sample Response

```curl theme={null}
\{
  "id": "<template-id>",
  "status": "PENDING",
  "category": "MARKETING"
}
```

### Send template with Flow

Ensure that your template passes all required reviews so that `status` is `APPROVED` instead of `PENDING`.

Now you can send a message template with a Flow using the request below

#### Sample request

```curl theme={null}
curl -X  POST \
 'https://graph.facebook.com/v16.0/FROM_PHONE_NUMBER_ID/messages' \
 -H 'Authorization: Bearer ACCESS_TOKEN' \
 -H 'Content-Type: application/json' \
 -d '{
  "messaging_product": "whatsapp",
  "recipient_type": "individual",
  "to": "PHONE_NUMBER",
  "type": "template",
  "template": {
    "name": "TEMPLATE_NAME",
    "language": {
      "code": "LANGUAGE_AND_LOCALE_CODE"
    },
    "components": [\
      {\
        "type": "button",\
        "sub_type": "flow",\
        "index": "0",\
        "parameters": [\
          {\
            "type": "action",\
            "action": {\
              "flow_token": "FLOW_TOKEN",   //optional, default is "unused"\
              "flow_action_data": {\
                 ...\
              }   // optional, json object with the data payload for the first screen\
            }\
          }\
        ]\
      }\
    ]
  }
}'
```

#### Sample Response

```curl theme={null}
\{
  "messaging_product": "whatsapp",
  "contacts": [\
    {\
      "input": "<phone-number>",\
      "wa_id": "<phone-number>"\
    }\
  ],
  "messages": [\
    {\
      "id": "<message-id>"\
    }\
  ]
}
```

## User-Initiated Conversations

You are able to send your WhatsApp Flow once you have created it. You can send a Message with a Flow in a user-initiated conversation using a Message with a Call To Action (CTA). You send this message either through the On-Prem client or Cloud API with information specific to the Flow. The Flow is triggered when the user taps the CTA button.

[Go here](https://developers.facebook.com/docs/whatsapp/conversation-types) to read more about message types, limits, and timing.

As mentioned earlier, a message with a Flow is not much different from other types of messages. It uses the existing APIs, which are described on the following pages:

* [Cloud API Interactive Messages](https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages#interactive-object) documentation page describes how to send Interactive Messages with the Cloud API.
* [On-Premises Interactive Object](https://developers.facebook.com/docs/whatsapp/on-premises/reference/messages/#interactive-object) documentation page describes sending messages with On-Premise client.

To send a message with a Flow, we have introduced a new type of the Interactive Object named `flow` with the following properties.

### Interactive message parameters for Cloud API

(See [On-Premises Interactive Object](https://developers.facebook.com/docs/whatsapp/on-premises/reference/messages/#interactive-object) documentation for On-Premise client parameters.)

| Parameter                                            | Description                                                                                                                                                                                                                                                    |           |             |
| ---------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | ----------- |
| `interactive`<br />object                            | The interactive message configuration                                                                                                                                                                                                                          |           |             |
| ↳`type`<br />(required) <br />string                 | Value must be `"flow"`.                                                                                                                                                                                                                                        |           |             |
| ↳`action`<br />(required) <br />object               |                                                                                                                                                                                                                                                                | Parameter | Description |
| ---                                                  | ---                                                                                                                                                                                                                                                            |           |             |
| `name`<br />(required) <br />string                  | Value must be `"flow"`.                                                                                                                                                                                                                                        |           |             |
| `parameters`<br />object                             |                                                                                                                                                                                                                                                                |           |             |
| ↳`flow_message_version`<br />(required) <br />string | Value must be `"3"`.                                                                                                                                                                                                                                           |           |             |
| ↳`flow_cta`<br />(required) <br />string             | Text on the CTA button. For example: "Signup"<br /> CTA text length is advised to be 30 characters or less (no emoji).                                                                                                                                         |           |             |
| ↳`flow_id`<br />(required) <br />string              | Unique ID of the Flow provided by WhatsApp.<br /> <br /> Cannot be used with the `flow_name` parameter. **Only one of these parameters is required.**                                                                                                          |           |             |
| ↳`flow_name`<br />(required) <br />string            | The name of the Flow that you created. Supported in Cloud API only. Changing the Flow name will require updating this parameter to match the new name.<br /> <br /> Cannot be used with the `flow_id` parameter. **Only one of these parameters is required.** |           |             |
| ↳`mode`<br />string                                  | The Flow can be in either `draft` or `published` mode\*.<br /> <br />(Default value: `published`)                                                                                                                                                              |           |             |
| ↳`flow_token`<br />string                            | Flow token that is generated by the business to serve as an identifier.<br /> <br />(Default value: `'unused'`)                                                                                                                                                |           |             |
| ↳`flow_action`<br />string                           | `navigate` or `data_exchange`.<br /> <br />(Default value: `navigate`)                                                                                                                                                                                         |           |             |
| ↳`flow_action_payload`<br />string                   | Optional if `flow_action` is `navigate`. Should be omitted otherwise.                                                                                                                                                                                          |           |             |

| Parameter            | Description                                                                                                                                   |   |   |
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | - | - |
| `screen`<br />string | The ID of the screen displayed first. It needs to be an entry screen\*\*.<br /> <br />(Default value: `FIRST_ENTRY_SCREEN`)                   |   |   |
| `data`<br />object   | Optional input data for the first Screen of the Flow.<br /> If provided, this must be a non-empty object.<br /> <br />(Default value: `null`) |   |   |

\*In case you edited published flow and now it is in the draft state, use "mode=draft" to send the current draft flow version, or "mode=published" (default value) to send the last published flow version.

\*\*See Flow JSON reference for [entry screen](https://developers.facebook.com/docs/whatsapp/flows/reference/flowjson#routing-rules) details.

**Cloud API Sample Request (with minimum parameters)**

```curl theme={null}
curl -X  POST \
 'https://graph.facebook.com/v18.0/FROM_PHONE_NUMBER/messages' \
 -H 'Authorization: Bearer ACCESS_TOKEN' \
 -H 'Content-Type: application/json' \
 -d '{
  "recipient_type": "individual",
  "messaging_product": "whatsapp",
  "to": "whatsapp-id",
  "type": "interactive",
  "interactive": {
    "type": "flow",
    "header": {
      "type": "text",
      "text": "Flow message header"
    },
    "body": {
      "text": "Flow message body"
    },
    "footer": {
      "text": "Flow message footer"
    },
    "action": {
      "name": "flow",
      "parameters": {
        "flow_message_version": "3",
        "flow_name": "appointment_booking_v1", //or flow_id
        "flow_cta": "Book!"
      }
    }
  }
}'
```

**Cloud API Sample Request (with all parameters)**

```curl theme={null}
curl -X  POST \
 'https://graph.facebook.com/v18.0/FROM_PHONE_NUMBER/messages' \
 -H 'Authorization: Bearer ACCESS_TOKEN' \
 -H 'Content-Type: application/json' \
 -d '{
  "recipient_type": "individual",
  "messaging_product": "whatsapp",
  "to": "whatsapp-id",
  "type": "interactive",
  "interactive": {
    "type": "flow",
    "header": {
      "type": "text",
      "text": "Flow message header"
    },
    "body": {
      "text": "Flow message body"
    },
    "footer": {
      "text": "Flow message footer"
    },
    "action": {
      "name": "flow",
      "parameters": {
        "flow_message_version": "3",
        "flow_token": "AQAAAAACS5FpgQ_cAAAAAD0QI3s.",

        "flow_name": "appointment_booking_v1",
        //or
        "flow_id": "123456",

        "flow_cta": "Book!",
        "flow_action": "navigate",
        "flow_action_payload": {
          "screen": "&lt;SCREEN_NAME&gt;",
          "data": {
            "product_name": "name",
            "product_description": "description",
            "product_price": 100
          }
        }
      }
    }
  }
}'
```

**Sample Response**

```json theme={null}
\{
  "contacts": [\
    {\
      "Input": "+447385946746",\
      "wa_id": "47385946746"\
    }\
  ],
  "messages": [\
    {\
      "id": "gHTRETHRTHTRTH-av4Y"\
    }\
  ],
  "meta": {
    "api_status": "stable",
    "version": "2.44.0.27"
  }
}
```

[←\\
\\
Previous\\
\\
Creating a Flow](https://developers.facebook.com/docs/whatsapp/flows/gettingstarted/creatingaflow)

[→\\
\\
Next\\
\\
Receiving Flow Response](https://developers.facebook.com/docs/whatsapp/flows/gettingstarted/receiveflowresponse)

On This Page

[Send a Flow](https://developers.facebook.com/docs/whatsapp/flows/guides/sendingaflow#send-a-flow)

[Business Initiated Messages](https://developers.facebook.com/docs/whatsapp/flows/guides/sendingaflow#templatemessages)

[Create a message template with a Flow](https://developers.facebook.com/docs/whatsapp/flows/guides/sendingaflow#create-a-message-template-with-a-flow)

[Send template with Flow](https://developers.facebook.com/docs/whatsapp/flows/guides/sendingaflow#send-template-with-flow)

[User-Initiated Conversations](https://developers.facebook.com/docs/whatsapp/flows/guides/sendingaflow#userinitiated)

[Interactive message parameters for Cloud API](https://developers.facebook.com/docs/whatsapp/flows/guides/sendingaflow#interactive-message-parameters-for-cloud-api)
