Webhook
message_created

Message created

Notifies your endpoint whenever a message is created.

Registering your endpoint

Webhook URLs are registered from the Eclectic dashboard: go to Dev Tools → Event Triggers and create a configuration with the message_created event type and your endpoint URL. You can choose POST or PUT, add custom headers (for example an authorization token so you can verify our calls), and inspect every delivery attempt in the logs on the same page. If you don't have dashboard access, contact the Eclectic team to set it up for you.

Trigger

This webhook is triggered whenever an inbound message is received from a customer, and whenever a message is sent through the API (POST /messages/send). Messages sent manually from the dashboard do not trigger it.

Payload fields

  • toRecipient's channel-specific identifier.
  • fromSender's channel-specific identifier.
  • textMessage content.
  • attachmentsArray of message files.
  • statusEither received or sent.
  • channelPlatform identifier (e.g. whatsapp).
  • contactAssociated contact details.
  • createdAtISO 8601 timestamp.
  • metadataCustom message metadata.

Optional fields are included only for specific message types: messageContactCard, messageContext, messageForward, messageInteractiveList, messageLocation and messageReplyButton.

Example payload

json
{
  "event": "message_created",
  "payload": {
    "to": "331122334455",
    "from": "335544332211",
    "text": "Hello",
    "status": "received",
    "channel": "whatsapp",
    "contact": {
      "href": "https://dash.try-eclectic.com/contacts/eb2b914a977e4ab896e7b886698b3eac",
      "conversationHref": "https://dash.try-eclectic.com/chat/f3670b13446b412796238b1cd78899f9",
      "name": "John Doe",
      "tags": ["Lead"],
      "uuid": "eb2b914a977e4ab896e7b886698b3eac",
      "source": "whatsapp",
      "avatarUrl": null,
      "createdAt": "2022-10-12T15:57:16Z",
      "phoneNumber": "331122334455"
    },
    "createdAt": "2022-10-18T12:06:29.000+02:00"
  }
}