How to build custom components for use in Oracle Intelligent Bots

About Bot Custom Components

As Figure 1 illustrates, a custom component service in Oracle Intelligent Bots is a Node.js-based REST service that hosts one or many custom components and that exposes two HTTP methods: GET and POST.

Figure 1: Bot custom component service architecture
The GET method is invoked at design time by the bot when the custom component is registered with the Oracle Intelligent Bots instance. The POST method is invoked at runtime when the dialog flow navigates to a state that is associated with a custom component hosted by the component REST service.When invoked, the custom component REST service receives the name of the custom component to invoke; looks up the custom component implementation JavaScript module; and dispatches the request, along with a reference to the custom component SDK.
A custom component is a Node module built with JavaScript that exposes two functions:
metadata. This function returns information about the custom component upon custom component service registration in the bot. The information includes the component name, the definition of the component input parameters (properties), and the action strings returned by the component to enable the bot designer to decide how to continue the dialog flow.
invoke. This function is called at runtime and executes the custom component business logic. The logic may access dependent resources such as Oracle Mobile Cloud connectors, platform services, and custom APIs.
The custom component SDK consists of four files and provides functions for reading the incoming bot message and sending a component response:
Registry. The registry.js file contains a mapping of custom component names and their physical JavaScript files.
Shell. The shell.js file contains the dispatcher logic that reads file locations from the registry.js file and loads the requested custom component implementation.
SDK. The sdk.js file is passed as a reference to the custom component’s invoke function.
MessageModel. The MessageModel.js file contains helper functions for the Oracle Intelligent Bots conversation message model and helps component developers build rich UI bot responses.
Open a browser, and access the Oracle Mobile Cloud Enterprise homepage.
Authenticate with the user credentials you defined when you provisioned the cloud service.
Click the hamburger icon at the upper left to open the Oracle Mobile Cloud Enterprise menu.
Click the Bots menu item (shown in Figure 2), which opens the Oracle Intelligent Bots dashboard in a separate browser window or tab.

  1. Figure 2: Oracle Mobile Cloud Enterprise with Oracle Intelligent Bots selected

  2. Click Import Bot at the upper right of the dashboard.
  3. In the opened dialog box, navigate to the location to which you extracted the downloaded zip file and open the starter-bot folder.
  4. Select the OracleMagazineOnlinePizzaBot4.zip import file, and click Open.
    Note: You cannot import two bots with the same name. If you need to import the starter bot more than once or if you share an Oracle Intelligent Bots instance, rename any previous imports of the starter bot before importing the new bot. You can rename a bot by opening it, clicking the Settings icon (), renaming the bot, and exiting the bot.
  5. Close the upload confirmation dialog box, by clicking the X on the right side.
  6. Keep the browser window open.

Leave a Reply

Your email address will not be published. Required fields are marked *