- Print
- DarkLight
- PDF
Send a WhatsApp Template Message
- Print
- DarkLight
- PDF
Use this endpoint to send WhatsApp template messages directly to specified contacts from your workspace.
- Navigate to Administration > Apps > Marketplace.
- Locate your preferred WhatsApp App.
- Go to App Info > Details > APIs and find the
POST templateMessage
section. - Copy the
POST templateMessage
endpoint URL for your WhatsApp app from the provided curl example. This URL includes the requiredappId
. Send a template message request using this URL as the endpoint.
Before sending template messages from Rocket.Chat through any WhatsApp App, ensure that you have set up the templates in respective WhatsApp provider account. Refer to the official guide for details on configuring template messages for each WhatsApp app.
We strongly recommend including the + prefix for all phone numbers in the payload. While you can submit numbers without the leading + sign, we have encountered cases where WhatsApp will return an invalid response despite the number being in use.
Recipient WhatsApp IDs where you want to send the template message. You can validate a WhatsApp id from here.
The WhatsApp Number from which you want to send this template message. The WhatsApp number connected to your workspace via the app.
Username of the agent you want to transfer the chat to when the WhatsApp user replies.
Department name or ID where you want to transfer the chat to when the WhatsApp user replies.
Provide the details of the template message you want to send. The structure of the template object may differ depending on the template defined within your WhatsApp provider account. For further clarification, refer to the official guide on sending template messages via API in Rocket.Chat. The example template object provided here is based on the configuration outlined in the official guide for the WhatsApp Cloud App.
If your template message includes parameters, make sure to replace all of them with the appropriate information before sending. Failure to do so may lead to an error.
OK
{
"success": true
}
Bad Request
{
"success": false,
"error": "Too many phone numbers! Please make sure that phoneNumbers are <= 250"
}
{
"success": false,
"error": "No Agent found with username abc98"
}
{
"success": false,
"error": "No Department found with id/Name SalesDepartment"
}
{
"success": false,
"error": "Connected WhatsApp Number (connectedWhatsAppNo) i.e. 565412001234 is not a valid WhatsApp contact. Contact Status is invalid"
}
{
"success": false,
"error": "Error! Connected WhatsApp Number (connectedWhatsAppNo) i.e. 565412001234 has not been registered yet on Rocket.Chat. Please goto #omnichannel-whatsapp-setup channel and connect this WhatsApp number first there before sending this request again."
}
Unauthorized
{
"status": "error",
"message": "You must be logged in to do this."
}
Forbidden
{
"success": false,
"error": "User does not have the permissions required for this action [error-unauthorized]"
}