Pingtochat Docs

Pingtochat Docs

Did You Know?

Advanced visual search system powered by Ajax

leafleafleafDocy banner shape 01Docy banner shape 02Man illustrationFlower illustration

Message with parameters, attachments, and with buttons

Estimated reading: 3 minutes 79 views

Description:

Send a basic template message with any parameters.

Endpoint:

http://{{your_domain}}/api/v1.0/{{phone_number_id}}/{{key}}/messages

Replace the placeholders:

  • {{your_domain}}: Your API domain.
  • {{phone_number_id}}: The ID linked to your WhatsApp Business API number.
  • {{key}}: Your API key for authentication.How to create key

Method:

POST

Headers:

  • Content-Type: application/json
  • Authorization: Bearer <your_access_token>

Example :

{
  "messaging_product": "whatsapp",
  "recipient_type": "individual",
  "to": "91xxxxxxxxxx",
  "type": "template",
  "template": {
    "name": "marketing_newyear_va_images",
    "language": {
      "code": "en"
    },
    "components": [
      {
        "type": "body",
        "parameters": [
          {
            "type": "text",
            "text": "User_Name"
          },
          {
            "type": "text",
            "text": "Features"
          }
        ]
      },
      {
        "type": "header",
        "parameters": [
          {
            "type": "image",
            "image": {
              "link": "https://chat.pingtochat.com/template_media/1736424548.png"
            }
          }
        ]
      },
       {
        "type": "FOOTER",
        "text": "Use the buttons below to visit our website"
        },
        {
        "type":"BUTTONS",
        "buttons": [
                {
                "type": "QUICK_REPLY",
                "text": "Unsubscribe from Promos"
                },
                {
                "type": "url",
                "text": "Go to link",
                "url": "https://developers.pingtochat.com/"
                }
               
            ]
        }
    ]
  }
}

Key Points in the Payload

  1. Components:
    • header: Includes an image URL.
    • body: Contains text with placeholders replaced by dynamic values.
    • footer: Simple static text.
    • buttons: Supports two types of buttons:
      • QUICK_REPLY: For quick interactions.
      • URL: Redirects to a specific URL.
  2. Parameters:
    • The parameters inside header and body match the placeholders defined in the template.
  3. URL Requirements:
    • The URL in the buttons section must be publicly accessible.
  4. Template Approval:
    • Templates (e.g., marketing_newyear_va_images) must be pre-approved.

Response

A successful request will return an HTTP status code of 200 OK along with the following response structure:

{
  "messaging_product": "whatsapp",
  "contacts": [
    {
      "input": "91xxxxxxxxxx",
      "wa_id": "91xxxxxxxxxx",
      "status_id": "NTg0MTc="
    }
  ],
  "messages": [
    {
      "id": "M2s4da2y4P",
      "message_status": "accepted"
    }
  ]
}

Field Descriptions

  1. messaging_product:
    • Type: String
    • Description: Indicates the messaging platform. Always returns whatsapp for messages sent via the WhatsApp Business API.
  2. contacts:
    • Type: Array
    • Description: Contains information about the message recipient(s).
    • Fields:
      • input:
        • Type: String
        • Description: The phone number input used in the API request (e.g., 91xxxxxxxxxx).
      • wa_id:
        • Type: String
        • Description: The WhatsApp ID associated with the input phone number.
      • status_id:
        • Type: String
        • Description: A unique identifier for the status of the message.
  3. messages:
    • Type: Array
    • Description: Contains details about the seMessages Without Buttonsnt message.
    • Fields:
      • id:
        • Type: String
        • Description: A unique identifier for the message sent (e.g., M2s4da2y4P).
      • message_status:
        • Type: String
        • Description: The status of the message at the time of the response. Example values include:
          • accepted: The message was successfully accepted by the system.

Sample codes

Leave a Comment

Share this Doc

Message with parameters, attachments, and with buttons

Or copy link

CONTENTS