English

⌘K
  1. Home
  2. English
  3. Flow Designer
  4. Example of API usage

Example of API usage

In this example, let’s see how to use APIs to improve communication with your users, connecting the chatbot with portrAIt: athics’ psychometric profiling technology capable of detecting the main personality traits of the user in real time and guaranteeing a personalized experience in the most appropriate language.

In this way, the chatbot will be able to detect up to 85 users’ psychometric traits (for example: risk of churn, propensity to purchase, up-selling, cross-selling, leaning for logical or creative communication, etc.) to adapt communication accordingly.

First, we ask our bot to retrieve some text to be used for user profiling:

chatbot asks some information to the user

The user’s response will be saved in slot_1 and we will pass the value to the PortrAIt service which will return the result of the user’s psychometric profiling:

Let’s add another block to our flow to make the API call:

How to use chatbot API

Choose the POST method and enter the endpoint to hit:

how to use portrait in API call

Let’s enter the configurator, move to the “Headers” tab and add an authorization token (you can create your token directly from the PortrAIt platform).

How to add an authorization token

Let’s move to the body to send the text acquired by the bot saved in slot_1 to PortrAIt

How to write the API portrait payload

Enter the information into the text field as shown in the figure above.

NB: to recall the information acquired by the bot it is important to recall the slot variable, using the double brace syntax: {{slot_1}}

Let’s test the call by clicking on “try it!” as shown in the figure:

How to test an API call to portrAIt service

Let’s move inside the response to check the outcome of our user profiling:

portrait response

Let’s move to the bottom of the configurator to assign the values of the data received in the response to the bot’s slots, so that it knows how to use them. Indicate the response keys in jsonpath format as shown in the figure:

put portrait response value in a custom chatbot slot

Let’s save to make our changes take effect.

Let’s add a new “bot responds” block to our flow to return the value of the call output to the user interacting with the bot.

How to use the portrait response in a chatbot conversation

To use the value returned by the API call, simply recall the slot between curly brackets: {anger} as shown in the figure above.

We add the exit block to the flow and save.

End of API custom flow

Once the training has been launched and the bot has been updated from the deployment step, we will have a bot in production capable of profiling our users.