Pingtochat Docs

Pingtochat Docs

Did You Know?

We design Docy for the readers, optimizing not for page views or engagement

leafleafleafDocy banner shape 01Docy banner shape 02Man illustrationFlower illustration

Session Message

Estimated reading: 2 minutes 325 views

A session message in WhatsApp refers to any message exchanged between a business and a customer within a 24-hour messaging window that starts when the customer sends a message to the business. These messages are not pre-approved by WhatsApp and can include free-form text, media, or interactive content.

URL

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

Method

POST

Headers

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

Request Payloads

Sending a Text Message

The payload for sending a plain text message via the WhatsApp API is structured as follows:

Example :

{
  "messaging_product": "whatsapp",
  "to": "91xxxxxxxxxx",
  "type": "text",
  "text": {
    "body": "Hello!"
  }
}

Field Descriptions

  • messaging_product: (string) Specifies the messaging product. For WhatsApp, this is always whatsapp.
  • to: (string) The recipient’s phone number in E.164 format. Example: 919880132082.
  • type: (string) The type of message being sent. Use text for plain text messages.
  • text: (object) Contains the message text.
    • body: (string) The text message content. Example: "Hello!".

Response

Example Success Response

A successful request returns a 200 OK status and a response payload similar to the following:

{
  "messaging_product": "whatsapp",
  "contacts": [
    {
      "input": "91xxxxxxxxxx",
      "wa_id": "91xxxxxxxxxx"
    }
  ],
  "messages": [
    {
      "id": "RfzuNs4qpN"
    }
  ]
}

Field Descriptions

  • messaging_product: (string) The messaging product used. Always whatsapp.
  • contacts: (array) Contains information about the recipient.
    • input: (string) The phone number you provided in the request.
    • wa_id: (string) The WhatsApp ID associated with the provided phone number.
  • messages: (array) Contains information about the sent message.
    • id: (string) The unique identifier for the sent message.

Notes

  1. Domain and Credentials: Replace {{your_domain}}, {{phone_number_id}}, and {{key}} with your API domain, phone number ID, and API key respectively.
  2. Rate Limits: Ensure your API calls comply with the rate limits set by WhatsApp to avoid being throttled.
  3. Session Window: Text messages can only be sent within a 24-hour window of the last user interaction.
  4. Template Pre-Approval: For template messages, ensure they are approved in the WhatsApp Business Manager before use.
  5. Language Code Matching: Language codes in templates must match the approved template language.

Sample codes

Leave a Comment

Share this Doc

Session Message

Or copy link

CONTENTS