Integrations
Chatbot Tools

Chatbot Tools

Answers

The Chatbot Tools app is a public app available on the Exchange marketplace that provides you with tooling to help set up some of the most common use cases for Answers.

The app consists of the following lightweight functions that extend the Answers functionality:

  • Geolocation Distance Calculator - use geolocation in chatbots to support conversations with your customers
  • File to Base64 - convert files from your chatbot conversations to Base64 to save in databases or third-party storage

Add the Chatbot Tools app

Before using the Chatbot Tools in Answers, you need to add the app:

  1. Log into Infobip and go to Exchange (opens in a new tab) > All Apps.
  2. Search for Chatbot Tools.
  3. On the Chatbot Tools tile, click Add.
  4. Accept the Exchange Terms and Conditions.

The Chatbot Tools integration is then available in Answers.

Chatbot Tools integration in Answers

To use the Chatbot Tools integration in Answers, it is available in the right-hand side panel under the Chatbot Integrationssection. For more information about working with chatbots in Answers, see Create a chatbot.

Drag and drop the Chatbot Tools integration on any part of the chatbot dialog where you need to use the functions.

When using the Chatbot Tools integration, you set the parameters for the functionailty you wish to implement. See the set up descriptions for:

You also include additional chatbot elements in the dialog that enable you to fully implement these functions. For more information about creating chatbots, see Chatbot components and Chatbot elements.

Geolocation Distance Calculator function

The Geolocation Distance Calculator is a function that supports the use of geolocation in chatbot conversations with customers. The main use of the function is to get distance between two coordinates.

For example, a customer may want to receive the closest shops or ATMs based on their current location. To ensure that the required data is given to the customer, you can compile a list of your shop destinations and host them in a locations file. You then use this list of destinations in the Chatbot Tools app.

The app uses the latitude and longitude received during the chatbot flow. It fetches the file from the URL and then returns the closest locations.

Locations file format

The Geolocation Distance Calculator uses a locations file to store your own list of destinations. Before you use Chatbot Tools in the chatbot dialog, you must first create a locations file.

You can choose to create and supply the locations file in either JSON or Comma Separated Values (CSV) format.

The following is an example of a JSON locations file with three destinations objects.

json
 
    {
      "destinations": [
        {
          "latitude": 51.5135655,
          "longitude": -0.2429161,
          "data": {
            "name": "Sports Rise - Brent Cross",
            "address": "Unit C, Brent Cross Shopping Park, Tilling Road, London NW2 1LW"
          }
        },
        {
          "latitude": 51.506747,
          "longitude": 0.223612,
          "data": {
            "name": "Sports Rise - Westfield",
            "address": "Unit 2057, Ariel Way, London W12 7GE"
          }
        },
        {
          "latitude": 51.481815,
          "longitude": -0.199366,
          "data": {
            "name": "Sports Rise - West Brompton",
            "address": "424, 425 North End Rd, London SW6 1NY"
          }
        }
      ]
    }
 

The destinations list holds all the destination objects.

Parameter

Description

destinations      
A list containing all of the destination objects. 
latitude

longitude
The end user's latitude and longitude coordinates.
Each destination object must contain the latitude and longitude as a minimum.
data
Each destination object may contain metadata to feed a chatbot with additional data that supplements the geolocation. For example:
 "data": {

"name": "Store name",

"address": "Address of the store"

}

The following is an example of a CSV locations file.

latitude,longitude,name,bank,customerLimit
41.3300,19.8200,"Tirana, Albania",,
41.3167,19.4500,Durrës,Durrës Bank,3
41.3833,19.7667,Kamëz,,
40.7167,19.5500,Fier,,
42.0667,19.5000,Shkodër,,
41.1125,20.0822,Elbasan,El Basan Bank,
40.4500,19.4833,Vlorë,,

The .csv format is comma-delimited (,) and must use headers. The values can be in any order but latitude and longitude are read as a minimum. The other comma-separated values are used as additional data that supplements the geolocation, in the same way that destination objects are used in the JSON example.

Using Geolocation Distance Calculator function in Answers

In your chatbot, add the Chatbot Tools integration in your chatbot dialog. Select the Geolocation Distance Calculator function from the drop-down list.

The Geolocation Distance Calculator function contains the following attributes in the request.

Attribute

Description                              

LongitudeThe end user's location coordinates.
LatitudeThe end user's location coordinates.
URL of The Locations FileThis identifies your database of locations.The maximum file size is 3MB.
Locations File Type (JSON, CSV) This specifies whether the locations file uses JSON format or Comma Separated Values format.
Number of Location ResultsThis specifies the number of location results that may be returned in the response.For example, you can limit the results to the top 3 locations.
Authorization Header Name - For Protected Location Files This is an optional attribute as a security precaution so that only this chatbot can access the locations file.
Authorization Header Value - For Protected Location FilesThis is an optional attribute as a security precaution so that only this chatbot can access the locations file.

For more information about the channels that support the use of location, see Chatbot channels.

File to Base64 function

The File to Base64 function enables you to store any kind of media or image file from your customers and convert it into a format that can be saved in a database or third-party storage.

For example, a customer might send you an image of their ID for authorization via one of the channels, and you need to store this image as part of the application process.

Many storage systems are built to receive files only as Base64-encoded strings. If an end user sends an image, this function converts the image file into Base64 encoding ready for storage.

Image URLs

When using this function in an Answers chatbot, the URL is obtained from either the document or image objects, which are interpreted as JSON objects.

For example, an image file URL is received from a customer in WhatsApp. The URL is obtained by parsing the URL attribute.

The function then processes the image file and returns it as Base64-encoded strings in an HTTP response.

Using the File to Base64 function in Answers

In your chatbot, add the Chatbot Tools in your chatbot dialog. Select the File to Base64function from the drop-down list.

This is an example of using the File to Base64 function in an Answers dialog.

The File to Base64 function has a set of attributes in the request.

Attribute

Description                              

File URLThis is the URL of the hosted image file from the end user.
Authorization Header Name - For Protected Files This is an optional attribute as a security precaution so that only this chatbot is authorized to access the file URLs.
Authorization Header Value - For Protected FilesThis is an optional attribute as a security precaution so that only this chatbot is authorized to access the file URLs.

Use a Code element before the Chatbot Tools element to get the image URL. You can use either the Document or Image attribute to extract a Document or Image.

Extract the URL field from either the document or image attribute.

Add a Call APIelement so that you can send this text using your API to store it as text in your database. See API element.

Use a Send Text element to return a message with the base64 image result. See Text element.

The following Simulator view shows an example of implementing the File to Base64 function.

Need assistance

Explore Infobip tutorials

Encountering issues

Contact our support

What's new? Check out

Release notes

Unsure about a term? See

Glossary

Research panel

Help shape the future of our products
Service Terms & ConditionsPrivacy policyTerms of use