Receiving Events - Webhooks

When new messages come into any of your channels or you want to be notified immediately we have any updates on your conversations, we trigger events that your application can listen to. We do this using webhooks.

A webhook is a URL on your server where we send payloads for such events.

You can specify your webhook URL on your Settings page or on individual channels where we would send POST requests to whenever an event occurs.

Kindly ensure your webhook URL is publicly available (localhost URLs cannot receive events).

Receiving Events

To receive the event, you will have to create an unauthenticated POST route on your application that returns a 200 status code as it's response.

// Using Express
app.post("/my/webhook/url", function(req, res) {
    // Retrieve the request's body
    var event = req.body;
    // Do something with event
    res.send(200);
});

Supported Events

{
  "event": "newMessage",
  "message": {
    "sender": {
      "name": "Message Sender",
      "authUser": false,
      "lastActivity": "2022-01-29T07:27:52.676Z"
    },
    "externalId": null,
    "content": "Hello World!",
    "contentType": "TEXT",
    "imageUrl": null,
    "videoUrl": null,
    "documentUrl": null,
    "audioUrl": null,
    "quoted_message_id": null,
    "conversation_id": "bf9d96d9-e495-489a-a22a-206b0ea44d90"
  },
  "conversation": {
    "id": "bf9d96d9-e495-489a-a22a-206b0ea44d90",
    "subject": null,
    "agent": null,
    "customer": {
      "name": "Customer name",
      "email": "customer@mail.com"
    },
    "lastMessageAt": "2022-01-29T07:27:52.793Z",
    "status": "in-queue",
    "country": "NG",
    "read": false,
    "createdAt": "2022-01-29T07:18:58.172Z",
    "updatedAt": "2022-01-29T07:27:52.794Z",
    "agent_id": null,
    "Channel": {
      "id": "8bad2edc-2973-4cec-8f33-a17c54dc0686",
      "phone": null,
      "identifier": "Identifier",
      "medium": "WHATSAPP",
      "credentials": null,
      "description": "Whatsapp Channel",
      "name": "Channel name",
      "type": "CUSTOM",
      "provider": null,
      "country": "NG",
      "env": "LIVE",
      "status": "ACTIVE",
      "webhookUrl": "https://webhook.url"
    }
  }
}

WhatsApp Campaign Events

{
    "event": "compaignDeliveryReport",
    "message": "campaign completed.",
    "campaignReportUrl": "https://api.oneroute.io/api/public/logs?page[size]=10&page[number]=1&campaign_id=campaign_id"
    "conversation": {
        "id": "id",
        "firm_id": "firm id"
    }
}

Last updated