Send session message

Send a message to recipient on target channel, i.e. WhatsApp, SMS.

If you are trying to send a WhatsApp message and the number you are messaging has not messaged you within the last 24 hours, you will need to send a pre approved template message. See here for details.

24 hour WhatsApp restriction

If the recipient has not initiated the conversation first within the last 24 hours you CAN NOT send the messages to them. In this case, you MUST use templated message API /v1/businesses/{businessId}/send/whatsapp_templated_messages.

  • Generally, you use /v1/businesses/{businessId}/send/messages to reply to the customers who already messaged you first.

  • You use /v1/businesses/{businessId}/send/whatsapp_templated_messages to initiate with the customer first.

Select the WhatsApp number you want to send from

The endpoint supports an optional sender field in the body. If you have multiple WhatsApp phone numbers with Connectly you can choose which one you want to send the message from. The payload needs to contain the optional sender object specifying the phone number in the id section and channelType as whatsapp:

{
  "sender": {
    "id": "+14151111234",
    "channelType": "whatsapp"
  },
  "recipient": {
    "id": "+16044441111",
    "channelType": "whatsapp"
  },
  "message": {
    "text": "Hello, this is a text message!"
  }
}

Send a message with an attachment

You can include an attachment to the message. Currently, only a single attachment is supported.

Image Attachment Message

{
  "sender": {
    "id": "+14151111234",
    "channelType": "whatsapp"
  },
  "recipient": {
    "id": "+16044441111",
    "channelType": "whatsapp"
  },
  "message": {
    "attachments": [
      {
        "type": "image",
        "url": "https://example.com/image.jpg",
        "caption": "Check out this image!"
      }
    ]
  }
}

Video Attachment Message

{
  "sender": {
    "id": "+14151111234",
    "channelType": "whatsapp"
  },
  "recipient": {
    "id": "+16044441111",
    "channelType": "whatsapp"
  },
  "message": {
    "attachments": [
      {
        "type": "video",
        "url": "https://example.com/video.mp4",
        "caption": "Check out this video!"
      }
    ]
  }
}

Audio Attachment Message

{
  "sender": {
    "id": "+14151111234",
    "channelType": "whatsapp"
  },
  "recipient": {
    "id": "+16044441111",
    "channelType": "whatsapp"
  },
  "message": {
    "attachments": [
      {
        "type": "audio",
        "url": "https://example.com/audio.mp3"
      }
    ]
  }
}

Document Attachment Message

{
  "sender": {
    "id": "+14151111234",
    "channelType": "whatsapp"
  },
  "recipient": {
    "id": "+16044441111",
    "channelType": "whatsapp"
  },
  "message": {
    "attachments": [
      {
        "type": "document",
        "url": "https://example.com/document.pdf",
        "caption": "Check out this document!",
        "filename": "document.pdf"
      }
    ]
  }
}

Send location message

{
  "sender": {
    "id": "+14151111234",
    "channelType": "whatsapp"
  },
  "recipient": {
    "id": "+16044441111",
    "channelType": "whatsapp"
  },
  "message": {
    "location": {
      "latitude": 37.7749,
      "longitude": -122.4194,
      "name": "San Francisco",
      "address": "123 Main St"
    }
  }
}

Send interactive list message

Use list_message to send a WhatsApp interactive list message. For more information, see WhatsApp documentation.

{
  "sender": {
    "id": "+14151111234",
    "channelType": "whatsapp"
  },
  "recipient": {
    "id": "+16044441111",
    "channelType": "whatsapp"
  },
  "message": {
    "listMessage": {
      "header": {
        "text": "Check out this list of items!"
      },
      "footer": {
        "text": "Choose an option from the list."
      },
      "button": {
        "text": "Select"
      },
      "sections": [
        {
          "title": "Section 1",
          "rows": [
            {
              "id": "1",
              "text": "Item 1",
              "description": "Description for Item 1"
            },
            {
              "id": "2",
              "text": "Item 2",
              "description": "Description for Item 2"
            }
          ]
        },
        {
          "title": "Section 2",
          "rows": [
            {
              "id": "3",
              "text": "Item 3",
              "description": "Description for Item 3"
            }
          ]
        }
      ]
    }
  }
}

Send interactive reply buttons message

Use reply_button_message to send interactive reply button message. For more information, see WhatsApp documentation.

{
  "sender": {
    "id": "+14151111234",
    "channelType": "whatsapp"
  },
  "recipient": {
    "id": "+16044441111",
    "channelType": "whatsapp"
  },
  "message": {
    "text": "This is a reply button message",
    "replyButtonMessage": {
      "header": {
        "text": "Header"
      },
      "footer": {
        "text": "Footer"
      },
      "buttons": [
        {
          "id": "b1",
          "text": "Button 1"
        },
        {
          "id": "b2",
          "text": "Button 2"
        },
        {
          "id": "b3",
          "text": "Button 3"
        }
      ]
    }
  }
}

Header Media

Both list and quick reply messages use the same header parameter structure. Here is an example of an image header:

"header": {
    "attachment": {
        "type": "image",
        "url": "https://cdn.connectly.ai/26fa/26fa1308-d328-41c9-a6a1-d5f4225a3768",
    }
},

This is an example of a document header with a filename:

"header": {
    "attachment": {
        "type": "document",
        "url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
        "filename": "feeeelsss"
    }
},

Last updated