You can use the WebHook node to subscribe to a message and WebHook events to capture real-time data from real-time events and show them to the user. You can use the WebHook node for server-side validation, execute business logic, or make backend server API calls. Also, you can use the Kore.ai SDK Tool BotKit to add event handlers and control the messages and WebHook events as required by connecting the WebHook node to a Script node to process the response.
Before you Begin: Creating and Registering an App
To get access to WebHook events and use WebHook nodes in your Dialog task, you need to subscribe and configure an app on the Settings tab for your Bot. For more information, see SDK Configuration.
- Hover over the side navigation panel and click Apps & Agents.
- On the Apps & Agents window, click the Agent Transfer tab.
- From the App Name drop-down list, select an existing app or click Create App.
- In the Create Client App dialog, enter a Name for the app, and then click Next.
- The Client Id and Client Secret appear. Click Done.
- In the Callback URL field, enter the URL from your live agent application.
Note: The registration app you create is based on the Callback URL applicable to all tasks for the bot. While each task can have unique SDK configurations, the Callback URL is the same. Create separate bots for separate application Callback URLs for live agent transfers.
- Click Save. The Successfully subscribed message is displayed.
Setting up the WebHook Node
Setting up a WebHook node in a Dialog task involves the following steps:
Step 1: Adding a WebHook Node to the Dialog Task
- Open the dialog task in which you want to add the WebHook node.
- Hover over a node next to which you want to add the WebHook node, and click the plus icon on it.
- Click the Plus icon that appears after the node, and then select Intent > New WebHook node. The Component Properties pane for the entity opens.
- Enter a name for the node.
- The other settings are auto-filled based on your Agent Transfer SDK configuration. Got to Apps & Agents for changing any settings.
- Timeouts can be configured by selecting from the range of 1 to 10 minutes. By default, it is set to 4 minutes.
Step 2: Configuring the Connections (or Transitions) Properties
You can add If-Else operators in the node’s Connections pane to determine which node in the dialog text to execute next. You can write the conditional statements based on the values of any Entity or Context Objects in the dialog task, or you can use intents for transitions.
To setup Component Transitions, follow these steps:
- Hover over the node, and click the icon. The Connections pane opens.
- On the Connections pane, click Add IF.
- Configure the conditional expression based on one of the following criteria:
- Entity: Compare an Entity node in the dialog with a specific value using one of these operators: Exists, equals to, greater than equals to, less than equals to, not equal to, greater than, and less than. Select the entity, operator using the respective drop-down lists, and type the number in the Value box. Example: PassengerCount (entity) greater than (operator) 5 (specified value)
- Context: Compare a context object in the dialog with a specific value using one of these operators: Exists, equals to, greater than equals to, less than equals to, not equal to, greater than, and less than. Example: Context.entity.PassengerCount (Context object) greater than (operator) 5 (specified value)
- Intent: Select an intent that should match the next user utterance.
- In the Then go to drop-down list, select the next node to execute in the dialog flow if the conditional expression succeeds. For example, if the PassengerCount (entity) greater than (operator) 5 (specified value), Then go to Offers (sub-dialog).
- In the Else drop-down list, select the node to execute if the condition fails.