Skip to content

Whatsapp Custom Templates Messages

Image Alt Text

Custom Template Object

Parameter Type Description
*template_id String Template ID configured for WhatsApp template (HSM). This should be registered and approved by D7. You can create a new Whatsapp Template here
*language String Specifies the code of language the template may be rendered in. Supported languages
body_parameter_values Dict The Object of the body parameter values. Only required if your body text have variables.
media Object Includes the parameters of template header
buttons Object Details of the button object.
carousel Object Carousel template object
limited_time_offer Object LTO Template Object
Parameter Type Description
*media_type String Type of the attachment you want to send through your template. Valid: text, image, audio, document, video
*media_url String URL for the attachment. Required except the media type is location/text.
*text_header_title String Required only if approved template having text header and a parameter included in header text.
*location Object Details of the location object, if media type is location
    "media": {
                "media_type": "text",
                "text_header_title": "Tom"
            },
    "media": {
                "media_type": "image",
                "media_url": "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
            },
    "media": {
            "media_type": "document",
            "media_url": "http://www.africau.edu/images/default/sample.pdf"
        },
    "media": {
            "media_type": "video",
            "media_url": "http://www.onirikal.com/videos/mp4/nestlegold.mp4"
        },
    "media": {
            "media_type": "location",
            "location": {
                "latitude": "12.93803129081362",
                "longitude": "77.61088653615994",
                "name": "Karix Mobile Pvt Ltd",
                "address": "30, Hosur Rd, 7th Block, Koramangala, Bengaluru, Karnataka 560095"
            }
        }

Parameter Type Description
*quick_replies Array(Object) List of quick_replies button object. This is required if you wants to add quick reply buttons in your message.
*actions Array(object) List of actions button object. This is required if you wants to add call to action buttons in your message.
*coupon_code Array(Object) List of coupon code button object. This is required if you wants to add coupon code buttons in your message.
Parameter Type Description
*button_index String Position index of the button. Required if you have quick reply in your template.
*button_payload String Developer-defined payload that will be returned when the button is clicked.
Parameter Type Description
*action_type String Type of action that whats to do while clicking the button. Supported Values: Dial and URL.
*action_index String Position index of the button. Required if you have either url or dial button in your template.
*action_payload String Developer-defined payload that will be returned when the button is clicked. For Dial Its a phone number and For URL it is a url.
Parameter Type Description
*index String Position index of the button. Required if you have copy code button in your template.
*type String Type of the coupen code
*coupon_code String The coupon code to be copied when the customer taps the button.
    "buttons": {
            "quick_replies": [
                {
                    "button_index": "0",
                    "button_payload": "SMS"
                },
                {
                    "button_index": "1",
                    "button_payload": "VIBER",
                }
            ]
        }
    "buttons": {
            "actions": [
                {
                    "action_index": "0",
                    "action_type": "URL",
                    "action_payload": "invoice/2345345345"
                }
            ]
        }
    "buttons": {
            "coupon_code": [
                {
                    "index": 0,
                    "type": "copy_code",
                    "coupon_code": "GCBTS23"
                }
            ]
        }

Programing Examples:

1. Template without media and buttons

curl --location --request POST 'https://api.d7networks.com/whatsapp/v2/send' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {{api_access_token}}' \
--data-raw '{
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}",
            "language" : "en"
        }
    },
    "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}",
            recipient : "{recipient}",
            template_id : "{{template_id}}", language: "en"});

console.log(response);
pip install direct7
1
2
3
4
5
from direct7 import Client

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

client.whatsapp.send_whatsapp_templated_message(originator="{{originator}}", language="en", recipient="{{recipient}}", template_id="{{template_id}}")

composer require direct7/direct7-php
require_once 'vendor/autoload.php';
require_once __DIR__ . '/vendor/autoload.php';

use direct7\Direct7\Client;

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

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

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 := "testing_alpha"
language := "en"
optParams := &OptionalParams{
}
response, err := client.whatsapp.SendWhatsAppTemplatedMessage(originator, recipient, templateId, language, 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        \"originator_name\": \"originator_name\",\n        \"recipients\": [\"{{recipient1}}\",\"{{recipient2}}\"],\n        \"content\": {\n                \"message_type\": \"TEMPLATE\",\n       \"template\":{\n                    \"template_id\": \"{{template_id}}\",\n                    }\n                }\n            },\n      \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\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("Accept", "application/json")
.addHeader("Authorization", "Bearer {{api_access_token}}")
.build();
Response response = client.newCall(request).execute();
var headers = {
'Content-Type': 'application/json',
'Accept': '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}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}",
            "language" : "en"
        }
    },
    "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);
}
1
2
3
4
5
6
7
8
9
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("Accept", "application/json")
$headers.Add("Authorization", "Bearer {{api_access_token}}")

$body = "{`n  `"messages`": [`n    {`n        `"originator`": `"{{originator}}`",`n        `"originator_name`": `"{{originator_name}}`",`n        `"recipients`": [`"{{recipient1}}`",`"{{recipient2}}`"],`n        `"content`": {`n        `"message_type`": `"TEMPLATE`",`n        `"template`": {`n        `"template_id`": `"{{template_id}}`",`n}`n}`n},`n       `"report_url`": `"https://the_url_to_recieve_delivery_report.com`"`n}`n  ] `n}"

$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')

client.whatsapp.send_whatsapp_templated_message(
    originator='{originator}', 
    recipient='{recipient}',
    template_id="{template_id}", 
    language="en"
)
1
2
3
4
5
6
7
8
9
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.d7networks.com/whatsapp/v2/send");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer {{api_access_token}}");
var content = new StringContent("{\n  \"messages\": [\n    {\n        \"originator\": \"{{originator}}\",\n        \"originator_name\": \"originator_name\",\n        \"recipients\": [\"{{recipient1}}\",\"{{recipient2}}\"],\n        \"content\": {\n                \"message_type\": \"TEMPLATE\",\n       \"template\":{\n                    \"template_id\": \"{{template_id}}\",\n                    }\n                }\n            },\n      \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n    }\n  ]\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
curl --location --request POST 'https://api.d7networks.com/whatsapp/v2/send' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {{api_access_token}}' \
--data-raw '{
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}",
            "language" : "en",
            "body_parameter_values": {
                "0": "first_parameter_in_your_template",
                "1": "second_parameter_in_your_template"
            }
        }
    },
    "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}",
            recipient : "{recipient}",
            template_id : "{{template_id}}",
            language: "en",
            body_parameter_values : {"0": "first_parameter_in_your_template", "1": "second_parameter_in_your_template"}});

console.log(response);
pip install direct7
1
2
3
4
5
from direct7 import Client

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

client.whatsapp.send_whatsapp_templated_message(originator="{{originator}}", recipient="{{recipient}}", language="en", template_id="{{template_id}}", body_parameter_values={"0": "first_parameter_in_your_template", "1": "second_parameter_in_your_template"})

composer require direct7/direct7-php
require_once 'vendor/autoload.php';
require_once __DIR__ . '/vendor/autoload.php';

use direct7\Direct7\Client;

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

$body_parameter_values = ["0" => 'first_parameter_in_your_template', "1" => 'second_parameter_in_your_template'];

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

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 := "with_personalize"
language := "en"
optParams := &OptionalParams{bodyParameterValues: map[string]interface{}{
            "0": "Anu",
}}

response, err := client.whatsapp.SendWhatsAppTemplatedMessage(originator, recipient, templateId, language, 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        \"originator_name\": \"originator_name\",\n        \"recipients\": [\"{{recipient1}}\",\"{{recipient2}}\"],\n        \"content\": {\n                \"message_type\": \"TEMPLATE\",\n       \"template\":{\n                    \"template_id\": \"{{template_id}}\",\n                    \"body_parameter_values\":{\n                        \"0\": \"first_parameter_in_your_template\",\n                        \"1\": \"second_parameter_in_your_template\",\n                    }\n                }\n            },\n      \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\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("Accept", "application/json")
.addHeader("Authorization", "Bearer {{api_access_token}}")
.build();
Response response = client.newCall(request).execute();
var headers = {
'Content-Type': 'application/json',
'Accept': '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}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}",
            "language" : "en",
            "body_parameter_values": {
                "0": "first_parameter_in_your_template",
                "1": "second_parameter_in_your_template"
            }
        }
    },
    "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);
}
1
2
3
4
5
6
7
8
9
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("Accept", "application/json")
$headers.Add("Authorization", "Bearer {{api_access_token}}")

$body = "{`n  `"messages`": [`n    {`n        `"originator`": `"{{originator}}`",`n        `"originator_name`": `"{{originator_name}}`",`n        `"recipients`": [`"{{recipient1}}`",`"{{recipient2}}`"],`n        `"content`": {`n        `"message_type`": `"TEMPLATE`",`n        `"template`": {`n        `"template_id`": `"{{template_id}}`",`n      `"body_parameter_values`": {`n        `"0`": `"first_parameter_in_your_template`",`n        `"2`": `"second_parameter_in_your_template`"`n}`n}`n},`n       `"report_url`": `"https://the_url_to_recieve_delivery_report.com`"`n}`n  ] `n}"

$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')

client.whatsapp.send_whatsapp_templated_message(
    originator='{originator}', 
    recipient='{recipient}',
    template_id="{template_id}", 
    language="en",
    body_parameter_values={"0": "first_parameter_in_your_template", "1": "second_parameter_in_your_template"}
)
1
2
3
4
5
6
7
8
9
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.d7networks.com/whatsapp/v2/send");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer {{api_access_token}}");
var content = new StringContent("{\n  \"messages\": [\n    {\n        \"originator\": \"{{originator}}\",\n        \"originator_name\": \"originator_name\",\n        \"recipients\": [\"{{recipient1}}\",\"{{recipient2}}\"],\n        \"content\": {\n                \"message_type\": \"TEMPLATE\",\n       \"template\":{\n                    \"template_id\": \"{{template_id}}\",\n                    \"body_parameter_values\":{\n                        \"0\": \"first_parameter_in_your_template\",\n                        \"1\": \"second_parameter_in_your_template\",\n                    }\n                }\n            },\n      \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n    }\n  ]\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

2. Template with media without buttons

curl --location --request POST 'https://api.d7networks.com/whatsapp/v2/send' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {{api_access_token}}' \
--data-raw '{
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}",
            "language" : "en",
            "media":{
                    "media_type": "text",
                    "text_header_title": "Tom"
                },
            "body_parameter_values": {
                "0": "first_parameter_in_your_template",
                "1": "second_parameter_in_your_template"
            }
        }
    },
    "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}", recipient : "{recipient}",
            template_id : "{{template_id}}", language: "en", body_parameter_values : {"0": "first_parameter_in_your_template", "1": "second_parameter_in_your_template"}, media_type : "text",
            text_header_title : "Tom"
        });

console.log(response);
pip install direct7
1
2
3
4
5
from direct7 import Client

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

client.whatsapp.send_whatsapp_templated_message(originator="{originator}", recipient="{recipient}", language="en", template_id="{{template_id}}", body_parameter_values={"0": "first_parameter_in_your_template", "1": "second_parameter_in_your_template"}, media_type="text", text_header_title="Tom")

composer require direct7/direct7-php
require_once 'vendor/autoload.php';
require_once __DIR__ . '/vendor/autoload.php';

use direct7\Direct7\Client;

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

$body_parameter_values = ["0" => 'first_parameter_in_your_template', "1" => 'second_parameter_in_your_template'];

$response = $direct7->whatsapp->sendWhatsAppTemplatedMessage(
    originator: '{originator}',
    recipient: '{recipient}',
    language: 'en',
    template_id: '{template_id}',
    media_type: 'text',
    text_header_title: 'Tom',
    body_parameter_values: $body_parameter_values,
);

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 := "header_param"
language := "en"
optParams := &OptionalParams{textHeaderTitle: "Tom"}
response, err := client.whatsapp.SendWhatsAppTemplatedMessage(originator, recipient, templateId, language, 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                \"message_type\": \"TEMPLATE\",\n                \"media_template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"media\": {\n                        \"media_type\": \"text\",\n                        \"text_header_title\": \"Tom\"\n                    },\n                    \"body_parameter_values\": {\n                        \"0\": \"first_parameter_in_your_template\",\n                        \"1\": \"second_parameter_in_your_template\"\n                    }\n                }\n            },\n            \"recipients\": [\n                {\n                    \"recipient\": [\n                        \"{{recipient1}}\",\n                        \"{{recipient2}}\"\n                    ]\n                }\n            ],\n            \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\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("Accept", "application/json")
.addHeader("Authorization", "Bearer {{api_access_token}}")
.build();
Response response = client.newCall(request).execute();
var headers = {
'Content-Type': 'application/json',
'Accept': '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}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}", 
            "language" : "en",
            "media":{
                    "media_type": "text",
                    "text_header_title": "Tom"
                }
            "body_parameter_values": {
                "0": "first_parameter_in_your_template",
                "1": "second_parameter_in_your_template"
            }
        }
    },
    "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);
}
1
2
3
4
5
6
7
8
9
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("Accept", "application/json")
$headers.Add("Authorization", "Bearer {{api_access_token}}")

$body = "{`\`n    `\`"messages`\`": [`\`n        {`\`n            `\`"originator`\`": `\`"{{originator}}`\`",`\`n            `\`"content`\`": {`\`n                `\`"message_type`\`": `\`"TEMPLATE`\`",`\`n                `\`"media_template`\`": {`\`n                    `\`"template_id`\`": `\`"{{template_id}}`\`",`\`n                    `\`"media`\`": {`\`n                        `\`"media_type`\`": `\`"text`\`",`\`n                        `\`"text_header_title`\`": `\`"Tom`\`"`\`n                    },`\`n                    `\`"body_parameter_values`\`": {`\`n                        `\`"0`\`": `\`"first_parameter_in_your_template`\`",`\`n                        `\`"1`\`": `\`"second_parameter_in_your_template`\`"`\`n                    }`\`n                }`\`n            },`\`n            `\`"recipients`\`": [`\`n                {`\`n                    `\`"recipient`\`": [`\`n                        `\`"{{recipient1}}`\`",`\`n                        `\`"{{recipient2}}`\`"`\`n                    ]`\`n                }`\`n            ],`\`n            `\`"report_url`\`": `\`"https://the_url_to_recieve_delivery_report.com`\`"`\`n        }`\`n    ]`\`n}"

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

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

client.whatsapp.send_whatsapp_templated_message(
    originator='{originator}', 
    recipient='{recipient}',
    template_id="{template_id}", 
    language="en",
    body_parameter_values={"0": "first_parameter_in_your_template", "1": "second_parameter_in_your_template"},
    media_type="text",
    text_header_title="Testing"
)
1
2
3
4
5
6
7
8
9
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.d7networks.com/whatsapp/v2/send");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer {{api_access_token}}");
var content = new StringContent("{\n    \"messages\": [\n        {\n            \"originator\": \"{{originator}}\",\n            \"content\": {\n                \"message_type\": \"TEMPLATE\",\n                \"media_template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"media\": {\n                        \"media_type\": \"text\",\n                        \"text_header_title\": \"Tom\"\n                    },\n                    \"body_parameter_values\": {\n                        \"0\": \"first_parameter_in_your_template\",\n                        \"1\": \"second_parameter_in_your_template\"\n                    }\n                }\n            },\n            \"recipients\": [\n                {\n                    \"recipient\": [\n                        \"{{recipient1}}\",\n                        \"{{recipient2}}\"\n                    ]\n                }\n            ],\n            \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n        }\n    ]\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
curl --location --request POST 'https://api.d7networks.com/whatsapp/v2/send' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {{api_access_token}}' \
--data-raw '{
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}",
            "language" : "en",
            "media":{
                    "media_type": "image",
                    "media_url": "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
                },
            "body_parameter_values": {
                "0": "first_parameter_in_your_template",
                "1": "second_parameter_in_your_template"
            }
        }
    },
    "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}", recipient : "{recipient}",
            template_id : "{{template_id}}", language: "en", body_parameter_values : {"0": "first_parameter_in_your_template", "1": "second_parameter_in_your_template"}, media_type : "image",
            media_url : "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
        });

console.log(response);
pip install direct7
1
2
3
4
5
from direct7 import Client

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

client.whatsapp.send_whatsapp_templated_message(originator="{originator}", recipient="{recipient}", language="en", template_id="{{template_id}}", body_parameter_values={"0": "first_parameter_in_your_template", "1": "second_parameter_in_your_template"}, media_type="image", media_url="https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg")

composer require direct7/direct7-php
require_once 'vendor/autoload.php';
require_once __DIR__ . '/vendor/autoload.php';

use direct7\Direct7\Client;

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

$body_parameter_values = ["0" => 'first_parameter_in_your_template', "1" => 'second_parameter_in_your_template'];

$response = $direct7->whatsapp->sendWhatsAppTemplatedMessage(
    originator: '{originator}',
    recipient: '{recipient}',
    language: 'en',
    template_id: '{template_id}',
    media_type: 'image',
    media_url: 'https://d7networks.com/static/resources/css/img/favicon.d27f70e6ebd0.png',
    body_parameter_values: $body_parameter_values,
);

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 := "image"
language := "en"
optParams := &OptionalParams{mediaType: "image", mediaURL: "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"}
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                \"message_type\": \"TEMPLATE\",\n                \"media_template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"media\": {\n                        \"media_type\": \"image\",\n                        \"media_url\": \"https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg\"\n                    },\n                    \"body_parameter_values\": {\n                        \"0\": \"first_parameter_in_your_template\",\n                        \"1\": \"second_parameter_in_your_template\"\n                    }\n                }\n            },\n            \"recipients\": [\n                {\n                    \"recipient\": [\n                        \"{{recipient1}}\",\n                        \"{{recipient2}}\"\n                    ]\n                }\n            ],\n            \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\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("Accept", "application/json")
.addHeader("Authorization", "Bearer {{api_access_token}}")
.build();
Response response = client.newCall(request).execute();
var headers = {
'Content-Type': 'application/json',
'Accept': '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}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}", 
            "language" : "en",
            "media":{
                    "media_type": "image",
                    "media_url": "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
                }
            "body_parameter_values": {
                "0": "first_parameter_in_your_template",
                "1": "second_parameter_in_your_template"
            }
        }
    },
    "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);
}
1
2
3
4
5
6
7
8
9
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("Accept", "application/json")
$headers.Add("Authorization", "Bearer {{api_access_token}}")

$body = "{`\`n    `\`"messages`\`": [`\`n        {`\`n            `\`"originator`\`": `\`"{{originator}}`\`",`\`n            `\`"content`\`": {`\`n                `\`"message_type`\`": `\`"TEMPLATE`\`",`\`n                `\`"media_template`\`": {`\`n                    `\`"template_id`\`": `\`"{{template_id}}`\`",`\`n                    `\`"media`\`": {`\`n                        `\`"media_type`\`": `\`"image`\`",`\`n                        `\`"media_url`\`": `\`"https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg`\`"`\`n                    },`\`n                    `\`"body_parameter_values`\`": {`\`n                        `\`"0`\`": `\`"first_parameter_in_your_template`\`",`\`n                        `\`"1`\`": `\`"second_parameter_in_your_template`\`"`\`n                    }`\`n                }`\`n            },`\`n            `\`"recipients`\`": [`\`n                {`\`n                    `\`"recipient`\`": [`\`n                        `\`"{{recipient1}}`\`",`\`n                        `\`"{{recipient2}}`\`"`\`n                    ]`\`n                }`\`n            ],`\`n            `\`"report_url`\`": `\`"https://the_url_to_recieve_delivery_report.com`\`"`\`n        }`\`n    ]`\`n}"

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

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

client.whatsapp.send_whatsapp_templated_message(
    originator='{originator}', 
    recipient='{recipient}',
    template_id="{template_id}", 
    language="en",
    body_parameter_values=nil,
    media_type="image",
    text_header_title=nil,
    media_url='https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg'
)
1
2
3
4
5
6
7
8
9
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.d7networks.com/whatsapp/v2/send");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer {{api_access_token}}");
var content = new StringContent("{\n    \"messages\": [\n        {\n            \"originator\": \"{{originator}}\",\n            \"content\": {\n                \"message_type\": \"TEMPLATE\",\n                \"media_template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"media\": {\n                        \"media_type\": \"image\",\n                        \"media_url\": \"https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg\"\n                    },\n                    \"body_parameter_values\": {\n                        \"0\": \"first_parameter_in_your_template\",\n                        \"1\": \"second_parameter_in_your_template\"\n                    }\n                }\n            },\n            \"recipients\": [\n                {\n                    \"recipient\": [\n                        \"{{recipient1}}\",\n                        \"{{recipient2}}\"\n                    ]\n                }\n            ],\n            \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n        }\n    ]\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
curl --location --request POST 'https://api.d7networks.com/whatsapp/v2/send' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {{api_access_token}}' \
--data-raw '{
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}",
            "language" : "en",
            "media":{
                    "media_type": "video",
                    "media_url": "https://www.luckyshrub.com/assets/lucky-shrub-eclipse-viewing.mp4"
                },
            "body_parameter_values": {
                "0": "first_parameter_in_your_template",
                "1": "second_parameter_in_your_template"
            }
        }
    },
    "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}", recipient : "{recipient}",
            template_id : "{{template_id}}", language:"en", body_parameter_values : {"0": "first_parameter_in_your_template", "1": "second_parameter_in_your_template"}, media_type : "video",
            media_url : "http://www.onirikal.com/videos/mp4/nestlegold.mp4"
        });

console.log(response);
pip install direct7
1
2
3
4
5
from direct7 import Client

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

client.whatsapp.send_whatsapp_templated_message(originator="{{originator}}", recipient="{{recipient}}", language="en", template_id="{{template_id}}", body_parameter_values={"0": "first_parameter_in_your_template", "1": "second_parameter_in_your_template"}, media_type="video", media_url="http://www.onirikal.com/videos/mp4/nestlegold.mp4")

composer require direct7/direct7-php
require_once 'vendor/autoload.php';
require_once __DIR__ . '/vendor/autoload.php';

use direct7\Direct7\Client;

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

$body_parameter_values = ["0" => 'first_parameter_in_your_template', "1" => 'second_parameter_in_your_template'];

$response = $direct7->whatsapp->sendWhatsAppTemplatedMessage(
    originator: '{originator}',
    recipient: '{recipient}',
    language: 'en',
    template_id: 'video',
    media_type: 'video',
    media_url: 'https://www.luckyshrub.com/assets/lucky-shrub-eclipse-viewing.mp4',
    body_parameter_values: $body_parameter_values,
);

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 := "video"
language := "en"
optParams := &OptionalParams{mediaType: "video", mediaURL: "http://www.onirikal.com/videos/mp4/nestlegold.mp4"}
response, err := client.whatsapp.SendWhatsAppTemplatedMessage(originator, recipient, templateId, language, 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                \"message_type\": \"TEMPLATE\",\n                \"media_template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"media\": {\n                        \"media_type\": \"video\",\n                        \"media_url\": \"https://www.luckyshrub.com/assets/lucky-shrub-eclipse-viewing.mp4\"\n                    },\n                    \"body_parameter_values\": {\n                        \"0\": \"first_parameter_in_your_template\",\n                        \"1\": \"second_parameter_in_your_template\"\n                    }\n                }\n            },\n            \"recipients\": [\n                {\n                    \"recipient\": [\n                        \"{{recipient1}}\",\n                        \"{{recipient2}}\"\n                    ]\n                }\n            ],\n            \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\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("Accept", "application/json")
.addHeader("Authorization", "Bearer {{api_access_token}}")
.build();
Response response = client.newCall(request).execute();
var headers = {
'Content-Type': 'application/json',
'Accept': '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}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}", 
            "language" : "en",
            "media":{
                    "media_type": "video",
                    "media_url": "https://www.luckyshrub.com/assets/lucky-shrub-eclipse-viewing.mp4"
                }
            "body_parameter_values": {
                "0": "first_parameter_in_your_template",
                "1": "second_parameter_in_your_template"
            }
        }
    },
    "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);
}
1
2
3
4
5
6
7
8
9
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("Accept", "application/json")
$headers.Add("Authorization", "Bearer {{api_access_token}}")

$body = "{`\`n    `\`"messages`\`": [`\`n        {`\`n            `\`"originator`\`": `\`"{{originator}}`\`",`\`n            `\`"content`\`": {`\`n                `\`"message_type`\`": `\`"TEMPLATE`\`",`\`n                `\`"media_template`\`": {`\`n                    `\`"template_id`\`": `\`"{{template_id}}`\`",`\`n                    `\`"media`\`": {`\`n                        `\`"media_type`\`": `\`"video`\`",`\`n                        `\`"media_url`\`": `\`"https://www.luckyshrub.com/assets/lucky-shrub-eclipse-viewing.mp4`\`"`\`n                    },`\`n                    `\`"body_parameter_values`\`": {`\`n                        `\`"0`\`": `\`"first_parameter_in_your_template`\`",`\`n                        `\`"1`\`": `\`"second_parameter_in_your_template`\`"`\`n                    }`\`n                }`\`n            },`\`n            `\`"recipients`\`": [`\`n                {`\`n                    `\`"recipient`\`": [`\`n                        `\`"{{recipient1}}`\`",`\`n                        `\`"{{recipient2}}`\`"`\`n                    ]`\`n                }`\`n            ],`\`n            `\`"report_url`\`": `\`"https://the_url_to_recieve_delivery_report.com`\`"`\`n        }`\`n    ]`\`n}"

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

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

client.whatsapp.send_whatsapp_templated_message(
    originator='{originator}', 
    recipient='{recipient}',
    template_id="{template_id}", 
    language="en",
    body_parameter_values=nil,
    media_type="video",
    text_header_title=nil,
    media_url='http://www.onirikal.com/videos/mp4/nestlegold.mp4'
)
1
2
3
4
5
6
7
8
9
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.d7networks.com/whatsapp/v2/send");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer {{api_access_token}}");
var content = new StringContent("{\n    \"messages\": [\n        {\n            \"originator\": \"{{originator}}\",\n            \"content\": {\n                \"message_type\": \"TEMPLATE\",\n                \"media_template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"media\": {\n                        \"media_type\": \"video\",\n                        \"media_url\": \"https://www.luckyshrub.com/assets/lucky-shrub-eclipse-viewing.mp4\"\n                    },\n                    \"body_parameter_values\": {\n                        \"0\": \"first_parameter_in_your_template\",\n                        \"1\": \"second_parameter_in_your_template\"\n                    }\n                }\n            },\n            \"recipients\": [\n                {\n                    \"recipient\": [\n                        \"{{recipient1}}\",\n                        \"{{recipient2}}\"\n                    ]\n                }\n            ],\n            \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n        }\n    ]\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
curl --location --request POST 'https://api.d7networks.com/whatsapp/v2/send' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {{api_access_token}}' \
--data-raw '{
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}",
            "language" : "en",
            "media":{
                    "media_type": "document",
                    "media_url": "https://www.luckyshrub.com/invoices/FmOzfD9cKf/lucky-shrub-invoice.pdf"
                },
            "body_parameter_values": {
                "0": "first_parameter_in_your_template",
                "1": "second_parameter_in_your_template"
            }
        }
    },
    "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}", recipient : "{recipient}",
            template_id : "{{template_id}}", language: "en", body_parameter_values : {"0": "first_parameter_in_your_template"}, media_type : "document",  media_url: "https://www.clickdimensions.com/links/TestPDFfile.pdf"
        });

console.log(response);
pip install direct7
1
2
3
4
5
from direct7 import Client

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

client.whatsapp.send_whatsapp_templated_message(originator="{originator}", recipient="{recipient}", language="en", template_id="{{template_id}}", body_parameter_values={"0": "first_parameter_in_your_template", "1": "second_parameter_in_your_template"}, media_type="document", media_url="https://www.clickdimensions.com/links/TestPDFfile.pdf")

composer require direct7/direct7-php
require_once 'vendor/autoload.php';
require_once __DIR__ . '/vendor/autoload.php';

use direct7\Direct7\Client;

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

$body_parameter_values = ["0" => 'first_parameter_in_your_template'];

$response = $direct7->whatsapp->sendWhatsAppTemplatedMessage(
    originator: '{originator}',
    recipient: '{recipient}',
    language: 'en',
    template_id: '{template_id}',
    body_parameter_values: $body_parameter_values,
    media_type: 'document',
    media_url: 'https://www.clickdimensions.com/links/TestPDFfile.pdf'
);

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 := "document"
language := "en"
optParams := &OptionalParams{
    bodyParameterValues: map[string]interface{}{ "0": "Anu", },
    mediaType: "document", 
    mediaURL: "https://www.clickdimensions.com/links/TestPDFfile.pdf"}
response, err := client.whatsapp.SendWhatsAppTemplatedMessage(originator, recipient, templateId, language, 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                \"message_type\": \"TEMPLATE\",\n                \"media_template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"media\": {\n                        \"media_type\": \"document\",\n                        \"media_url\": \"https://www.luckyshrub.com/invoices/FmOzfD9cKf/lucky-shrub-invoice.pdf\"\n                    },\n                    \"body_parameter_values\": {\n                        \"0\": \"first_parameter_in_your_template\",\n                        \"1\": \"second_parameter_in_your_template\"\n                    }\n                }\n            },\n            \"recipients\": [\n                {\n                    \"recipient\": [\n                        \"{{recipient1}}\",\n                        \"{{recipient2}}\"\n                    ]\n                }\n            ],\n            \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\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("Accept", "application/json")
.addHeader("Authorization", "Bearer {{api_access_token}}")
.build();
Response response = client.newCall(request).execute();
var headers = {
'Content-Type': 'application/json',
'Accept': '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}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}", 
            "language" : "en",
            "media":{
                    "media_type": "document",
                    "media_url": "https://www.luckyshrub.com/invoices/FmOzfD9cKf/lucky-shrub-invoice.pdf"
                }
            "body_parameter_values": {
                "0": "first_parameter_in_your_template",
                "1": "second_parameter_in_your_template"
            }
        }
    },
    "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);
}
1
2
3
4
5
6
7
8
9
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("Accept", "application/json")
$headers.Add("Authorization", "Bearer {{api_access_token}}")

$body = "{`\`n    `\`"messages`\`": [`\`n        {`\`n            `\`"originator`\`": `\`"{{originator}}`\`",`\`n            `\`"content`\`": {`\`n                `\`"message_type`\`": `\`"TEMPLATE`\`",`\`n                `\`"media_template`\`": {`\`n                    `\`"template_id`\`": `\`"{{template_id}}`\`",`\`n                    `\`"media`\`": {`\`n                        `\`"media_type`\`": `\`"document`\`",`\`n                        `\`"media_url`\`": `\`"https://www.luckyshrub.com/invoices/FmOzfD9cKf/lucky-shrub-invoice.pdf`\`"`\`n                    },`\`n                    `\`"body_parameter_values`\`": {`\`n                        `\`"0`\`": `\`"first_parameter_in_your_template`\`",`\`n                        `\`"1`\`": `\`"second_parameter_in_your_template`\`"`\`n                    }`\`n                }`\`n            },`\`n            `\`"recipients`\`": [`\`n                {`\`n                    `\`"recipient`\`": [`\`n                        `\`"{{recipient1}}`\`",`\`n                        `\`"{{recipient2}}`\`"`\`n                    ]`\`n                }`\`n            ],`\`n            `\`"report_url`\`": `\`"https://the_url_to_recieve_delivery_report.com`\`"`\`n        }`\`n    ]`\`n}"

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

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

client.whatsapp.send_whatsapp_templated_message(
    originator='{originator}', 
    recipient='{recipient}',
    template_id="{template_id}", 
    language="en",
    body_parameter_values={"0": "first_parameter_in_your_template"},
    media_type="document",
    text_header_title=nil,
    media_url='https://www.clickdimensions.com/links/TestPDFfile.pdf'
)
1
2
3
4
5
6
7
8
9
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.d7networks.com/whatsapp/v2/send");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer {{api_access_token}}");
var content = new StringContent("{\n    \"messages\": [\n        {\n            \"originator\": \"{{originator}}\",\n            \"content\": {\n                \"message_type\": \"TEMPLATE\",\n                \"media_template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"media\": {\n                        \"media_type\": \"document\",\n                        \"media_url\": \"https://www.luckyshrub.com/invoices/FmOzfD9cKf/lucky-shrub-invoice.pdf\"\n                    },\n                    \"body_parameter_values\": {\n                        \"0\": \"first_parameter_in_your_template\",\n                        \"1\": \"second_parameter_in_your_template\"\n                    }\n                }\n            },\n            \"recipients\": [\n                {\n                    \"recipient\": [\n                        \"{{recipient1}}\",\n                        \"{{recipient2}}\"\n                    ]\n                }\n            ],\n            \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n        }\n    ]\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
curl --location --request POST 'https://api.d7networks.com/whatsapp/v2/send' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {{api_access_token}}' \
--data-raw '{
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}",
            "language" : "en",
            "media":{
                    "media_type": "location",
                    "location": {
                        "latitude": "12.93803129081362",
                        "longitude": "77.61088653615994",
                        "name": "ABC Mobile Pvt Ltd",
                        "address": "30, Hosur Rd, 7th Block, Koramangala, Bengaluru, Karnataka 560095"
                    }
                },
            "body_parameter_values": {
                "0": "first_parameter_in_your_template",
                "1": "second_parameter_in_your_template"
            }
        }
    },
    "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}", recipient : "{recipient}",
            template_id : "{{template_id}}",  language: "en", body_parameter_values : {"0": "first_parameter_in_your_template", "1": "second_parameter_in_your_template"}, media_type : "location",
            latitude : "12.93803129081362", longitude : "77.61088653615994", name : "Mobile Pvt Ltd", address : "Bengaluru, Karnataka 560095"
        });

console.log(response);
pip install direct7
1
2
3
4
5
from direct7 import Client

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

client.whatsapp.send_whatsapp_templated_message(originator="{{originator}}", recipient="{{originator}}", language="en", template_id="{{template_id}}", body_parameter_values={"0": "first_parameter_in_your_template", "1": "second_parameter_in_your_template"}, media_type="location", latitude="12.93803129081362", longitude="77.61088653615994", name="Mobile Pvt Ltd", address="Bengaluru, Karnataka 560095")

composer require direct7/direct7-php
require_once 'vendor/autoload.php';
require_once __DIR__ . '/vendor/autoload.php';

use direct7\Direct7\Client;

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

$body_parameter_values = ["0" => 'first_parameter_in_your_template', "1" => 'second_parameter_in_your_template'];

$response = $direct7->whatsapp->sendWhatsAppTemplatedMessage(
    originator: '{originator}',
    recipient: '{recipient}',
    language: 'en',
    template_id: '{template_id}',
    body_parameter_values: $body_parameter_values,
    media_type: 'location',
    latitude: '12.93803129081362',
    longitude: '77.61088653615994',
    name: 'Mobile Pvt Ltd', 
    address: 'Bengaluru, Karnataka 560095'
);

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 := "location"
language := "en"
optParams := &OptionalParams{
    mediaType: "location", 
    latitude : "12.93803129081362", 
    longitude : "77.61088653615994",
    name : "Mobile Pvt Ltd", 
    address : "Bengaluru, Karnataka 560095",
}
response, err := client.whatsapp.SendWhatsAppTemplatedMessage(originator, recipient, templateId, language, optParams)

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            \"recipients\": [\"{{recipient1}}\",\"{{recipient2}}\"],\n            \"content\": {\n                \"message_type\": \"TEMPLATE\",\n                \"template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"media\": {\n                        \"media_type\": \"location\",\n                        \"location\": {\n                            \"latitude\": \"12.93803129081362\",\n                            \"longitude\": \"77.61088653615994\",\n                            \"name\": \"ABC Mobile Pvt Ltd\",\n                            \"address\": \"Bengaluru, Karnataka 560095\"\n                        }\n                    },\n                    \"body_parameter_values\": {\n                        \"0\": \"first_parameter_in_your_template\",\n                        \"1\": \"second_parameter_in_your_template\"\n                    }\n                }\n            },\n            \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\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("Accept", "application/json")
.addHeader("Authorization", "Bearer {{api_access_token}}")
.build();
Response response = client.newCall(request).execute();
var headers = {
'Content-Type': 'application/json',
'Accept': '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}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}", 
            "language" : "en",
            "media":{
                    "media_type": "location",
                    "location": {
                        "latitude": "12.93803129081362",
                        "longitude": "77.61088653615994",
                        "name": "ABC Mobile Pvt Ltd",
                        "address": "Bengaluru, Karnataka 560095"
                    }
                }
            "body_parameter_values": {
                "0": "first_parameter_in_your_template",
                "1": "second_parameter_in_your_template"
            }
        }
    },
    "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);
}
1
2
3
4
5
6
7
8
9
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("Accept", "application/json")
$headers.Add("Authorization", "Bearer {{api_access_token}}")

$body = "{`\`n    `\`"messages`\`": [`\`n        {`\`n            `\`"originator`\`": `\`"{{originator}}`\`",`\`n            `\`"content`\`": {`\`n                `\`"message_type`\`": `\`"TEMPLATE`\`",`\`n                `\`"media_template`\`": {`\`n                    `\`"template_id`\`": `\`"{{template_id}}`\`",`\`n                    `\`"media`\`": {`\`n                        `\`"media_type`\`": `\`"image`\`",`\`n                        `\`"media_url`\`": `\`"https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg`\`"`\`n                    },`\`n                    `\`"body_parameter_values`\`": {`\`n                        `\`"0`\`": `\`"first_parameter_in_your_template`\`",`\`n                        `\`"1`\`": `\`"second_parameter_in_your_template`\`"`\`n                    }`\`n                }`\`n            },`\`n            `\`"recipients`\`": [`\`n                {`\`n                    `\`"recipient`\`": [`\`n                        `\`"{{recipient1}}`\`",`\`n                        `\`"{{recipient2}}`\`"`\`n                    ]`\`n                }`\`n            ],`\`n            `\`"report_url`\`": `\`"https://the_url_to_recieve_delivery_report.com`\`"`\`n        }`\`n    ]`\`n}"

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

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

client.whatsapp.send_whatsapp_templated_message(
        originator='{originator}', 
        originator='{originator}',
        template_id='{template_id}', 
        language='en',
        body_parameter_values={"0": "first_parameter_in_your_template", "1": "second_parameter_in_your_template"},
        media_type='location',
        text_header_title=nil, media_url=nil,
        latitude='12.93803129081362',
        longitude='77.61088653615994',
        name='Mobile Pvt Ltd',
        address='30, Hosur Rd, 7th Block, Koramangala, Bengaluru, Karnataka 560095'
)
1
2
3
4
5
6
7
8
9
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.d7networks.com/whatsapp/v2/send");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer {{api_access_token}}");
var content = new StringContent("{\n    \"messages\": [\n        {\n            \"originator\": \"{{originator}}\",\n            \"recipients\": [\"{{recipient1}}\",\"{{recipient2}}\"],\n            \"content\": {\n                \"message_type\": \"TEMPLATE\",\n                \"template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"media\": {\n                        \"media_type\": \"location\",\n                        \"location\": {\n                            \"latitude\": \"12.93803129081362\",\n                            \"longitude\": \"77.61088653615994\",\n                            \"name\": \"ABC Mobile Pvt Ltd\",\n                            \"address\": \"Bengaluru, Karnataka 560095\"\n                        }\n                    },\n                    \"body_parameter_values\": {\n                        \"0\": \"first_parameter_in_your_template\",\n                        \"1\": \"second_parameter_in_your_template\"\n                    }\n                }\n            },\n            \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n        }\n    ]\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());

3. Template with media and buttons

curl --location --request POST 'https://api.d7networks.com/whatsapp/v2/send' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {{api_access_token}}' \
--data-raw '{
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}",
            "language" : "en",
            "media":{
                    "media_type": "image",
                    "media_url": "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
            },
            "body_parameter_values": {
                "0": "first_parameter_in_your_template",
                "1": "second_parameter_in_your_template"
            },
            "buttons": {
                    "quick_replies": [
                        {
                            "button_index": "0",
                            "button_payload": "ButtonText"
                        },
                        {
                            "button_index": "1",
                            "button_payload": "ButtonText"
                        }
                    ]
            }
        }
    },
    "report_url": "https://the_url_to_recieve_delivery_report.com"
    }
]
}'
```bash
npm i direct7
const Client = require('direct7')

const client = new Client(apiToken="Your API token")
const quick_replies = [
                        {
                            "button_index": "0",
                            "button_payload": "ButtonText"
                        }
                    ]

const response = await client.whatsapp.sendWhatsAppTemplatedMessage({
            originator : "{originator}",
            recipient : "{recipient}",
            template_id : "{{template_id}}",
            language: "en",
            body_parameter_values : {"0": "first_parameter_in_your_template", "1": "second_parameter_in_your_template"}, quick_replies: quick_replies});

console.log(response);
pip install direct7
from direct7 import Client

client = Client(api_token="Your API token")
quick_replies = [
                  {
                      "button_index": "0",
                      "button_payload": "ButtonText"
                  }
                ]

client.whatsapp.send_whatsapp_templated_message(originator="{{originator}}", recipient="{{recipient}}", language="en", template_id="quick_reply", body_parameter_values={"0": "first_parameter_in_your_template", "1":  "second_parameter_in_your_template"}, quick_replies=quick_replies)
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");
$quick_replies = [
                    [
                        "button_index" => "0",
                        "button_payload" => "ButtonText"
                    ]
                ];  
$body_parameter_values = ["0" => 'first_parameter_in_your_template', "1" => 'second_parameter_in_your_template'];

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

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 := "quick_reply"
    language := "en"
    quickReplies := []map[string]interface{}{
        {
            "button_index": "0",
            "button_payload": "1",
        },
        {
            "button_index": "1",
            "button_payload": "2",
        },
    }
    optParams := &OptionalParams{
        quickReplies: quickReplies,
    }
    response, err := client.whatsapp.SendWhatsAppTemplatedMessage(originator, recipient, templateId, language, 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                \"message_type\": \"TEMPLATE\",\n                \"media_template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"media\": {\n                        \"media_type\": \"image\",\n                        \"media_url\": \"https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg\"\n                    },\n                    \"body_parameter_values\": {\n                        \"0\": \"first_parameter_in_your_template\",\n                        \"1\": \"second_parameter_in_your_template\"\n                    },\n                    \"buttons\": {\n                        \"quick_replies\": [\n                            {\n                                \"button_index\": \"0\",\n                                \"button_payload\": \"ButtonText\"\n                            },\n                            {\n                                \"button_index\": \"1\",\n                                \"button_payload\": \"ButtonText\"\n                            }\n                        ]\n                    }\n                }\n            },\n            \"recipients\": [\n                {\n                    \"recipient\": [\n                        \"{{recipient1}}\",\n                        \"{{recipient2}}\"\n                    ]\n                }\n            ],\n            \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\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("Accept", "application/json")
.addHeader("Authorization", "Bearer {{api_access_token}}")
.build();
Response response = client.newCall(request).execute();
var headers = {
'Content-Type': 'application/json',
'Accept': '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}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}", 
            "language" : "en",
            "media":{
                    "media_type": "image",
                    "media_url": "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
            },
            "body_parameter_values": {
                "0": "first_parameter_in_your_template",
                "1": "second_parameter_in_your_template"
            },
            "buttons": {
                    "quick_replies": [
                        {
                            "button_index": "0",
                            "button_payload": "ButtonText"
                        },
                        {
                            "button_index": "1",
                            "button_payload": "ButtonText"
                        }
                    ]
            }
        }
    },
    "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);
}
1
2
3
4
5
6
7
8
9
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("Accept", "application/json")
$headers.Add("Authorization", "Bearer {{api_access_token}}")

$body = "{`n    `"messages`": [`n        {`n            `"originator`": `"{{originator}}`",`n            `"content`": {`n                `"message_type`": `"TEMPLATE`",`n                `"media_template`": {`n                    `"template_id`": `"{{template_id}}`",`n                    `"media`": {`n                        `"media_type`": `"image`",`n                        `"media_url`": `"https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg`"`n                    },`n                    `"body_parameter_values`": {`n                        `"0`": `"first_parameter_in_your_template`",`n                        `"1`": `"second_parameter_in_your_template`"`n                    },`n                    `"buttons`": {`n                        `"quick_replies`": [`n                            {`n                                `"button_index`": `"0`",`n                                `"button_payload`": `"ButtonText`"`n                            },`n                            {`n                                `"button_index`": `"1`",`n                                `"button_payload`": `"ButtonText`"`n                            }`n                        ]`n                    }`n                }`n            },`n            `"recipients`": [`n                {`n                    `"recipient`": [`n                        `"{{recipient1}}`",`n                        `"{{recipient2}}`"`n                    ]`n                }`n            ],`n            `"report_url`": `"https://the_url_to_recieve_delivery_report.com`"`n        }`n    ]`n}"

$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')
quick_replies = [
    {
        "button_index" => "0",
        "button_payload" => "1"
    },
    {
        "button_index" => "1",
        "button_payload" => "2"
    }
]
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=quick_replies
)
1
2
3
4
5
6
7
8
9
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.d7networks.com/whatsapp/v2/send");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer {{api_access_token}}");
var content = new StringContent("{\n    \"messages\": [\n        {\n            \"originator\": \"{{originator}}\",\n            \"content\": {\n                \"message_type\": \"TEMPLATE\",\n                \"media_template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"media\": {\n                        \"media_type\": \"image\",\n                        \"media_url\": \"https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg\"\n                    },\n                    \"body_parameter_values\": {\n                        \"0\": \"first_parameter_in_your_template\",\n                        \"1\": \"second_parameter_in_your_template\"\n                    },\n                    \"buttons\": {\n                        \"quick_replies\": [\n                            {\n                                \"button_index\": \"0\",\n                                \"button_payload\": \"ButtonText\"\n                            },\n                            {\n                                \"button_index\": \"1\",\n                                \"button_payload\": \"ButtonText\"\n                            }\n                        ]\n                    }\n                }\n            },\n            \"recipients\": [\n                {\n                    \"recipient\": [\n                        \"{{recipient1}}\",\n                        \"{{recipient2}}\"\n                    ]\n                }\n            ],\n            \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n        }\n    ]\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
curl --location --request POST 'https://api.d7networks.com/whatsapp/v2/send' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {{api_access_token}}' \
--data-raw '{
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}",
            "language" : "en",
            "media":{
                    "media_type": "image",
                    "media_url": "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
            },
            "body_parameter_values": {
                "0": "first_parameter_in_your_template",
                "1": "second_parameter_in_your_template"
            },
            "buttons": {
                    "actions": [
                    {
                        "action_index": "0",
                        "action_type": "URL",
                        "action_payload": "invoice/2345345345"
                    }
                ]
            }
        }
    },
    "report_url": "https://the_url_to_recieve_delivery_report.com"
    }
]
}'
```bash
npm i direct7
const Client = require('direct7')

const client = new Client(apiToken="Your API token")
const actions = [
    {
        "action_type": "url",
        "action_index": "0",
        "action_payload": "ButtonText"
    }
]

const response = await client.whatsapp.sendWhatsAppTemplatedMessage({
            originator : "{originator}",
            recipient : "{recipient}",
            template_id : "{{template_id}}",
            language: "en",
            body_parameter_values : {"0": "first_parameter_in_your_template", "1": "second_parameter_in_your_template"}, actions: actions});

console.log(response);
pip install direct7
from direct7 import Client

client = Client(api_token="Your API token")
actions = [
    {
        "action_type": "url",
        "action_index": "0",
        "action_payload": "ButtonText"
    }
]

client.whatsapp.send_whatsapp_templated_message(originator="{{originator}}", recipient="{{recipient}}",
                                                language="en", template_id="{{template_id}}",
                                                body_parameter_values={ "0": "first_parameter_in_your_template", "1": "second_parameter_in_your_template"}, actions=actions)
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");
$body_parameter_values = ["0" => 'first_parameter_in_your_template', "1" => 'second_parameter_in_your_template'];
$actions = [
    [
        "action_type" => "url",
        "action_index" => "0",
        "action_payload" => "dashboard"
    ]
];  

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

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 := "call_to_action"
    language := "en"
    actions := []map[string]interface{}{
        {
            "action_type": "url",
            "action_index": "0",
            "action_payload": "dash",
        },
    }
    optParams := &OptionalParams{
        actions: actions,
    }
    response, err := client.whatsapp.SendWhatsAppTemplatedMessage(originator, recipient, templateId, language, 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            \"recipients\": [\"{{recipient1}}\",\"{{recipient2}}\"],\n            \"content\": {\n                \"message_type\": \"TEMPLATE\",\n                \"template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"media\": {\n                        \"media_type\": \"image\",\n                        \"media_url\": \"https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg\"\n                    },\n                    \"body_parameter_values\": {\n                        \"0\": \"first_parameter_in_your_template\",\n                        \"1\": \"second_parameter_in_your_template\"\n                    },\n                    \"buttons\": {\n                        \"actions\": [\n                            {\n                                \"action_index\": \"0\",\n                                \"action_type\": \"URL\",\n                                \"action_payload\": \"invoice/2345345345\"\n                            }\n                        ]\n                    }\n                }\n            },\n            \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\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("Accept", "application/json")
.addHeader("Authorization", "Bearer {{api_access_token}}")
.build();
Response response = client.newCall(request).execute();
var headers = {
'Content-Type': 'application/json',
'Accept': '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}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}", 
            "language" : "en",
            "media":{
                    "media_type": "image",
                    "media_url": "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
            },
            "body_parameter_values": {
                "0": "first_parameter_in_your_template",
                "1": "second_parameter_in_your_template"
            },
            "buttons": {
                    "actions": [
                    {
                        "action_index": "0",
                        "action_type": "URL",
                        "action_payload": "invoice/2345345345"
                    }
                ]
            }
        }
    },
    "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);
}
1
2
3
4
5
6
7
8
9
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("Accept", "application/json")
$headers.Add("Authorization", "Bearer {{api_access_token}}")

$body = "{`n    `"messages`": [`n        {`n            `"originator`": `"{{originator}}`",`n            `"content`": {`n                `"message_type`": `"TEMPLATE`",`n                `"media_template`": {`n                    `"template_id`": `"{{template_id}}`",`n                    `"media`": {`n                        `"media_type`": `"image`",`n                        `"media_url`": `"https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg`"`n                    },`n                    `"body_parameter_values`": {`n                        `"0`": `"first_parameter_in_your_template`",`n                        `"1`": `"second_parameter_in_your_template`"`n                    },`n                    `"buttons`": {`n                        `"quick_replies`": [`n                            {`n                                `"button_index`": `"0`",`n                                `"button_payload`": `"ButtonText`"`n                            },`n                            {`n                                `"button_index`": `"1`",`n                                `"button_payload`": `"ButtonText`"`n                            }`n                        ]`n                    }`n                }`n            },`n            `"recipients`": [`n                {`n                    `"recipient`": [`n                        `"{{recipient1}}`",`n                        `"{{recipient2}}`"`n                    ]`n                }`n            ],`n            `"report_url`": `"https://the_url_to_recieve_delivery_report.com`"`n        }`n    ]`n}"

$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')
actions = [
    {
        "action_type" => "url",
        "action_index" => "0",
        "action_payload" => "dash"
    }
]
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=actions
)
1
2
3
4
5
6
7
8
9
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.d7networks.com/whatsapp/v2/send");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer {{api_access_token}}");
var content = new StringContent("{\n    \"messages\": [\n        {\n            \"originator\": \"{{originator}}\",\n            \"recipients\": [\"{{recipient1}}\",\"{{recipient2}}\"],\n            \"content\": {\n                \"message_type\": \"TEMPLATE\",\n                \"template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"media\": {\n                        \"media_type\": \"image\",\n                        \"media_url\": \"https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg\"\n                    },\n                    \"body_parameter_values\": {\n                        \"0\": \"first_parameter_in_your_template\",\n                        \"1\": \"second_parameter_in_your_template\"\n                    },\n                    \"buttons\": {\n                        \"actions\": [\n                            {\n                                \"action_index\": \"0\",\n                                \"action_type\": \"URL\",\n                                \"action_payload\": \"invoice/2345345345\"\n                            }\n                        ]\n                    }\n                }\n            },\n            \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n        }\n    ]\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
curl --location --request POST 'https://api.d7networks.com/whatsapp/v2/send' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {{api_access_token}}' \
--data-raw '{
"messages": [
    {
        "originator": "{{originator}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}",
            "language" : "en",
            "media":{
                    "media_type": "image",
                    "media_url": "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
            },
            "body_parameter_values": {
                "0": "first_parameter_in_your_template",
                "1": "second_parameter_in_your_template"
            },
            "buttons": {
                    "coupon_code": [
                    {
                        "type": "copy_code",
                        "index": "0",
                        "coupon_code": "DF345F45"
                    }
                ]
            }
        }
    },
    "report_url": "https://the_url_to_recieve_delivery_report.com"
    }
]
}'
```bash
npm i direct7
const Client = require('direct7')

const client = new Client(apiToken="Your API token")

const response = await client.whatsapp.sendWhatsAppTemplatedMessage({
            originator : "{originator}",
            recipient : "{recipient}",
            template_id : "{{template_id}}",
            language: "en",
            body_parameter_values : {"0": "first_parameter_in_your_template", "1": "second_parameter_in_your_template"}, coupon_code: "DAS558HG"
            });

console.log(response);
pip install direct7
1
2
3
4
5
from direct7 import Client

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

client.whatsapp.send_whatsapp_templated_message(originator="{{originator}}", recipient="{{recipient}}", language="en", template_id="{{template_id}}", body_parameter_values={"0": "first_parameter_in_your_template", "1": "second_parameter_in_your_template"}, coupon_code="DF345F45")
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");
$body_parameter_values = ["0" => 'first_parameter_in_your_template', "1" => 'second_parameter_in_your_template'];

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

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 := "coupon_code"
    language := "en"
    optParams := &OptionalParams{
        bodyParameterValues: map[string]interface{}{"0": "Anu",},
        couponCode: "DER556"
        }

    response, err := client.whatsapp.SendWhatsAppTemplatedMessage(originator, recipient, templateId, language, 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            \"recipients\": [\n                \"{{recipient1}}\",\n                \"{{recipient2}}\"\n            ],\n            \"content\": {\n                \"message_type\": \"TEMPLATE\",\n                \"template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"media\": {\n                        \"media_type\": \"image\",\n                        \"media_url\": \"https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg\"\n                    },\n                    \"body_parameter_values\": {\n                        \"0\": \"first_parameter_in_your_template\",\n                        \"1\": \"second_parameter_in_your_template\"\n                    },\n                    \"buttons\": {\n                        \"coupon_code\": [\n                            {\n                                \"type\": \"copy_code\",\n                                \"index\": \"0\",\n                                \"coupon_code\": \"DF345F45\"\n                            }\n                        ]\n                    }\n                }\n            },\n            \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\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("Accept", "application/json")
.addHeader("Authorization", "Bearer {{api_access_token}}")
.build();
Response response = client.newCall(request).execute();
var headers = {
'Content-Type': 'application/json',
'Accept': '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}}",
        "recipients": ["{{recipient1}}","{{recipient2}}"],
        "content": {
        "message_type": "TEMPLATE",
        "template": {
            "template_id": "{{template_id}}", 
            "language" : "en",
            "media":{
                    "media_type": "image",
                    "media_url": "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
            },
            "body_parameter_values": {
                "0": "first_parameter_in_your_template",
                "1": "second_parameter_in_your_template"
            },
            "buttons": {
                    "coupon_code": [
                    {
                        "type": "copy_code",
                        "index": "0",
                        "coupon_code": "DF345F45"
                    }
                ]
            }
        }
    },
    "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);
}
1
2
3
4
5
6
7
8
9
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("Accept", "application/json")
$headers.Add("Authorization", "Bearer {{api_access_token}}")

$body = "{`n    `"messages`": [`n        {`n            `"originator`": `"{{originator}}`",`n            `"content`": {`n                `"message_type`": `"TEMPLATE`",`n                `"media_template`": {`n                    `"template_id`": `"{{template_id}}`",`n                    `"media`": {`n                        `"media_type`": `"image`",`n                        `"media_url`": `"https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg`"`n                    },`n                    `"body_parameter_values`": {`n                        `"0`": `"first_parameter_in_your_template`",`n                        `"1`": `"second_parameter_in_your_template`"`n                    },`n                    `"buttons`": {`n                        `"quick_replies`": [`n                            {`n                                `"button_index`": `"0`",`n                                `"button_payload`": `"ButtonText`"`n                            },`n                            {`n                                `"button_index`": `"1`",`n                                `"button_payload`": `"ButtonText`"`n                            }`n                        ]`n                    }`n                }`n            },`n            `"recipients`": [`n                {`n                    `"recipient`": [`n                        `"{{recipient1}}`",`n                        `"{{recipient2}}`"`n                    ]`n                }`n            ],`n            `"report_url`": `"https://the_url_to_recieve_delivery_report.com`"`n        }`n    ]`n}"

$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')

client.whatsapp.send_whatsapp_templated_message(
        originator='{originator}', 
        recipient='{recipient}',
        template_id="{template_id}", 
        language="en",
        body_parameter_values={"0": "first_parameter_in_your_template"}, 
        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="DAS558HG"
)
1
2
3
4
5
6
7
8
9
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.d7networks.com/whatsapp/v2/send");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer {{api_access_token}}");
var content = new StringContent("{\n    \"messages\": [\n        {\n            \"originator\": \"{{originator}}\",\n            \"recipients\": [\n                \"{{recipient1}}\",\n                \"{{recipient2}}\"\n            ],\n            \"content\": {\n                \"message_type\": \"TEMPLATE\",\n                \"template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"media\": {\n                        \"media_type\": \"image\",\n                        \"media_url\": \"https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg\"\n                    },\n                    \"body_parameter_values\": {\n                        \"0\": \"first_parameter_in_your_template\",\n                        \"1\": \"second_parameter_in_your_template\"\n                    },\n                    \"buttons\": {\n                        \"coupon_code\": [\n                            {\n                                \"type\": \"copy_code\",\n                                \"index\": \"0\",\n                                \"coupon_code\": \"DF345F45\"\n                            }\n                        ]\n                    }\n                }\n            },\n            \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n        }\n    ]\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());