How to create a smart customer service ai bot that will do much more than just answer questions, without coding

Use case: a printing company would like to automate such tasks as check the order's status, cancel orders, apply credits, help with wrong or non-satisfying orders.

In this article, we review how to create a smart and helpful chatbot that not only answers users' questions but also calls API to make some actions and reads from the Internet to obtain the needed information.

Step 1. Create a project with a text data source

Let's start with creating a project and adding a simple data source to start.

Navigate to the projects list

image

Click the "Add a project" button and enter the project name:

image

Navigate to the data source and click the "Add a data source":

image

Select the "Plain text" from the list and click the "Add this source" button:

image

Click the "Add text content" button and enter the title and text content into the modal window:

image

Then click the "Save and index" button to save the text and index it to make available for the chatbot:

image

Now, let's conduct a simple test to see if the chatbot already picks up the content. Open the interaction window - this is where we will test our chatbot.

image

Click the "Chat" panel and enter a question in the text area below, then click the button to send it. As we can see, the chatbot replies pretty nicely:

image

Step 2. Add the custom prompt.

But what if we want the chatbot to do something more complicated, say, check the order status, apply the credits to an account, or even cancel the order? To achieve it, we have to provide the chatbot with the corresponding instructions. We can do it using 2 tools in the Enum:

  1. Custom prompt
  2. Instruments(R)

In a custom prompt, we add the instructions that will tell the chatbot how to behave. For example, we can tell it:

  • which data to collect
  • what to do if some condition is met or not met
  • and what not not do.

So, before we start, let's see what happens if we don't have any prompts. So, if we don't provide any guide on what to do, the AI returns just pretty default asnwer:

image

Let's add this text to the custom prompt field "You are a helpful assistant. Users will ask you questions about our products which include wall calendars. You need to answer in polite, friendly manner. Never say that user should contact the customer support but only can help, and only is the customer support. You are able to solve all the problems.":

image

Scroll the page, click the Save settings button to save the changes and try again:

image

As you can see, now it's much better. But let's add something that will allows the chatbot to do something really: we will use the tools called "Instruments".

Step 3. Add the instruments

Before we dig into using Instrumens(R), let's review shortly how they work. When a user makes a request, or when AI uses a prompt, there may be some intention to do something. For example, a user can say "can you check my order", or the prompt can say "when a user does X check their order". By default, no any existing LLM (AI) can't do this for you because:

  1. It doesn't know how to check an order, what it mean in practice
  2. It has not any resourses to do it.

To solve this problem, we introduces the Instruments(R) which internally can actually figure out what do to and do it. To make it happen, we need to provide some information for our engine:

  1. The clear instructions when to do when some conditions are met
  2. The technical information like API endpoint, or website URL (to check an URL if needed).

In our example, if we add the API instrument with the API endpoint to check the order (this API should belong you or you may use publicly-available resources) and instructions to the prompt (telling the engine, when exactly we want it to hit this endpoint), we can achieve what we want - to seamlessly check the order.

Small conclusion: Instruments(R) are specific instructions that tells AI to do some things like call an API, or open a web page and read the content. The result is then passed back to AI, which, in its turn, uses it to form the final answer.

Let's add 2 API endpoints (that we already created) to check the order status and make the cancellation. To do it, open the Instruments market and click the Install button for Custom API endpoint:

image

Do it again for the second endpoint, then navigate to the My instruments page to see them:

image

Now, click the details of the installed Instrument. You will see the bunch of settings. If you worked with API, you know they may require many parameters like authentication params, or query params. Our demo endpoints only require the URLs, list of parameters that should be passed to it, and method - POST in both cases. We also need to add some descriptions to explain the AI when to call this endpoint:

For the check order status it may look like this:

image

Scroll to the end of the modal window and add 2 parameters: order_number and email:

image

For the endpoint to cancel an order:

image

and add the same parameters.

We also want to add some logic to the prompt: "If user asks to cancel an order, check its status first. If the status is "created" or "in progress" you can cancel, and cancel the order. In case of any other status like "delivered" or "cancelled", the cancellation cannot be done."

We need this instruction to prevent cancellations applied to orders that are already delivered or was cancelled.

The full prompt is now this:

If user asks to cancel an order, check its status first. If the status is "created" or "in progress" you can cancel, and cancel the order. In case of any other status, the cancellation cannot be done. You are a helpful assistant. Users will ask you questions about our products which include wall calendars. You need to answer in polite, friendly manner. Never say that user should contact the customer support but only can help, and only is the customer support. You are able to solve all the problems. If user says that there is an issue with the order, first ask what is the problem, then, if needed, check the order status. If user asks to cancel an order, check its status first. If the status is "created" or "in progress" you can cancel, and cancel the order. In case of any other status like "delivered" or "cancelled", the cancellation cannot be done. If user is not satisfied with the order, suggest to apply the credits to his account - the sum of credit is cost of the order. You know the cost of the order by checking the order.
Warning
Please note that this example is very simplified. In read life, you will provide the authentication parameters, and the additional logic inside the endpoints to prevent the abuse or misuse the endpoints.

Let's see how it works:

image

As you can see, the chatbot works pretty well. To make sure that the corresponding endpons have been called, please refer to the information on the right: it includes the URL of endpoint, payload (data that was passed) and sometimes, some additional information.

To make the applying the credits possible, you need to add other endpoints and corresponding instructions. Now, let's add some fun.

Step 4. Let AI use real time data

Now, when you see how the Instruments for API endpoints work, you may ask "What if I don't have an endpoint, but I would like to provide access to real-time data?" Obviously, the data source can't be used in this case unless you update it pretty often. But in many cases, especially if some data is publicly avaialable, you just use the Instrument for reading the Internet content. In our case, we want to allow users to re-calculate the cost of orders and products into another currency. If we don't add any specific instruments, we may fail:

image

To fix the problem, let's add the corresponding Instrument called "Get URL content":

image

As you can see it doesn't require any parameters at all. It just provides the inner tool to access the Internet when necessarily. Now, we need to tell AI which web page should be opened and read, so let's add this text to our custom prompt: "If user asks how much the order would cost in other, than American dollars, currency, ask which currency they want (if not provided), then open this page and recalculate the value from there - https://www.x-rates.com/table/?from=USD&amount=1"

As you can see, this instruction contains a URL of web page that has the actual currency information:

image

Now, let's check again if it helps:

image

As you can see the AI successfully opened and read the content from this page, then passed data to the chatbot which used it to form the final answer.

Conclusion

As you can see, using the Instruments(R) can turn your "so-so" chatbot to a real support that doesn't sleep and may work fast and effectively. Let's list some tasks that your chatbot equipped with Instruments can solve:

  • Extract the bug reports from the conversation and send data to the bug tracker
  • Generate texts/reports for marketing purposes baases on some actual information
  • Make calculations
  • Give recommendations based on user's position/situation
  • Search for and book flights, hotels, or car rentals and provide live updates on flight statuses or travel delays
  • Provide technical assistance and help with troubleshooting.
Improve conversion by enhancing support with the AI plugin for Crisp, letting the chatbot assist users when you're offline.