Skip to content

Whatsapp Reaction Messages

Carousel templates Messages allow you to send a single text message accompanied by a set of up to 10 carousel cards in a horizontally scrollable view

Image Alt Text

Reaction Object

Parameter Type Description
*card_index number Zero-indexed order in which card appears within the card carousel. 0 indicates first card, 1 indicates second card, etc.
*components Array(Object) Includes the header object, body object and button object. See example
    "carousel": {
                "cards": [
                    {
                        "card_index": "0",
                        "components": [
                          /* Message bubble; can omit if template message bubble has no variables */
                            {
                                "type": "header",
                                "parameters": [
                                  /* Required if template uses image header, otherwise omit */
                                    {
                                        "type": "image",
                                        "image": {
                                            "id": "1585106238959535"
                                        }
                                    }
                                ]
                            },
                            /* Can be omitted if card body text in template has no variables */
                            {
                                "type": "body",
                                "parameters": [
                                    {
                                        "type": "text",
                                        "text": "15OFF"
                                    },
                                    {
                                        "type": "text",
                                        "text": "15%"
                                    }
                                ]
                            },
                            {
                                "type": "button",
                                "sub_type": "quick_reply",
                                "index": "0",
                                "parameters": [
                                    {
                                        "type": "payload",
                                        "payload": "59NqSd"
                                    }
                                ]
                            }
                        ]
                    }
                  ]
                }

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": {
                "preview_url": false,
                "message_type": "TEMPLATE",
                "template": {
                    "template_id": "{{template_id}}",
                    "language" : "en",
                    "body_parameter_values": {
                        "0": "parameter1",
                        "1": "parameter2"
                    },
                    "carousel": {
                        "cards": [
                            {
                                "card_index": "0",
                                "components": [
                                    {
                                        "type": "header",
                                        "parameters": [
                                            {
                                                "type": "image",
                                                "image": {
                                                    "id": "1585106238959535"
                                                }
                                            }
                                        ]
                                    },
                                    {
                                        "type": "body",
                                        "parameters": [
                                            {
                                                "type": "text",
                                                "text": "parameter1"
                                            },
                                            {
                                                "type": "text",
                                                "text": "parameter2"
                                            }
                                        ]
                                    },
                                    {
                                        "type": "button",
                                        "sub_type": "quick_reply",
                                        "index": "0",
                                        "parameters": [
                                            {
                                                "type": "payload",
                                                "payload": "59NqSd"
                                            }
                                        ]
                                    }
                                ]
                            },
                            {
                                "card_index": "1",
                                "components": [
                                    {
                                        "type": "header",
                                        "parameters": [
                                            {
                                                "type": "image",
                                                "image": {
                                                    "id": "1585106238959535"
                                                }
                                            }
                                        ]
                                    },
                                    {
                                        "type": "body",
                                        "parameters": [
                                            {
                                                "type": "text",
                                                "text": "parameter1"
                                            },
                                            {
                                                "type": "text",
                                                "text": "parameter2"
                                            }
                                        ]
                                    },
                                    {
                                        "type": "button",
                                        "sub_type": "quick_reply",
                                        "index": "0",
                                        "parameters": [
                                            {
                                                "type": "payload",
                                                "payload": "59NqSdd"
                                            }
                                        ]
                                    }
                                ]
                            }
                        ]
                    }
                }
            },
            "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 cards = [
    {
        "card_index": "0",
        "components": [
            {
                "type": "header",
                "parameters": [
                    {
                        "type": "image",
                        "image": {
                            "link": "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
                        }
                    }
                ]
            },
            {
                "type": "body",
                "parameters": [
                    {
                        "type": "text",
                        "text": "parameter1"
                    },
                    {
                        "type": "text",
                        "text": "parameter2"
                    }
                ]
            },
            {
                "type": "button",
                "sub_type": "quick_reply",
                "index": "0",
                "parameters": [
                    {
                        "type": "payload",
                        "payload": "2259NqSd"
                    }
                ]
            }
        ]
    }
]
response = await client.whatsapp.sendWhatsAppTemplatedMessage({originator:"{originator}", recipient:"{recipient}",  template_id:"carousel_card", language: "en", carousel_cards:cards});
console.log('Templated message sent successfully. Response:', response);
pip install direct7
from direct7 import Client

client = Client(api_token="Your API token")
carousl_cards = [
    {
        "card_index": "0",
        "components": [
            {
                "type": "header",
                "parameters": [
                    {
                        "type": "image",
                        "image": {
                            "link": "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
                        }
                    }
                ]
            },
            {
                "type": "button",
                "sub_type": "quick_reply",
                "index": "0",
                "parameters": [
                    {
                        "type": "payload",
                        "payload": "2259NqSd"
                    }
                ]
            }
        ]
    }
]

response = client.whatsapp.send_whatsapp_templated_message(originator="{{originator}}", recipient="{{recipient}}",
                                                           language="en", template_id="{{template_id}}",
                                                           carousel_cards=carousl_cards)
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");
$cards = [
    [
        "card_index" => "0",
        "components" => [
            [
                "type" => "header",
                "parameters" => [
                    [
                        "type" => "image",
                        "image" => [
                            "link" => "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
                        ]
                    ]
                ]
            ],
            [
                "type" => "button",
                "sub_type" => "quick_reply",
                "index" => "0",
                "parameters" => [
                    [
                        "type" => "payload",
                        "payload" => "2259NqSd"
                    ]
                ]
            ]
        ]
    ]
];

$response = $direct7->whatsapp->sendWhatsAppTemplatedMessage(
    originator:'{originator}',
    recipient:'{recipient}',
    language: 'en',
    template_id:'{template_id}',
    carousel_cards: $cards
);

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 := "{{originator}}"
recipient := "{{recipient}}"
templateID := "marketing_media_image"
cards := []map[string]interface{}{
    {
        "card_index": "0",
        "components": []map[string]interface{}{
            {
                "type": "header",
                "parameters": []map[string]interface{}{
                    {
                        "type": "image",
                        "image": map[string]interface{}{
                            "link": "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg",
                        },
                    },
                },
            },
            {
                "type": "button",
                "sub_type": "quick_reply",
                "index": "0",
                "parameters": []map[string]interface{}{
                    {
                        "type": "payload",
                        "payload": "2259NqSd",
                    },
                },
            },
        },
    }
}
optParams := &OptionalParams{carousel_card: cards}

response, err := whatsapp.SendWhatsAppTemplatedMessage(originator, recipient, templateID, optParams)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"messages\": [\n        {\n            \"originator\": \"{{originator}}\",\n            \"content\": {\n                \"preview_url\": false,\n                \"message_type\": \"TEMPLATE\",\n                \"template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"body_parameter_values\": {\n                        \"0\": \"parameter1\",\n                        \"1\": \"parameter2\"\n                    },\n                    \"carousel\": {\n                        \"cards\": [\n                            {\n                                \"card_index\": \"0\",\n                                \"components\": [\n                                    {\n                                        \"type\": \"header\",\n                                        \"parameters\": [\n                                            {\n                                                \"type\": \"image\",\n                                                \"image\": {\n                                                    \"id\": \"1585106238959535\"\n                                                }\n                                            }\n                                        ]\n                                    },\n                                    {\n                                        \"type\": \"body\",\n                                        \"parameters\": [\n                                            {\n                                                \"type\": \"text\",\n                                                \"text\": \"parameter1\"\n                                            },\n                                            {\n                                                \"type\": \"text\",\n                                                \"text\": \"parameter2\"\n                                            }\n                                        ]\n                                    },\n                                    {\n                                        \"type\": \"button\",\n                                        \"sub_type\": \"quick_reply\",\n                                        \"index\": \"0\",\n                                        \"parameters\": [\n                                            {\n                                                \"type\": \"payload\",\n                                                \"payload\": \"59NqSd\"\n                                            }\n                                        ]\n                                    }\n                                ]\n                            },\n                            {\n                                \"card_index\": \"1\",\n                                \"components\": [\n                                    {\n                                        \"type\": \"header\",\n                                        \"parameters\": [\n                                            {\n                                                \"type\": \"image\",\n                                                \"image\": {\n                                                    \"id\": \"1585106238959535\"\n                                                }\n                                            }\n                                        ]\n                                    },\n                                    {\n                                        \"type\": \"body\",\n                                        \"parameters\": [\n                                            {\n                                                \"type\": \"text\",\n                                                \"text\": \"parameter1\"\n                                            },\n                                            {\n                                                \"type\": \"text\",\n                                                \"text\": \"parameter2\"\n                                            }\n                                        ]\n                                    },\n                                    {\n                                        \"type\": \"button\",\n                                        \"sub_type\": \"quick_reply\",\n                                        \"index\": \"0\",\n                                        \"parameters\": [\n                                            {\n                                                \"type\": \"payload\",\n                                                \"payload\": \"59NqSdd\"\n                                            }\n                                        ]\n                                    }\n                                ]\n                            }\n                        ]\n                    }\n                }\n            },\n            \"recipients\": [\n                {\n                    \"recipient\": \"{{recipient1}}\",\n                    \"recipient_type\": \"individual\"\n                }\n            ],\n            \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n        }\n    ]\n}\n");
Request request = new Request.Builder()
.url("https://api.d7networks.com/whatsapp/v2/send")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", "Bearer {{api_access_token}}")
.build();
Response response = client.newCall(request).execute();
var headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer {{api_access_token}}'
};
var request = http.Request('POST', Uri.parse('https://api.d7networks.com/whatsapp/v2/send'));
request.body = json.encode({
"messages": [
    {
    "originator": "{{originator}}",
    "content": {
        "preview_url": false,
        "message_type": "TEMPLATE",
        "template": {
        "template_id": "{{template_id}}",
        "language" : "en",
        "body_parameter_values": {
            "0": "parameter1",
            "1": "parameter2"
        },
        "carousel": {
            "cards": [
            {
                "card_index": "0",
                "components": [
                {
                    "type": "header",
                    "parameters": [
                    {
                        "type": "image",
                        "image": {
                        "id": "1585106238959535"
                        }
                    }
                    ]
                },
                {
                    "type": "body",
                    "parameters": [
                    {
                        "type": "text",
                        "text": "parameter1"
                    },
                    {
                        "type": "text",
                        "text": "parameter2"
                    }
                    ]
                },
                {
                    "type": "button",
                    "sub_type": "quick_reply",
                    "index": "0",
                    "parameters": [
                    {
                        "type": "payload",
                        "payload": "59NqSd"
                    }
                    ]
                }
                ]
            },
            {
                "card_index": "1",
                "components": [
                {
                    "type": "header",
                    "parameters": [
                    {
                        "type": "image",
                        "image": {
                        "id": "1585106238959535"
                        }
                    }
                    ]
                },
                {
                    "type": "body",
                    "parameters": [
                    {
                        "type": "text",
                        "text": "parameter1"
                    },
                    {
                        "type": "text",
                        "text": "parameter2"
                    }
                    ]
                },
                {
                    "type": "button",
                    "sub_type": "quick_reply",
                    "index": "0",
                    "parameters": [
                    {
                        "type": "payload",
                        "payload": "59NqSdd"
                    }
                    ]
                }
                ]
            }
            ]
        }
        }
    },
    "recipients": [
        {
        "recipient": "{{recipient1}}",
        "recipient_type": "individual"
        }
    ],
    "report_url": "https://the_url_to_recieve_delivery_report.com"
    }
]
});
request.headers.addAll(headers);

http.StreamedResponse response = await request.send();

if (response.statusCode == 200) {
print(await response.stream.bytesToString());
}
else {
print(response.reasonPhrase);
}
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("Authorization", "Bearer {{api_access_token}}")

$body = @"
{
    `"messages`": [
        {
            `"originator`": `"{{originator}}`",
            `"content`": {
                `"preview_url`": false,
                `"message_type`": `"TEMPLATE`",
                `"template`": {
                    `"template_id`": `"{{template_id}}`",
                    `"body_parameter_values`": {
                        `"0`": `"parameter1`",
                        `"1`": `"parameter2`"
                    },
                    `"carousel`": {
                        `"cards`": [
                            {
                                `"card_index`": `"0`",
                                `"components`": [
                                    {
                                        `"type`": `"header`",
                                        `"parameters`": [
                                            {
                                                `"type`": `"image`",
                                                `"image`": {
                                                    `"id`": `"1585106238959535`"
                                                }
                                            }
                                        ]
                                    },
                                    {
                                        `"type`": `"body`",
                                        `"parameters`": [
                                            {
                                                `"type`": `"text`",
                                                `"text`": `"parameter1`"
                                            },
                                            {
                                                `"type`": `"text`",
                                                `"text`": `"parameter2`"
                                            }
                                        ]
                                    },
                                    {
                                        `"type`": `"button`",
                                        `"sub_type`": `"quick_reply`",
                                        `"index`": `"0`",
                                        `"parameters`": [
                                            {
                                                `"type`": `"payload`",
                                                `"payload`": `"59NqSd`"
                                            }
                                        ]
                                    }
                                ]
                            },
                            {
                                `"card_index`": `"1`",
                                `"components`": [
                                    {
                                        `"type`": `"header`",
                                        `"parameters`": [
                                            {
                                                `"type`": `"image`",
                                                `"image`": {
                                                    `"id`": `"1585106238959535`"
                                                }
                                            }
                                        ]
                                    },
                                    {
                                        `"type`": `"body`",
                                        `"parameters`": [
                                            {
                                                `"type`": `"text`",
                                                `"text`": `"parameter1`"
                                            },
                                            {
                                                `"type`": `"text`",
                                                `"text`": `"parameter2`"
                                            }
                                        ]
                                    },
                                    {
                                        `"type`": `"button`",
                                        `"sub_type`": `"quick_reply`",
                                        `"index`": `"0`",
                                        `"parameters`": [
                                            {
                                                `"type`": `"payload`",
                                                `"payload`": `"59NqSdd`"
                                            }
                                        ]
                                    }
                                ]
                            }
                        ]
                    }
                }
            },
            `"recipients`": [
                {
                    `"recipient`": `"{{recipient1}}`",
                    `"recipient_type`": `"individual`"
                }
            ],
            `"report_url`": `"https://the_url_to_recieve_delivery_report.com`"
        }
    ]
}

"@

$response = Invoke-RestMethod 'https://api.d7networks.com/whatsapp/v2/send' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
gem install direct7
require 'direct7'

client = Direct7::Client.new('Your API token')
cards = [
    {
      "card_index" => "0",
      "components" => [
        {
          "type" => "header",
          "parameters" => [
            {
              "type" => "image",
              "image" => {
                "link" => "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
              }
            }
          ]
        },
        {
          "type" => "button",
          "sub_type" => "quick_reply",
          "index" => "0",
          "parameters" => [
            {
              "type" => "payload",
              "payload" => "2259NqSd"
            }
          ]
        }
      ]
    }
  ]
client.whatsapp.send_whatsapp_templated_message(
    originator='{originator}', 
    recipient='{recipient}',
    template_id="{template_id}", 
    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, 
    carousel_cards=cards
)
1
2
3
4
5
6
7
8
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.d7networks.com/whatsapp/v2/send");
request.Headers.Add("Authorization", "Bearer {{api_access_token}}");
var content = new StringContent("{\n    \"messages\": [\n        {\n            \"originator\": \"{{originator}}\",\n            \"content\": {\n                \"preview_url\": false,\n                \"message_type\": \"TEMPLATE\",\n                \"template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"body_parameter_values\": {\n                        \"0\": \"parameter1\",\n                        \"1\": \"parameter2\"\n                    },\n                    \"carousel\": {\n                        \"cards\": [\n                            {\n                                \"card_index\": \"0\",\n                                \"components\": [\n                                    {\n                                        \"type\": \"header\",\n                                        \"parameters\": [\n                                            {\n                                                \"type\": \"image\",\n                                                \"image\": {\n                                                    \"id\": \"1585106238959535\"\n                                                }\n                                            }\n                                        ]\n                                    },\n                                    {\n                                        \"type\": \"body\",\n                                        \"parameters\": [\n                                            {\n                                                \"type\": \"text\",\n                                                \"text\": \"parameter1\"\n                                            },\n                                            {\n                                                \"type\": \"text\",\n                                                \"text\": \"parameter2\"\n                                            }\n                                        ]\n                                    },\n                                    {\n                                        \"type\": \"button\",\n                                        \"sub_type\": \"quick_reply\",\n                                        \"index\": \"0\",\n                                        \"parameters\": [\n                                            {\n                                                \"type\": \"payload\",\n                                                \"payload\": \"59NqSd\"\n                                            }\n                                        ]\n                                    }\n                                ]\n                            },\n                            {\n                                \"card_index\": \"1\",\n                                \"components\": [\n                                    {\n                                        \"type\": \"header\",\n                                        \"parameters\": [\n                                            {\n                                                \"type\": \"image\",\n                                                \"image\": {\n                                                    \"id\": \"1585106238959535\"\n                                                }\n                                            }\n                                        ]\n                                    },\n                                    {\n                                        \"type\": \"body\",\n                                        \"parameters\": [\n                                            {\n                                                \"type\": \"text\",\n                                                \"text\": \"parameter1\"\n                                            },\n                                            {\n                                                \"type\": \"text\",\n                                                \"text\": \"parameter2\"\n                                            }\n                                        ]\n                                    },\n                                    {\n                                        \"type\": \"button\",\n                                        \"sub_type\": \"quick_reply\",\n                                        \"index\": \"0\",\n                                        \"parameters\": [\n                                            {\n                                                \"type\": \"payload\",\n                                                \"payload\": \"59NqSdd\"\n                                            }\n                                        ]\n                                    }\n                                ]\n                            }\n                        ]\n                    }\n                }\n            },\n            \"recipients\": [\n                {\n                    \"recipient\": \"{{recipient1}}\",\n                    \"recipient_type\": \"individual\"\n                }\n            ],\n            \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n        }\n    ]\n}\n", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());