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 signed download URLs for the message's files. URLs expire after 120 minutes.
  • mediaArray of media objects ({id, url, filename, contentType}) describing the same files with metadata.
  • 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.

Signed media URLs expire 120 minutes after the webhook is generated, and retried deliveries reuse the original payload. Download files promptly, or call GET /media/:id with the media item's id to obtain a fresh URL.

Example payload

json
{
  "event": "message_created",
  "payload": {
    "to": "331122334455",
    "from": "335544332211",
    "text": "Hello",
    "attachments": [
      "https://storage.googleapis.com/eclectic-media/documents/6f9a...c2.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Expires=7200&..."
    ],
    "media": [
      {
        "id": 482,
        "url": "https://storage.googleapis.com/eclectic-media/documents/6f9a...c2.pdf?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Expires=7200&...",
        "filename": "cotizacion.pdf",
        "contentType": "application/pdf"
      }
    ],
    "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"
  }
}