Skip to main content
Conversation

How to connect API to customer data sources

by content 03.06.2020

FPT.AI Chatbot can connect to the external data sources through API using JSON API, in order to receive/send users’ information via URL.

This feature is useful in many business processes, for example, checking order status in stores or locking lost cards in banks.

In the article, we will show you how to integrate a chatbot with Customer Relationship Management system (CRM), specifically Google Sheet, to lock card in banks.

(Learn how to use Google Sheet API at: Sheets API)

Here are step-by-step instructions for locking cards with Chatbot and setting up and integrating Chatbot with external data sources:

Step 1: Create a “lock card” script:

               - Create Step

               - Create Intent

               - Create Sample

               - Create responses for Chatbot with Text Card           

Step 2: Set up and create variables

              - Set up variables

              - Create questions for users to provide information with Form card

Step 3: Send data to API for processing

               - Prepare data in Google Sheet (excel sheet) format

               - Create JSON API Card

Step 4: Handle users’ responses

              - When customers enter correct information

              - When customers enter incorrect information

Step 5: Delete variables

Detailed instructions

Step 1: Create the “lock card” script

  1. Create and name a new step. For example, Lock Card.

 

Chatbot FPT.AI

  1. Create Intent

Intent is the purpose of users’ sentences, in this case, the Intent of users is to lock their cards.

  • Name: lock_card_khoathe

Chatbot FPT.AI

Note: Intent’s name is written without accent marks, each word is separated by "_".

  1. Create Sample

Sample is a set of sentences that users use to communicate with chatbot. In this case, users tend to ask questions about “locking card”.

For example:

      • I want to lock my card
      • Lock my visa card immediately, please
      • I just lost my card, please lock it immediately
      • Please lock the visa card for me I just lost it
      • Admin, please help me lock the card
      • Lock the card for me.
      • Etc.

Chatbot FPT.AI

Note:

 

  • You have to enter all the variants and synonyms of the intent to make sure chatbot identify the intent of users accurately. You should enter a minimum of 20 sample sentences for 1 intent.
  • Then click the "Train" button, chatbot will "learn" all sample sentences you had provided, helping it identify users’ intent and give accurate answers quickly.

 

  1. Create responses for Chatbot with Text card

           - Select Text tag (1)

           - Enter the answers of Chatbot (2)

Chatbot FPT.AI

As users’ questions are similar to Sample Sentences you had created, the chatbot will give the answer according to what you set up.Chatbot FPT.AI

 

Step 2: Set up and create variables

  1. Set up variables

 

  • In the Conversation Management (1) section, click Set up variables (2) to create variables that store customer data.
  • Click Add variable: Enter the Variable Name (3), select the Entity type, authentication type, and then click Save (4) to create the variable.
  • Create Variables to store user information:

 

                - id_number: To store the ID number of users

                - Card_numbers: To save the card number that users provided

                - DoB: To save the customers’ date of birth

Chatbot FPT.AI

  1. Create questions for users to provide information with Form Card

After storing user information according to variables, you create questions for users to provide information with Form tag.

  • Select Form card
  • Select Variables and enter the corresponding questions to ask users to provide further information

For example: id_number: Please enter your ID numberChatbot FPT.AI

When users answer the questions, the data will be saved in the corresponding variable.Chatbot FPT.AI

Demo chat interface of chatbot and users. Here are the values that chatbot saves in its system:

 

  • id_number: 510858545
  • card_numbers: 3431
  • dob: 26

Step 3: Send data to API for processing

  1. Prepare data in Google Sheet (excel sheet) format

In this step, we send data to API for processing.

FPT.AI created an API to check the data provided by users and send the results.

To simulate a tabular database, FPT.AI created a file on Google Sheet and connected user data to this file.

Chatbot FPT.AI

User data file includes: Customer name, ID number, Date of birth, Card number, Card status.

  1. Create JSON API card

We use the JSON API card to send/receive data to an API,

In the JSON API card, there are two methods to call the API, namely POST and GET. Select the method that is suitable to API URL.

If selecting GET method, you can send data to the API via API URL link.

Or you can send via the Variables section (with both POST and GET methods)

Chatbot FPT.AI

You can return any data you want in the API with the following response:Chatbot FPT.AI

The API returns the complete information of users with the word "success".

          - If success = 1, the data exists on the database.

          - If success = 0, it means that user data is Wrong or Not yet in the database.            

To capture data returned from the API, you set additional variables with the same name.

  • success
  • full_name
  • full_card_number

Step 4: Handle users’ responses

  1. If information users provided is wrong or “does not exist”, set up the appropriate response for chatbot.

Chatbot FPT.AI

  1. If information users provided is correct, set up the answer providing information that users need.

Chatbot FPT.AI

Step 5: Delete variables

You should add the Delete step with Memory card to make sure chatbot not to use the old data in the next conversation with users.

  • Select the Memory card

Chatbot FPT.AI

  • Select the variables you want to delete

Chatbot FPT.AI

 

Experience with chatbot

When users enter correct informationChatbot FPT.AI

When users enter wrong informationChatbot FPT.AI

Data was successfully updated in the database:Chatbot FPT.AI

 

More specifically, please watch in the following video tutorial:

 

-------------------------------------

? Try #FPT_AI latest product at: https://fpt.ai/en/

☎ Hotline: 0911886353

? Email: [email protected]