Request transcript on close

With this tutorial we demonstrate how to easily get the request transcript in JSON format using the request's close event. This event is useful if you want to send, for example, a personalized email, or if you want to save the conversation messages on an external system or your own CRM.

Create a new Project

1

Fork the backend

To work with webhooks we'll need a web application endpoint where all the chatbot's requests will be forwarded. We'll use the Replit service to quickly create our own NodeJS web application endpoint.

Start forking the following app: https://replit.com/@tiledesk/webhook-get-transcript-on-close#index.js

2

Create the Tiledesk project

To use Tiledesk APIs or integrate your own chatbots it is mandatory to sign up a new user on Tiledesk: https://tiledesk.com/

Then go to the console: https://panel.tiledesk.com/v3/dashboard

After signup follow the proposed wizard to create your first Tiledesk project. In this tutorial we chose "Transcript project" as Project name.

Project creation screenshot

Once the project is created you'll be redirected to the project home (for this tutorial you can ignore the widget installation step).

Now navigate to Settings > Project Settings > Developer and click on "MANAGE WEBHOOK".

Manage webhook screenshot

Add a new webhook. Make sure the endpoint corresponds to the endpoint of your forked Replit application followed by /webhooks.

Example endpoint used in this tutorial: https://webhook-get-transcript-on-close.tiledesk.repl.co/webhooks

Use your application endpoint so you can modify the code as needed.

Webhook configuration screenshot

Now the webhook is connected to your backend.

Analyzing the backend on Replit

The webhook endpoint is implemented at app.post('/webhooks', ...). The code in the Replit project contains the logic to receive webhook events and to download the transcript when the request is closed.

The code is explained in the following picture:

Code explanation screenshot

Let's run

To run, open your Tiledesk console and choose the "Simulate visitor" button. As soon as you close a request the webhook is invoked and the transcript is downloaded by your backend.

See you in our next tutorial!

If you have suggestions on this article, please send feedback to [email protected]

Last updated 2 years ago