Create Flow
POST Method
kaleyra's Create Flow API allows you to create WhatsApp Flows. Using the WhatsApp Flow you can build structured interactions for business messaging. With Flows, businesses can define, configure, and customize messages with rich interactions that give customers more structure in the way they communicate.
For example, an automotive dealer wants its customers to schedule an appointment for a test drive for a car from car showrooms located at multiple locations. Using the flow, the brand can provide options to its customers to select a showroom and book an appointment based on State, District, PIN or ZIP code, Area, and so on. When a customer selects a State, the defined flow can give them an option to select the District within the State in the next District field. Similarly, they can collect other details from customers using the flow templates.
Benefits
The following are the benefits of WhatsApp Flow:
- You can define, configure, and customize messages with rich interactions that give customers more structure in the way they communicate.
- Helps in generating leads, recommending products, getting new sales leads, or anything else where structured communication is more natural or comfortable for your customers.
Prerequisites
- Before you get started, Create an API Key. To view the API Key and the SID, see View API Key and SID.
A prerequisite for using Kaleyra WhatsApp APIs is to have an active WhatsApp plan on kaleyra platform. - To set up a WhatsApp account on kaleyra platform, see Manual Signup
and Embedded Signup. - An active WhatsApp for Business API plan that includes:
- A WhatsApp business number.
- An associated profile with the business number.
- A WhatsApp verified and approved profile.
- WABA ID must be onboarded on Kaleyra WhatsApp API V2 compatible.
Base URL
https://<api_domain>/v2/<SID>
API Domain and Value
api_domain | Value |
---|---|
IN pod | api.in.kaleyra.io |
SG Pod | api.ap.kaleyra.io |
EU Pod | api.eu.kaleyra.io |
API request to create WhatsApp Flow
To create WhatsApp Flow, use the https://<api_domain>/v2/<sid>/whatsapp/<waba_id>/flows
endpoint with the following request method.
Request Format
The following is the request format to create WhatsApp Flow:
curl --location POST \ 'https://<api_domain>/v2/<sid>/whatsapp/<waba_id>/flows' \
--header 'api-key: <api-key>' \
--header 'Content-Type: application/json' \
--data '{
"name": "<name>",
"endpoint_uri" : "<endpoint_uri>",
"categories": [ "categories" ]
}'
Sample Request Format
The following is the sample request format to create a WhatsApp Flow:
curl --location POST \ 'https://api.in.kaleyra.io/v2/HXAP16XXXXXX97IN/whatsapp/1090xxxxxxxxxxxx/flows' \
--header 'api-key: Axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx3' \
--header 'Content-Type: application/json' \
--data '{
"name": "First flow demo",
"endpoint_uri" : "https://www.tatacommunications.com/",
"categories": [ "APPOINTMENT_BOOKING" ]
}'
Note:
- New Flows are by default created in DRAFT status and you can make changes to the Flow by uploading a JSON file.
- You can create a new published Flow in a single request by specifying
flow_json
and publish parameters.- The above request format is only to show the POST method to create a Flow. For more information about the different possible types of WhatsApp Flow that can be created please refer to the Send Flow Messages.
URL Parameters and Headers
Following is the list of parameters and headers to send the outgoing message request:
Parameter / Headers | Data Type | Description | Example | Mandatory? |
---|---|---|---|---|
sid | String | Account SID (Security Identifier). | HXAP16XXXXXX97IN | Yes |
waba_id | String | WhatsApp Business Account. For more information, see step 1 to step 3 of Adding a new WABA ID. | 1090xxxxxxxxxxxx | Yes |
Content-Type | String | Indicates the format of the content the API will be processing. | The only allowed value is application/json. | Yes |
api-key | String | API key generated from Kaleyra platform account. | Axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx3 | Yes |
Note:
For the complete list of supported parameters, see Flows API.
Following is the list of a few supported parameters to be used in the payload to create the WhatsApp Flow:
Parameter | Data Type | Description | Example | Mandatory? |
---|---|---|---|---|
name | String | The name you want to provide for your WhatsApp Flow. | First flow demo | Yes |
endpoint_uri | String | The URI you want to use in the WhatsApp Flow from your business link. | https://www.tatacommunications.com/ | No |
categories | Array of string | The category templates using which you want to define the WhatsApp Flow. The following are the supported categories: - SIGN_UP - SIGN_IN - APPOINTMENT_BOOKING - LEAD_GENERATION - SHOPPING - CONTACT_US - CUSTOMER_SUPPORT - SURVEY - OTHER Note: You can use multiple categories separated by a comma based on your WhatsApp Flow. | APPOINTMENT_BOOKING | Yes |
Sample Success Response
The following success message appears with the status 200 Accepted:
200 OK
{
"code":"WA200",
"message": "Request Processed Successfully",
"data": {
"id": "112xxxxxxxxxx207"
}
"error": {}
}
Sample Failure Response
The following are the failure responses:
401 Unauthorized
{
"code": "RBC001",
"message": "Incorrect SID or API key.",
"data": [],
"error": {
"error": "Incorrect SID or API key."
}
}
401 Wrong account
{
"code": "WA-401",
"message": "API is not available for given customer.Please contact support for more info",
"data": {},
"error": "API is not available for given customer.Please contact support for more info"
}
400 Incorrect payload
{
"code": "WA-400",
"message": "Refer to correct payload format",
"data": {},
"error": {
"payload": "Incorrect payload format"
}
}
500 Internal Server Error
{
"code": "WA-500",
"message": "Please try again later",
"data": {},
"error": {
"error": "Internal server error"
}
}
{
"code": "WA-401",
"message": "The flow_id either does not exist or does not belong to the account.",
"data": {},
"error": {
"flow_id": "The flow_id either does not exist or does not belong to the account."
}
}
Updated about 15 hours ago