The purpose of the Chatbot generator is to automatically build and deploy a chatbot to any of the supported Chatbot providers.
A Pattern called Conversational Flows exists under the Patterns node of the Preferences view in GeneXus.
You have to define a Conversational Flows instance to create your chatbot, and configure the least necessary settings: NLP Provider property and the Provider credentials (User Name property and Watson User Password property). See Configuring GeneXus for using the Chatbot Generator.
Then, define the Flow of a Conversational instance which setup the conversation.
You can create as many instances as needed by your application.
To create a chatbot, you just need to design the model and the pattern will generate automatically all the objects needed to solve the conversation between the user and the AI provider.
The purpose of the objects generated by the chatbot generator pattern, is to digest the messages received from the user, and build the query to be sent to the AI provider. Then the response is handled through a handler and the result is shown to the user. The result can be a text message, or a GeneXus object with a graphical interface. See How GeneXus chatbots work.
More specifically, when you select the Generate ChatBot option for the first time (or just save a Conversational Flows instance for the first time), a module is automatically created (you will have a module for each Conversational Flows instance in the KB).
This module contains the definition of all the objects automatically generated by the Chatbot generator.
Callers of the UI objects:
In particular, the <InstanceName>WebUI object, is a main webpanel which calls the "PanelChatWeb" object.
Similarly, the <InstanceName>SDUI object, calls the "PanelChatSD" object for the corresponding instance.
Handler object: The handler is the service that is responsible for "routing" the user's query to the procedure that was generated to comply with the intent to which it corresponds. The Handler is executed after the query is sent to the provider, so that it has the necessary data to know where to redirect. It's a generated object.
xxBot objects: These are the procedures to which the Handler "routes". They take the name of the Conversational Object of the bot, plus "bot". They are generated based on the defined flows. They know how to interpret the context to decide when they have to execute the conversational object associated with their flow (with the appropriate parameters).
xxComponent & xxComponentSD: These are the automatically generated components for flows that have a component type response (for web and sd).
Another module, called CommonChatbots is created which contains all the pattern resources. The Web resources are imported automatically when the first conversational flows instance is created in the KB. The SD resources are imported when you set the Enable SD UI Generation property to TRUE for any instance, and they do not already exist in the KB.
In sum, the pattern generates some objects, which are included in the module of the instance, and there are other objects (resources) which are in the "CommonChatbots" module. The last, can be modified as you desire, as they aren't updated any time that the pattern is generated.
- ChatMessage: Table used to store messages and their metadata.
- ChatUser : Table in which users and their devices are stored
The "GXChatbotsGeneratorWeb" and "GXChatbotsGenerator" Themes are resources used to style the UI of the chatbot. As they are not generated by the pattern, you can make all the necessary changes to these objects to give your app the look & feel you want.
In the case of SD; in order to keep the style that you have already defined to your app, you need to set the Theme for SD (GXChatbotsGenerator) to inherit from the Theme you are already using. Use the Base Theme property for that purpose.
Then, set the Theme property for the platform. See Theme for Smart Devices Object for more information.
Similarly, in the case of Web applications, the Theme property has to be set to "GXChatbotsGeneratorWeb".
The "PanelChatWeb" object is a resource which is imported when you create a conversational Flow instance for the first time and it's the UI object for WEB chatbots.
The "PanelChatSD" is the corresponding resource object for Smart Devices, which is called by the <InstanceName>SDUI generated object.
The pattern uses an external Module where the services which interact with the AI API are defined. It contains the necessary services to communicate with the different providers.
The Chatbot module is automatically installed in the KB, when you create a Conversational Flows instance. You can check if it's installed (and updated) going through the menu "Knowledge Manager -> Manage Module References".
In the case of Watson, the module contents are the following:
ChatBotWatson -> Service consumed on the web to obtain the interpretation of the user's query
ChatBotWatsonSD -> Same as above but for SD
ContextAdapter -> "Knows" to adapt the generic context to the Watson specific context
ConversationalConfiguration -> Returns the configuration of the chatbot (using its credentials and URL) for the service provider.
On the AI provider side, the pattern generates the Intents, Entities, and the Dialog to setup the conversation.
For example, in Watson provider, a workspace is created with all that components, that allow to build the final solution.
See Conversational Flows pattern settings
When you save the instance, the dialog is updated in the Provider. That is, a JSON object is created including the necessary changes, and it's sent to the Provider to update the conversational model.
In the Build process, the pattern instance is refreshed (the objects are generated).
To force the process of refreshing the instance, right-click on the Conversational Flows tab, and select Generate ChatBot. When you select the Generate ChatBot action, the model is synchronized with the AI provider (the same as saving the instance), and the instance is refreshed (so the objects of the pattern are generated).
The connection to the Chatbot Provider is done using the Username and Password properties (this depends on the Provider).
In the case of Watson services, the Chatbot generator generates a JSON file located under the model's directory: <KB_Directory>\Model\bot\Watson. This JSON file is POST to Watson, to generate the Workspace.
A file called <Conversational Flows instance name>.config is generated under the web directory, which contains the credentials to connect to the AI service (including the workspaceId in Watson).
Note: The following warning is displayed when the Chatbot provider's configuration (Username & Password) is empty. In this case, you can POST the JSON manually to Watson.
Warning: The user and password for the Watson conversation service are empty. The workspace is not going to be uploaded to Watson conversation.
In the case of Web Chatbots, check the Web Notifications and Progress UC requirements because Web notifications are used. The client does not wait for the server for a resonse, asyncronous calls are executed for a better user experience.