OneRoute
Search…
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.
Node
PHP
1
// Using Express
2
app.post("/my/webhook/url", function(req, res) {
3
// Retrieve the request's body
4
var event = req.body;
5
// Do something with event
6
res.send(200);
7
});
Copied!
1
<?php
2
// Retrieve the request's body and parse it as JSON
3
$input = @file_get_contents("php://input");
4
$event = json_decode($input);
5
// Do something with $event
6
http_response_code(200); // PHP 5.4 or greater
7
?>
Copied!

Supported Events

New Incoming Message
Second Tab
1
{
2
"event": "newMessage",
3
"message": {
4
"sender": {
5
"name": "Message Sender",
6
"authUser": false,
7
"lastActivity": "2022-01-29T07:27:52.676Z"
8
},
9
"externalId": null,
10
"content": "Hello World!",
11
"contentType": "TEXT",
12
"imageUrl": null,
13
"videoUrl": null,
14
"documentUrl": null,
15
"audioUrl": null,
16
"quoted_message_id": null,
17
"conversation_id": "bf9d96d9-e495-489a-a22a-206b0ea44d90"
18
},
19
"conversation": {
20
"id": "bf9d96d9-e495-489a-a22a-206b0ea44d90",
21
"subject": null,
22
"agent": null,
23
"customer": {
24
"name": "Customer name",
25
"email": "[email protected]"
26
},
27
"lastMessageAt": "2022-01-29T07:27:52.793Z",
28
"status": "in-queue",
29
"country": "NG",
30
"read": false,
31
"createdAt": "2022-01-29T07:18:58.172Z",
32
"updatedAt": "2022-01-29T07:27:52.794Z",
33
"agent_id": null,
34
"Channel": {
35
"id": "8bad2edc-2973-4cec-8f33-a17c54dc0686",
36
"phone": null,
37
"identifier": "Identifier",
38
"medium": "WHATSAPP",
39
"credentials": null,
40
"description": "Whatsapp Channel",
41
"name": "Channel name",
42
"type": "CUSTOM",
43
"provider": null,
44
"country": "NG",
45
"env": "LIVE",
46
"status": "ACTIVE",
47
"webhookUrl": "https://webhook.url"
48
}
49
}
50
}
Copied!