Bot Management

Introduction

To manage the bots on the system, head over to the Bots item on the left sidebar menu. If you have the Organization Admin level access, you will be able to see the list of bots in the system.

Click on the Bot ID to start editing the bot. Bot editing is broken down mainly into three parts -

  1. General: you can change the bot name, description and conversation_starter here.
  2. Functions: you can define Pre-functions and Post-functions for your bot to execute before and after running intents in this tab.
  3. Flow: you can visually define the flow of conversation of your bot here by simple drag-and-drop method.

Finally, you will se the Publish tab on the bots navbar which is used to publish the changes you made in your bot to production.

After creating new bot, we need to setup the Pre-functions and Post-functions for the bot. Upon successful bot cereation, you will be automatically redirected to this page.

Functions Editor

The functions editor will display two primary tabs - pre.py and post.py which will respectively set code for the Pre-functions and Post-functions on the page.

These function auto-deploy on a scalable infrastructure and work independenly between execution flows of the intents, live during a call.

pre.py

The functions defined in pre.py will receive the request object of the conversation before the intent executes. This means that using the functions provided in this file, you will be able to fetch data from external APIs that you can then plug-in into the output that the bot will next produce.

All the Pre-functions are wrapped inside a Python class PreFunctions. The definition of this class is given below for your reference:

pre.py

This python file used to get request from client and send the resepctive response. These file contain Prefunction Class and userdefine functions. To create the functions we need to follow the following details. The syntax to declare a pre function is: eg.

class PostFunctions():
    def __init__(self):
        self.name = "PostFunctions"

All the user-defined Pre-functions need to be a method of this class and need to accept the request variable, as shown below:

    def samplePreFunction(self, request):
      // function body
      response = {
        "foo": "bar"
      }
      return response

Here,

samplePreFunction - any user-defined name given to the function.
request - live information from a call via the bot is transferred to this variable in the following format:

{
  "context": {
    "key": "val"
  },
  "outputs": ["output1", "output2", "output3"],
  "transcription": "the current input by the user"
}

return response - returns a dictionary response from the function which then directly updates the context available to the future intents and functions.

post.py

Exactly similar to how Pre-functions work except in when these execute. Post-functions run after the intent has complete running which means that it can be used to perform tasks based on whatever output was produced in the previous intent.

If you combine the fact that you can manipulate the bot output from the Pre-functions and then store variables to the context store and finally use them to make decisions about which intent should next be invoked from the Post-functions, you can choose to entirely control the bot execution flow from these files. This should only be used in advanced implementations of the bot and in most cases avoided for sake of simplicity and observability offered by the Flow editor tool.

Flow Editor

Flow Editor Page

The above screenshot shows how the Flow editor tool displays the conversation flow of your bots. At every node which branches out, there must be defined a Post-function to handle the switching of the branch, which will otherwise be done randomly.

To add an intent, click on the green + button on the top left of the Flow editor. This will add an intent at the center of the page and then you can drag and drop it as per your convenience.

To add a connection between intents, start dragging from the bottom of any intent which will be marked in yellow and drop it on the green area about any intent. The direction of the connection will be from top to down, hence the conversation will be flowing from the yellow handle intent to the green handle intent.

You will see that an edge has been created between the intents. To delete any edge, simple drag the edge onto blank area of the Flow editor and it will be removed from the graph.

To edit intents and to associate Pre-functions and Post-functions to the intents, double click any intent to open the intent editor modal. Here you can define the inputs, outputs, associated functions and other attributes of the intent.

Intent Editor Modal

Once you are done updating the intents, make sure to click the Save button at the bottom of the modal and then the Save button icon on the Flow editor page, displayed on the top left in a blue button with the save icon on it.

Publish

The Publish page allows you to deploy to production all the changes that you have made to your bot. Click on the Publish tab on the bot navbar and then click on the Publish button to start deploying your changes. The deployment should take roughly 2-3 seconds.

To test the updates on any bot, place a new call any lead from your leadlist.