# Databases

The databases are linked to the chatbot. You will therefore be able to use the same databases in all your versions or all your chatbot environments.

# Use case

This feature was originally developed to allow us to detect if there were already similar tickets before the user created them. This allowed us internally to reduce the number of tickets and improve the productivity of our tech teams.

However, the number of possible use cases with this feature is infinite.

You can for example:

  • Detect similar tickets
  • Search for the best article in a wiki
  • Search for a product in a database to ask the user for clarification or confirmation

# How to use it

1- Create a new database Create a database

WARNING

The name of your database must not contain any special characters or spaces.

2- Edit the database and add the fields of the database "objects" As a basic rule, we add a vz_id field that will allow us to judge the uniqueness of the objects. Create a database

Once you add all the fields you want, we can validate the actions related to this database.

3- Validate the actions In the Validation tab click on the button to create the actions. Create database actions

4- In the workflows you have 5 new actions

  • FindOne: Allows to find 1 object in the database from its vz_id

  • CreateOne: Allows you to create 1 object in the database

This action will allow you to create the ticket in the "Vizir" database. Fill in all the fields from the workflow editor.

  • RemoveOne: Allows you to remove 1 object from the database

Once a ticket is closed, we can imagine deleting it from the Vizir database too.

  • UpdateOne: Allows to update one or more fields of the object.

We can imagine a webhook from the ticketing tool to update the comments, status, ... in the Vizir database.

  • Find: Allows you to search the database

This is the action that will serve you the most. It allows you to do textual searches in the database on the fields you want. We can imagine several levels of search for tickets. First you search in the title, if you don't find anything, you search in the description, ...

5- Add objects to the database We have dedicated a route to add objects to the database to allow you to do it via a third party tool or a script.

Here is the route to use to create items via API in your database: POST https://developers.vizir.co/chatbots/:chatbotID/databases/:database_id

with a body the fields you have defined:

{
	"name": "Lorem ipsum"
}

Here is the route to use to make a request on the API database: PUT https://developers.vizir.co/chatbots/:chatbotID/databases/:database_id/search

With a body cce that you want to search: For example here, we will search for the term "lorem" in the "name" field

{
	"name": "Lorem"
}

Here is an example of the response you may receive with this type of request:

{
  "count": 1,
  "data": [
    {
      "name": "Lorem ipsum"
    }
  ]
}

The objects in data will include ALL the fields you filled in when you created the object.

DANGER

These routes are secure, so you must have a valid token in the API call (see online help for more info (opens new window))