Tiledesk Docs
Search…
Webhooks

Introduction

Webhooks are a powerful resource that you can use to automate your use cases and improve your productivity.
Unlike the API resources, which represent static data that you can create, update and retrieve as needed, webhooks represent dynamic resources. You can configure them to automatically notify you when for example a new request occurs.

Use cases

Typical use case for webhook integration is connecting Tiledesk to external CRM, marketing automation tools or data analytics platforms.
Follow this tutorial if you’re developing a Tiledesk integration that reacts to internal Tiledesk events, such as new incoming chat or queued visitor.
For instance if you’re integrating a marketing automation tool, you could add a new contact every time a Tiledesk visitor starts a chat.

Getting started

To use this tool you need to have basic knowledge about webhooks and Tiledesk authorization protocol.
This tutorial is will not be helpful for integration that pulls data on demand (not in reaction to some Tiledesk event). If you just want to pull Tiledesk reports on user request, you’d rather just use REST API.

Prerequisites

You’ll need a Tiledesk Account. Sign up to the Tiledesk Dashboard to create a new account.

RESTHooks

Tiledesk uses RestHook patterns. REST Hooks itself is not a specification, it is a collection of patterns that treat webhooks like subscriptions. These subscriptions are manipulated via a REST API just like any other resource. More info about Rest Hook here.
Tiledesk can send notifications when some particular action is performed. Such a notification is called a webhook – it’s just a simple HTTP request that Tiledesk sends to your server when a particular event occurs.
To use RestHook you can:
  • Create a New Subscription using Dashoboard UI. Go to Settings > Project Settings > Developer (tab) and click on Manage WebHook button.
image
Each Subscription consists of the following properties:
  • event – determines when the webhook is sent to your web server.
  • target – address of your web server the webhook will be sent to.

Webhook format

Each webhook is a HTTP POST request made to the URL that you provide. The request’s POST body contains webhook information in JSON format.
1
{
2
"hook":{
3
"_id":"5c4f1c2e081bde0016cd61d4",
4
"updatedAt":"2019-01-28T15:13:50.807Z",
5
"createdAt":"2019-01-28T15:13:50.807Z",
6
"target":"https://webhook.site/xyzxyz",
7
"event":"request.close",
8
"id_project":"5ad5bd52c975820014ba9234",
9
"createdBy":"5aaa99024c3b110014b478f0",
10
"__v":0
11
},
12
"timestamp":1549035233858,
13
"payload":{
14
"_id":"5c542239721b190016a50538",
15
"request_id":"support-group-LXcdORkb1Kp21ucGNEH",
16
"requester_id":"5beda319507c7500150b1b80",
17
"first_text":"hello",
18
"department":"5b8eb4955ca4d300141fb2cc",
19
"sourcePage":"http://localhost:4200/#/login",
20
"id_project":"5ad5bd52c975820014ba9234",
21
...
22
}
23
}
Copied!
Each webhook request contains the following properties:
  • hook – return the subscription object that triggered the webhook.
  • payload – It contains the data of the webhook.
When your server receives a webhook from Tiledesk, it should respond with HTTP 200 response. Otherwise, Tiledesk will retry sending the webhook to your service for a number of times unless it receives the correct HTTP 200 response.
Note: Tiledesk webhooks are sent with Content-Type: application/json header, so please make sure that your service can handle such requests.

Webhook Models

Webhook events

The following Events are available and you can be notified when an action relating to that event occurs.
Event
Description
Model
request.create
Subscribe to requests creations
Request
request.update
Subscribe to request being updated
Request
request.close
Subscribe to request being closed
Request
message.create
Subscribe to messages creations (sent and receive)
Message
message.create.request.channel.CHANNEL_NAME
Subscribe to messages created (sent and receive) from a specific channel. Ex: message.create.request.channel.telegram for Telegram
Message
lead.create
Subscribes to leads creations
Lead
faq.create
Subscribes to faq creations
Faq
faq.update
Subscribes to faq being updated
Faq
faq.delete
Subscribes to faq being deleted
Faq
faqBot.create
Subscribes to bot creations
Bot
faqBot.update
Subscribes to bot being updated
Bot
faqBot.delete
Subscribes to bot being deleted
Bot
department.create
Subscribes to department creations
department.update
Subscribes to department being updated
department.delete
Subscribes to department being deleted
project_user.invite
Subscribes to teammate project invitation
Team
project_user.update
Subscribes to teammate being updated
Team
project_user.delete
Subscribes to teammate project leave
Team
group.create
Subscribes to group creations
Group
group.update
Subscribes to group being updated
Group

Webhook Notification object

A notification object contains the following fields:
  • Hook attribute
  • Payload attribute

Hook Attribute

Hook attribute contains the subscription object that triggered the webhook.
Attribute
Type
Description
_id
string
The Tiledesk defined id representing the subscription.
createdAt
timestamp
The timestamp the subscription was created.
updatedAt
timestamp
The timestamp the subscription was updated
target
string
The subscription target url
event
string
Corresponds to an event, eg 'lead.create', 'request.create'

Payload

Payload is the data associated with the notification. To understand the payload object you must consider the model column of the Webhook Events table.

Signed Notifications

Each webhook notification is signed by Tiledesk via an x-hook-secret header. We do this so that you can verify the notification came from Tiledesk.