Share Media Content with Message Templates over API
Using WhatsApp and API, send different types of media messages using templates. You can send various types of content such as location, documents, images, and video.
This tutorial explains how to send a message template containing location.
Process Workflow
IMPLEMENTATION STEPS
Before you implement this use case and start using WhatsApp media message templates, the template needs to be approved by WhatsApp. Once your delivery location media message template is approved, you can reuse it and personalize it for each customer who is awaiting their package.
Use the additional placeholders to personalize your message.
To register your template, you must provide a template name, content, and language info. After that, Infobip sends the template over to WhatsApp for approval.
Define the media in the header, in this instance it’s the location, and enter the message content.
Template name | Template header | Template body | Language | Approved |
---|---|---|---|---|
delivery_notification | Media - Location | Order number {{1}} has been delivered to the shipping address seen on the map. Thank you for shopping at Go2Shop �� | en | ✅ |
Steps over API
To send a delivery location notification to a specific customer using API, follow the steps described below.
-
Log in to the Infobip API Developer Hub" (opens in a new tab).
-
Copy your Base URL. It is visible on top of the page below the API Key.
NOTEThe personal BASE URL is a simple way to identify who sent the API request. This means we can identify the request through DNS and then find the optimal route for API requests.
-
Open Postman (or similar tool) and choose the POST method.
-
Replace the endpoint with your Base URL and then add the following to that URL: '' .api.infobip.com/omni/1/advanced''
-
Add the Authorization header.
For example, Basic: Base64 encoded username and password.
Learn more about Security and Authorization methods (opens in a new tab) on the Infobip API Developer Hub.
-
Copy the
scenarioKey
you previously created.Learn more about Creating a scenario.
-
Specify the destination
phoneNumber
you wish to send the notification to.Replace the
templateName
,latitude
,longitude
,placeholders
, andlanguage
fields with registered ones (refer to the table above).json"scenarioKey":"CC9F01A5DC7BEE2C2B829D203482A654", "destinations":[ { "to":{ "phoneNumber":"41793026727" } } ], "whatsApp":{ "templateName":"delivery_notification", "mediaTemplateData": { "header": { "latitude": 45.793337, "longitude": 15.946519 }, "body": { "placeholders": ["51298783"] }}, "language":"en" } }
Here's how the message will look like:
Apart from sharing the delivery location for items and packages, you can create entire digital customer journeys by sending out customers' e-receipts right after they make a purchase, share e-tickets, share boarding passes, and send invoices.