Skip to main content

Webhooks

If you do not want to use the push service of a third party you can set-up a webhook where we will send all the push notifications to. You can use any endpoint you want to receive the notification of, you just need to make sure our servers can access it.

To set this up you will need to share 1 or 2 options with us. The actual endpoint and optionally a static header that we will send with every request. If you need a dynamic authorization header, we currently only support OAuth for that and you will need to send us the information described in OAuth webhooks.

OptionRequiredDescriptionExample
endpointyesThe URL of the endpoint that we will send all push notifications to.https://yourendpoint/foo/bar
header(s)noA JSON value that contains static headers that we will add every time we send something to the endpoint. This can be used if you need us to send a static authorization so that we can reach the endpoint. This is optional because we will sign any notification that we send which is the method you can use to identify real notifications from us.{"Authorization":"Bearer 31217c9ed3fe820104cf3dbf0cf71b9aa3059a4b"}

Send these settings to us via support@parley.nu. If you send us a static authorization header make sure to encrypt it or send a part of it through a second means of communication (a parley conversation, SMS, etc.). We will then setup your Parley account So that you can receive notifications on the webhook.

Make sure that the when you register a device you will set the push type to webhook so that we will use that configuration to send the notification to for those devices.

The notifications you will receive

When the webhook is set-up correctly you will start to receive different types of notifications. I will briefly explain the differences and the fields you are receiving.

New message notification

This notification will be triggered on each new message that is send from the Service

Property nameData typeDescription
dataObjectThe contents of the notification
data.typeStringThis is an enum * message An indicator of the type of notification you receive. The current enum can expand, make sure your code will ignore types it doesn't recognize.
data.objectObjectAn object containing the message or event (depending on the type).
data.object.idIntegerThe id of the message in Parley.
data.object.timeIntegerThe time when the message was send to Parley.
data.object.messageStringCould contain one of these things: * The plain-text message the user send to Parley * A pre-set message which you can configure in the admin.parley.nu environment under Settings -> Push notifications -> generic push message * A photo camera icon (📷) which is set only when the message contains an image.
data.object.imageStringnull
data.object.typeIdIntegerThis is an enum * 2 Message * 3 Info message * 5 System message The type of this message.
data.object.agentObjectnull
data.object.agent.idIntegerThe id of this Agent in Parley.
data.object.agent.nameStringThe name of this Agent in Parley
data.object.agent.avatarStringA url to the avatar for this Agent.
toString[]This will be an array of one or more push tokens that you have register in the POST devices call of the client API. These indicate the different receivers of this notification. For now we only send 1 message per device and this array will always contain 1 push token. In the future we will think about grouping multiple tokens into this array.
{
"data": {
"type": "message",
"object": {
"id": 3651,
"time": 1581687386,
"message": "Hi there",
"image": null,
"typeId": 2,
"agent": {
"id": 1,
"name": "Tracebuzz",
"avatar": "https://beta.tracebuzz.com/V002/img/avatar.php?i=TB&c=f4931d"
}
}
},
"to": [
"0801fc577294c34e0b28ad2839435945"
]
}

New event notification

This notification will be triggered on each new event that is send from the Service

Property nameData typeDescription
dataObjectThe contents of the notification
data.typeStringThis is an enum * event An indicator of the type of notification you receive. The current enum can expand, make sure your code will ignore types it doesn't recognize.
data.objectObjectAn object containing the message or event (depending on the type).
data.object.nameStringThe name of the event that is triggered
data.object.bodyObjectObject containing the information for this specific event. Different events can have different bodies. Currently we only have the startTyping and stopTyping events. (which use the same body)
data.object.body.agentObjectnull
data.object.body.agent.idIntegerThe id of this Agent in Parley.
data.object.body.agent.uidStringThe unique identifier for this Agent in Parley
data.object.body.agent.nameStringThe name of this Agent in Parley
data.object.body.agent.avatarStringA url to the avatar for this Agent.
toString[]This will be an array of one or more push tokens that you have register in the POST devices call of the client API. These indicate the different receivers of this notification.
{
"data": {
"type": "event",
"object": {
"name": "startTyping",
"body": {
"agent": {
"id": 1,
"uid": "-1",
"name": "Tracebuzz",
"avatar": "https://beta.tracebuzz.com/V002/img/avatar.php?i=TB&c=f4931d"
}
}
}
},
"to": [
"0801fc577294c34e0b28ad2839435945"
]
}