Create a customer support chatbot with Zendesk and CSML
Tags: csml, chatbot, bot
Published: 2020-08-10 10:47:17

Customer support is **key** to keep your existing customers, it is **key** to maintain a good reputation, it is **key** to acquire new customers.

A great way to take care of customer support is to work with a ticketing service that takes care of **tracking** the open tickets, helps you **resolve** issues, and provides **notifications**. We, at CSML, use Zendesk, it’s one of the most (if not the most) efficient product on the market, so we decided to make an integration to Zendesk for CSML.
With this CSML integration, your chatbot can create a ticket on Zendesk on the fly. Let’s see how this work.


## The chatbot
The chatbot we’re going to build is an IT support chatbot, so let’s make a chatbot for the serie The [IT Crowd](https://www.google.com/search?q=the+it+crowd). We’ll call this chatbot **RoyBot**.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/mv37bryyxksvc98scf7s.gif)

This is Roy, asking the same question over and over again 👨‍💻
The goal of this chatbot is:
- to handle all incoming support requests
- ask the question that Roy asks 100% of the time: “Have you tried turning it off and on again?”
Asking this question over 50% of the IT support enquiries.
- create a ticket on Zendesk if the user has already restarted his computer.
Note that this chatbot will be coded with [CSML](https://www.csml.dev/?utm_source=medium&utm_medium=article&utm_campaign=zendesk) on its free development Studio.

## Step 1: Build the chatbot base
Let’s code the chatbot base, for now let’s just ask to the user the question that Roy asks all day long, only we’ll be a bit more polite than Roy.
Here is the result, if you’re looking for the source code, it’s over here 👇https://gist.github.com/bastienbot/39af60477f77bbd96e724c8e68fb64e0
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/55t4xz6b2kp3gr1jsfx4.gif)

## Step2: Install the Zendesk app
In the CSML development Studio, you can install “Apps”, they are connectors to third-party services. In this case, we’re going to install the Zendesk app.
To install it, go to Functions > Apps directory.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/tsfiv55xinyfvglv7awf.png)

You will need three informations in order complete the App installation: ZENDESK_URL, ZENDESK_EMAIL and ZENDESK_API_TOKEN.
Let’s go find these.

## Step3: Get the url, email and token from Zendesk
To get the API Token you will need to connect to Zendesk as administrator. Then go to: Admin > API, then you can **create a token** under the section “Token Access”.
The email is your **account email**, and the url is the first part of the dashboard url as follows: **https://my-company.zendesk.com**
*Make sure you don’t keep the trailing slash at the end.*

## Step4: Time to finish the bot
Now that we have the App successfully installed, we only need to write a single line of code (line 43) to get the chatbot to create tickets on the go.
{% gist https://gist.github.com/bastienbot/39af60477f77bbd96e724c8e68fb64e0 %}


Whenever a user confirms having turned his device off and on again, the chatbot asks the user to describe the issue, remembers it and uses this information to create a Zendesk ticket **on its own**.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/59v11s7wz46tmcu9yv3i.png)

## What’s next?
Depending on your business, there are a few ways to improve a customer support chatbot:
- Adding a **QnA NLP base**, the user can ask questions to the chatbot using natural language, the chatbot can then answer frequently asked questions and forward the question to Zendesk if no suitable answer exists (exemple: [Clevy](https://www.clevy.io))
- Adding more chatbot flows for to help the user resolving the issue on his own. In fact, **Apple as well as many other companies** provides this service before opening a ticket.
- Asking more questions to the user in order to have **as many informations as possible** when creating the ticket. The agent in charge of resolving the ticket won’t have to ask them later.
- Get the user to **upload a file** (a screenshot for instance) that the chatbot will attach to the ticket.

With all these features, Roy can be no other than a happy man 😎.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/8e32d8vz8a55ycpbdxiv.gif)