Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Intents can have Python callbacks defined as their response. This page describes how to create custom callbacks and where to find reference material.

Custom Python code

When processing a conversation, Koji tries to extract an intent and deliver a response to a user. Intent in Kbot is the primary logical unit of a conversation. They can have Python callbacks defined as their response.

Python callbacks' code allows you to run any kind of interaction with users, send requests to external systems, and eventually end the intent with particular return code (completed, failed, etc.).

To add your custom code, use Editable files.

Creating and editing custom callbacks

Editable files allow you to modify code that can be used to leverage Koji functionalities. There is no access to source code of the software, but editable files help you modify some parts.

To view and modify editable files:

1. Go to Development.

2. In the Configuration section, click one of the Callbacks Code files.

3. Modify its content in the window and click Save.

Sample

Note that by default Callbacks Code files provide you with the tips on how to create functions.

Image Modified

Reference material

To view the reference material on callbacks, open the help page. It is available on your instance with the following address: https://<yourinstance>.konverso.ai/doc/Responding-with-callback-scripts_500302062.html. Just substitute <yourinstance> with the actual name of your host.

What’s next?

Once you have created a callback, you can use it as an intent’s response.

1. Go to Content > Intents.

2. Select an intent.

3. Navigate to the Response section.

4. In the Response type drop-down list, select Callback.

5. In the Callback name field, enter the name of your callback. For example, if your custom callback is stored in core/python/callback/my1.py, specify your callback as my1.

6. Click Save.

Now, when Koji detects a given intent in the chat, it will invoke the defined callback as a response.