•  


Sending a Flow - WhatsApp Flows - 文書 - Meta for Developers

Sending a Flow

You are able to send your WhatsApp Flow once you have created it. On this page, we will explore the existing APIs for message sending, as well as the modifications required for sending a message with a Flow.

User-Initiated Conversations

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 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:

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

Parameter Description
interactive
object
The interactive message configuration
? type
(required)
string
Value must be "flow" .
? action
(required)
object
Parameter Description
name
(required)
string
Value must be "flow" .
parameters
object
? mode
string
The Flow can be in either draft or published mode.
(Default value: published )
? flow_message_version
string
Value must be "3" .
? flow_token
string
Flow token that is generated by the business to serve as an identifier.
? flow_id
string
Unique ID of the Flow provided by WhatsApp.
? flow_cta
string
Text on the CTA button. For example: "Signup" Character limit - 20 characters (no emoji).
? flow_action
string
navigate or data_exchange .
(Default value: navigate )
? flow_action_payload
string
Required if flow_action is navigate . Should be omitted otherwise.
Parameter Description
screen
string
The ID of the screen displayed first. It needs to be an entry screen*.
data
object
Optional input data for the first Screen of the Flow. If provided, this must be a non-empty object.

*See Flow JSON reference for entry screen details.

Now let's consider what a message sending request might look like using Cloud API:

Sample Request

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_id": "1",
        "flow_cta": "Book!",
        "flow_action": "navigate",
        "flow_action_payload": {
          "screen": "<SCREEN_NAME>",
          "data": { 
            "product_name": "name",
            "product_description": "description",
            "product_price": 100
          }
        }
      }
    }
  }
}'

Sample Response

{
  "contacts": [
    {
      "Input": "+447385946746",
      "wa_id": "47385946746"
    }
  ],
  "messages": [
    {
      "id": "gHTRETHRTHTRTH-av4Y"
    }
  ],
  "meta": {
    "api_status": "stable",
    "version": "2.44.0.27"
  }
}

Template Messages

You can send a template message with a WhatsApp Flow. Only published Flows can be sent this way. We introduced a new button type called FLOW. Use this type to specify the Flow to be sent with the template message.

First you need to create a template . Here is an example request:

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>",
          "navigate_screen":  "Flows Json screen name",
          "flow_action": "navigate"
        }
      ]
    }
  ]
}'
Parameter Description
buttons
? flow_id
string
The unique ID of a Flow.
? nagivate_screen
string
Required if flow_action is navigate . The unique ID of the Screen in the Flow.
? flow_action
string
Either navigate or data_exchange .
(Default value: navigate )

You are able to send messages in these languages .

Sample Response

{
  "id": "<template-id>",
  "status": "PENDING",
  "category": "MARKETING"
}

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

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

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

{
  "messaging_product": "whatsapp",
  "contacts": [
    {
      "input": "<phone-number>",
      "wa_id": "<phone-number>"
    }
  ],
  "messages": [
    {
      "id": "<message-id>"
    }
  ]
}
- "漢字路" 한글한자자동변환 서비스는 교육부 고전문헌국역지원사업의 지원으로 구축되었습니다.
- "漢字路" 한글한자자동변환 서비스는 전통문화연구회 "울산대학교한국어처리연구실 옥철영(IT융합전공)교수팀"에서 개발한 한글한자자동변환기를 바탕하여 지속적으로 공동 연구 개발하고 있는 서비스입니다.
- 현재 고유명사(인명, 지명등)을 비롯한 여러 변환오류가 있으며 이를 해결하고자 많은 연구 개발을 진행하고자 하고 있습니다. 이를 인지하시고 다른 곳에서 인용시 한자 변환 결과를 한번 더 검토하시고 사용해 주시기 바랍니다.
- 변환오류 및 건의,문의사항은 juntong@juntong.or.kr로 메일로 보내주시면 감사하겠습니다. .
Copyright ⓒ 2020 By '전통문화연구회(傳統文化硏究會)' All Rights reserved.
 한국   대만   중국   일본