Send a WhatsApp Template Message
    • Dark
      Light
    • PDF

    Send a WhatsApp Template Message

    • Dark
      Light
    • PDF

    Article summary

    Post
    /api/apps/public/{appId}/templateMessage

    Use this endpoint to send WhatsApp template messages directly to specified contacts from your workspace.

    1. Navigate to Administration > Apps > Marketplace.
    2. Locate your preferred WhatsApp App.
    3. Go to App Info > Details > APIs and find the POST templateMessage section.
    4. Copy the POST templateMessage endpoint URL for your WhatsApp app from the provided curl example. This URL includes the required appId. 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.

    Path parameters
    appId
    stringRequired



    Body parameters

    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.

    Expand All
    object 
    Example{ "phoneNumbers": [ "2368106035555" ], "connectedWhatsAppNo": "104920685899299", "template": { "name": "ship", "language": { "code": "en", "policy": "deterministic" }, "components": [ { "type": "body", "parameters": [ { "type": "text", "text": "20" } ] } ] } }
    phoneNumbers
    Array of string Required

    Recipient WhatsApp IDs where you want to send the template message. You can validate a WhatsApp id from here.

    string 
    connectedWhatsAppNo
    string Required

    The WhatsApp Number from which you want to send this template message. The WhatsApp number connected to your workspace via the app.

    targetAgent
    string 

    Username of the agent you want to transfer the chat to when the WhatsApp user replies.

    targetDepartment
    string 

    Department name or ID where you want to transfer the chat to when the WhatsApp user replies.

    template
    object Required

    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.

    namespace
    string 
    name
    string 
    language
    object 
    code
    string 
    policy
    string 
    components
    Array of object 
    object 
    type
    string 
    parameters
    Array of object 
    object 
    type
    string 
    text
    string 
    Responses
    200

    OK

    Success
    {
      "success": true
    }
    object 
    success
    boolean 
    400

    Bad Request

    Too many phone numbers
    {
      "success": false,
      "error": "Too many phone numbers! Please make sure that phoneNumbers are <= 250"
    }
    Agent Not Found
    {
      "success": false,
      "error": "No Agent found with username abc98"
    }
    Department Not Found
    {
      "success": false,
      "error": "No Department found with id/Name SalesDepartment"
    }
    Invalid WhatsApp Contact
    {
      "success": false,
      "error": "Connected WhatsApp Number (connectedWhatsAppNo) i.e. 565412001234 is not a valid WhatsApp contact. Contact Status is invalid"
    }
    Invalid Connected WhatsApp Number
    {
      "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."
    }
    object 
    success
    boolean 
    error
    string 
    401

    Unauthorized

    Authorization Error
    {
      "status": "error",
      "message": "You must be logged in to do this."
    }
    object 
    status
    string 
    message
    string 
    403

    Forbidden

    Permission Error
    {
      "success": false,
      "error": "User does not have the permissions required for this action [error-unauthorized]"
    }
    object 
    success
    boolean 
    error
    string 

    Was this article helpful?

    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.