Skip to main content

Extension

AI Studio provides a way to extend the Chatbot webservice functionality. We provide hooks for certain processes which you can use to write your specific code. You can also add custom python functions, custom triggers, and workflow functions.
This code extension can be managed through the Extension subtab.



img alt

  1. Last Updated Date: The last updated date for any custom code modifications.
    Refresh ( ): Refresh both the panels.
    Download ( ): Downloads the current custom code in a zip file.
    Upload: Upload a custom code zip through this option.
info

You need to follow the same file structure while uploading a zip file.
You cannot modify/update any file directly in the Extension subtab. Uploading the custom code zip is the only option available.

  1. Custom code structure.
  2. View the contents of the selected file.

Custom code structure

The files and folders available under the Extension submenu are explained below,

  • functions: These are the functions that can be used in dialog designer. Each functionality is divided into a different folder as follows,
    • custom_trigger: Define python files for custom triggers and they will be available for selection under Skill Settings -> Custom Triggers -> Function.
    • python: Define python files for custom python functions and they will be available for selection under Skill -> Dialog Designer -> Action Dialog Element -> Action: Python -> Function.
    • workflow: Define python files for workflow functions and they will be available for selection under Skill -> Dialog Designer -> Action Dialog Element -> Action : AE Workflow -> Workflow Parameters tab -> Type : Function -> Value.
  • helpers: Helper or common utility files and methods can be placed here.
  • migrations.py: In case you need extra database tables for the custom code written, it will be handled from here. The migration files will be executed everytime the Chatbot webservice is deployed.
info

Custom database tables support is not available for Cloud instances.

  • apps.py - Custom code application-level configurations can be done here.
caution

Do not change/remove the following line from apps.py,
name = "custom"

  • custom_hooks.py: The main file where you can define logic in the specific hook method.

    • export_dialogs: List of custom dialogs. For whatever reason a dialog cannot be designed in the Dialog Designer, a custom dialog can be created and registered in this variable.

    Different hooks available are explained below,

    • root_dialog_hook: This method will be invoked before matching triggers from dialogs in Dialog Designer. You can return the dialog (custom or any dialog from the Dialog Designer) that needs to be executed. And None if you do not want to execute any dialog.
    • custom_view_hook: We have provided a new API Chatbot webservice URL/api/custom. This method will be invoked when the custom REST API is called from any source.
    • storecon_hook: This method will be invoked for every activity before the user chat history is logged.
    • webchat_join_event_hook: This method will be invoked when the user starts a new conversation.
    • aistudio_dialog_element_hook: This method is invoked before executing any Dialog Element.
    • api_messages_hook: This method is invoked for every Chatbot webservice URL/api/messages REST API invocation.
    • api_reply_hook: This method is invoked for every Chatbot webservice URL/api/reply REST API invocation
  • extra_requirements.text: If your custom code needs any python library which is not part of the Chatbot webservice, it can be specified in this file. These extra python libraries will be installed in the chatbot environment during deployment.

  • models.py: Model files for the custom database tables.

  • settings.py: Environment variables which are needed by your custom code can be set here.

info

Custom environment variable(s) values can also be set during deployment.