Skip to content

Flow Template Messages

Flow template message transforms a simple chat into a mini-application, making it easier and more intuitive for users to interact with businesses and complete specific tasks without leaving the messaging platform.

Image Alt Text

Flow Object

Parameter Type Description
flow_token String flow_token is optional ."unused" is taken as default .
flow_action_data object flow_action_data is optional .json object with the data payload for the first screen.
*action_type String Action Type required
*index String Position index of the button. Required if you have flow button in your template .
     "buttons": {

                      "button_flow":[
                        {"flow_token":"unused",
                        "action_type":"flow",
                        "index":"0",
                        "flow_action_data":{}
                        }
                      ]
                }

Programing Examples:

curl --location 'https://api.d7networks.com/whatsapp/v2/send' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{api_access_token}}' \
--data '{
    "messages": [
        {
            "originator": "{{originator}}",
             "content": {
            "message_type": "TEMPLATE",
            "template": {
                template_id: "{{template_id}}",
                "language": "en",
                "buttons": {

                      "button_flow":[
                        {"flow_token":"unused",
                        "action_type":"flow",
                        "index":"0",
                        "flow_action_data":{}
                        }
                      ]
                }
            }
        },
                "recipients": [
                    {
                        "recipient": "{{recipient1}}",
                        "recipient_type": "individual"
                    }
                ],
                "report_url": "https://the_url_to_recieve_delivery_report.com"

        }
    ]
}'
npm i direct7
const Client = require('direct7')
const client = new Client(apiToken="Your API token")
const response = await client.whatsapp.sendWhatsAppTemplatedMessage({
        originator: "{{originator}}",
        recipients: [{"recipient": "{{recipient1}}","recipient_type": "individual"}],
        template_id: "{{template_id}}",
        language: "en",
        button_flow: [
          {"flow_token":"unused",
            "action_type":"flow",
            "index":"0",
            "flow_action_data":{}
            }
        ]
    });
console.log('Templated message sent successfully. Response:', response);
pip install direct7
from direct7 import Client

client = Client(api_token="Your API token")

client.whatsapp.send_whatsapp_templated_message(originator="{{originator}}",
                                                recipients=[{"recipient": "{{recipient1}}","recipient_type": "individual"}],
                                                language="en",
                                                template_id="{{template_id}}",
                                                button_flow=[{"flow_token":"unused",
                                                "action_type":"flow",
                                                "index":"0",
                                                "flow_action_data":{}
                                                    }
                                                  ]
                                                )
composer require direct7/direct7-php
require_once 'vendor/autoload.php';
require_once __DIR__ . '/vendor/autoload.php';

use direct7\Direct7\Client;

$direct7 = new Client(api_token="Your API token");

$response = $direct7->whatsapp->sendWhatsAppTemplatedMessage(
    originator:"{originator}", 
    recipients: [["recipient" => "{recipient}", "recipient_type" => "individual"]], 
    template_id: "{template_id}", 
    language: 'en',
    button_flow:[
    [
        "flow_token" => "unused",
        "action_type" => "flow",
        "index" => "0",
        "flow_action_data" => []
    ]
]
);

var_dump($response);
go get -u github.com/d7networks/direct7-go-sdk
import (
    "github.com/d7networks/direct7-go-sdk/direct7"
    )
    apiToken := "Your Api Token"
    client := direct7.NewClient(apiToken)
    whatsapp := direct7.NewWhatsApp(client)
    originator := "+97156XXXXXXXX"
recipient := "+9180867XXXXXXX"
templateId := "call_to_action"
language := "en"
buttonFlow := []map[string]interface{}{
    {
        "flow_token":     "unused",
        "action_type":    "flow",
        "index":          "0",
        "flow_action_data": map[string]interface{}{},
    },
}
optParams := &OptionalParams{
    ButtonFlow: buttonFlow,
}
response, err := client.whatsapp.SendWhatsAppTemplatedMessage(originator, recipient, templateId, language, optParams)
gem install direct7
require 'direct7'

client = Direct7::Client.new('Your API token')

button_flow=[
          {"flow_token":"unused",
            "action_type":"flow",
            "index":"0",
            "flow_action_data":{}
            }
        ]
response = @client.whatsapp.send_whatsapp_templated_message(
   originator='971563XXXXXX',
  recipient='991999999XXXX',
  template_id="call_to_action",
  language="en",
  body_parameter_values=nil, media_type=nil, text_header_title=nil, media_url=nil, latitude=nil, longitude=nil, name=nil, address=nil,lto_expiration_time_ms=nil, coupon_code=nil,
  quick_replies=nil,
  actions=nil,
  button_flow=button_flow
)