Chatbot Overview
Conversational Bots
Intents & Entities
Intelligent Bots
Kore.ai's Approach
Kore.ai Conversational Platform
Bot Concepts and Terminology
Natural Language Processing (NLP)
Bot Types
Bot Tasks
Starting with Kore.ai Platform
How to Access Bot Builder
Working with Kore.ai Bot Builder
Building your first Bot
Getting Started with Building Bots
Using the Dialog Builder Tool
Creating a Simple Bot
Release Notes
Latest Updates
Older Releases
Bot Builder
Creating a Bot
Design
Develop
Dialog Task
Working with User Intent Node
Working with the Dialog Node
Working with Entity Node
Supported Entity Types
Working with Composite Entities
Supported Time Zones
Supported Colors
Supported Company Names
Working with Message Nodes
Working with the Confirmation Nodes
Working with Service Node
Implementing Custom Authentication
Enabling 2-way SSL for Service nodes
Working with Script Node
Working with Agent Transfer Node
Working with WebHook Node
Defining Connections & Transitions
Managing Dialogs
Prompt Editor
Action & Information Task
Working with Action Tasks
Working with Information Tasks
Establishing Flows
Alert Tasks
Working with Alert Tasks
Managing Ignore Words and Field Memory
Knowledge Tasks
Knowledge Ontology
Building Knowledge Graph
Importing and Exporting Bot Ontology
Knowledge Extraction
Natural Language
Overview
Machine Learning
ML Model
Fundamental Meaning
Knowledge Graph Training
Traits
Ranking and Resolver
NLP Detection
NLP Settings and Guidelines
Bot Intelligence
Overview
Context Management
Session and Context Variables
Context Object
Dialog Management
Sub-Intents
Amend Entity
Multi-Intent Detection
Sentiment Management
Tone Analysis
Sentiment Management
Default Conversations
Default Standard Responses
Channel Enablement
Test & Debug
Talking to Bot
Utterance Testing
Batch Testing
Recording Conversations
Publishing your Bot
Analyzing your Bot
Overview
Dashboard
Conversation Flows
Bot Metrics
Advanced Topics
Bot Authorization
Language Management
Collaborative Development
IVR Integration
Universal Bots
Defining
Creating
Customizing
Enabling Languages
Smart Bots
Defining
Sample Bots
Github
Asana
Travel Planning
Flight Search
Event Based Bot Actions
Bot Settings
Bot Functions
General Settings
PII Settings
Customizing Error Messages
Bot Management
Using Bot Variables
API Guide
API Overview
API List
API Collection
SDKs
SDK Overview
SDK Security
SDK App Registration
Kore.ai Web SDK Tutorial
Message Formatting and Templates
Mobile SDK Push Notification
Web Socket Connect & RTM
Using the BotKit SDK
Installing the BotKit SDK
BotKit SDK Configuration
Events for the BotKit SDK
Functions for the BotKit SDK
BotKit SDK Tutorial – Agent Transfer
BotKit SDK Tutorial – Flight Search Sample Bot
Using an External NLP Engine
Bot Administration
Bots Admin Console
User Management
Managing Users
Managing Groups
Managing Role
Bots Management
Enrollment
Inviting Users
Sending Bulk Invites to Enroll Users
Importing Users and User Data
Synchronizing Users from Active Directory
Security & Compliance
Overview
Using Single Sign-On
Cloud Connector
Analytics
Billing
How Tos
Context Switching
Using Traits
Live Agent Transfer
Schedule a Smart Alert
Configure Agent Transfer
  1. Home
  2. Docs
  3. Bots
  4. Bot Building
  5. Dialog Task
  6. Working with the Service Node

Working with the Service Node

The Service node is a component type in a dialog task that you can use to add an API service to make REST or SOAP requests to third-party web services. You can use this node when you have collected the parameters needed for the API request using Entity or other nodes to capture the user input.

You can define the Service Type as one of:

  • Custom Service – Define an API request to a third-party web service. This is the default setting.
  • HTML to Image – Define HTML to render as an image using JavaScript. For example, you want to compose HTML or the value of a key in a web service response contains HTML markup as a string that you want to convert to an image.
  • URL to Image – Define a web page URL to load to render an image.
  • Alert Subscription Service – Define contextually relevant alerts to be sent proactively to the user as a part of the dialog journey.

Creating a Service node

  1. Click the Plus icon diydialogtaskplusicon where you want to add a new Service node,
  2. Select Service and then click Create new Service Call. You can also select from a list of pre-defined Service Nodes.
  3. A new default Service node is added, and the Component Properties panel is displayed.
  4. In the General Settings, enter the Name and Display Name of your Service node, for example, FetchWeather.
  5. Choose the Service Type as:
    • Custom Service – Define an API request to a third-party web service. This is the default setting.
    • HTML to Image – Define HTML to render as an image using JavaScript. For example, you want to compose HTML or the value of a key in a web service response contains HTML markup as a string that you want to convert to an image.
    • URL to Image – Define a web page URL to load to render an image.
    • Custom Authentication Service – Define a URL to a third-party application that provides the authentication services necessary for the task flow. Learn more.
    • Alert Subscription Service – Define contextually relevant alerts to be sent proactively to the user as a part of the dialog journey.
  6. Based upon the Service Type selected, enter the Type/Sub Type or Auth URL.
  7. In the Request Definition section, click >Define Request.
  8. The Define Request for < ServiceXXXX > dialog is displayed. Depending on the Service Type selected, see one of the following sections in this topic:
    Note: In the case of Custom Authentication Service, the Request Definition section doesn’t apply and you can see a Response section instead. Learn more. 

  9. From the node’s Connections panel you can determine which node in the dialog task 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:
    1. You can select from the available nodes under the Default connections.
    2. To configure a conditional flow, click Add IF.
    3. Configure the conditional expression based on one of the following criteria:
      1. 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)
      2. 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)
      3. Intent: Select an intent that should match the next user utterance.
    4. In the Then go to the 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).
    5. In the Else drop-down list, select the node to execute if the condition fails.
    Note: If you want to write multiple If conditions, click Add Else If below the last If conditional expression.

Defining a Custom Service

  1. When Custom Service is selected for Service Type, then in the Sub-Type field, select one of:
    • REST – The API web service is using REST services.
    • SOAP – The API web service is using SOAP services.
  2. In the Request Definition section, click Define Request to specify the settings for the web service type.
  3. The Define Request for < Service Node Name > dialog is displayed as shown in the following illustration.

    1. In the Request URL field, in the first field, select the HTTP method used for the request. One of:
      • POST – Used to send data to the server, for example, customer information, file upload, and so forth using HTML forms.
      • PUT – Replaces the content of the target resource with the content sent.
      • PATCH – Appends the content of an existing target resource with the content sent.
      • DELETE – Deletes the content of an existing target resource.
      • GET – Returns the content of an existing target resource.

      NOTE: For SOAP services, you can pass the XML payload in the ‘body’ by using the POST method

    2. In the second field of the Request URL, specify the URL for the Dialog task response to process at Kore.ai, for example, http://koremessenger.com/postURL. Add query or path parameters as part of the URL, if required. To use Entity node values as parameters, use the following syntax for accessing the Context object: https://myDomain.com/{{context.entities.topic}} for the context.entities.topic. You must use the double brackets {{ context.object }}. For more information, see the Context Object.
    3. Optionally, click Show Advanced, and then select
    4. In the Auth tab, select the type of authorization needed for this Service node call, or define a new authorization type if needed. For more information, see Setting Up Authentication.
    5. In the Headers tab, specify the headers as key/value pairs if required to access the specified Request URL.  Authentication headers are auto-generated based on the authorization type specified on the Auth tab. You need to define any other standard headers, for example, Content-type, Accept, etc. or any custom headers. Headers defined here are only applicable to this Service node.
    6. In the Body tab, select the body content type. One of:
      • application/x-www-form-urlencoded – Also known as Multipart/Form-data, which is an encoding type that allows files to be sent through an HTTP POST request method if you want to allow a user to upload a file from a form. You can add key/value pairs which are encoded by the Bots platform.
      • application/json – Use JSON to transmit data between the Kore.ai servers and your Bot web application. Any JSON is sent with the request without any processing.
      • application/xml – For SOAP services, pass XML payload using POST methods. You can pass Entity node values as part of the XML, using the following syntax for accessing the Context object: https://myDomain.com/{{context.entities.topic}} for the context.entities.topic. You must use the double brackets {{ context.object }}. For more information, see the Context Object.
    7. In the Test Request tab, click Test to optionally send your API Request URL, using the specify Auth type, HTTP headers, and body parameters, if defined. The response is displayed in the text area. Click Save as Sample Response to save the test response as the sample response for this node.
    8. Click Save to save the request for the Service node and close the Define Request for < Service Node Name > dialog.
  4. In the Sample Response section, optionally click Add Sample Response to display the Add Sample Response dialog that you can use to manually enter or paste a sample response.
  5. Optionally, in the Add Sample Response drop-down list, select one of:
    • JSON – A list of JSON key/value pairs available in the Request URL response that can be used in other nodes as variables.
    • RAW – A list of key/value pairs that can be used in other nodes as variables.
  6. In the Component Properties section, under Advanced Controls, you can configure the Timeout for terminating the service call. By default, it is set for 20 seconds, you can choose a value anywhere between 5 to 20 seconds.

Defining a URL to Convert to Image

  1. When URL to Image is selected for Service Type, the Type setting is read-only.
  2. In the Request Definition section, click Define Request to specify the settings when URL to Image is selected for Service Type. The Define Request for < Service Node Name > dialog is displayed as shown in the following illustration.
  3. In the URL to Convert field, enter the URL for the image. The syntax when using a Context object key in a URL is to enclose the object name in double brackets, for example, https://myURLimage.com/{{context.entities.imageName}}.
  4. In the Render Sizes section, specify a name for the image size, for example, iPhone or tablet, enter the Width and Height in pixels, and then click +Add to add additional sizes, or click Add to save and close the dialog.
  5. Click Save to save the request for the Service node and close the Define Request for < Service Node Name > dialog.

Defining HTML to Convert to Image

  1. When HTML to Image is selected for Service Type, the Type setting is read-only.
  2. In Request Definition section, click Define Request to specify the settings when HTML to Image is selected for Service Type. The Define Request for < Service Node Name > dialog is displayed as shown in the following illustration.
  3. In the HTML to Convert field, enter the HTML for the image.
  4. In the Render Sizes section, specify a name for the image size, for example, iPhone or tablet, enter the Width and Height in pixels, and then click +Add to add additional sizes, or click Add to save and close the dialog.

Example HTML Definition
The following is an example for converting HTML to an image:

<head>
<link href="../assets/styles.min.css" rel="stylesheet"/>
<title>HTML: Print Wide HTML Tables</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<style>
  .style1 {
     border-collapse: collapse;
     }
  .style1 th {
     background-color: #DDDDDD;
     white-space: nowrap;
     }
  .style1 .d {
     white-space: nowrap;
     }
  .style1 .n {
     padding-left: 20px;
     text-align: right;
     }
</style>
</head>
<body>
<table id="table1" class="style1" border="1" cellpadding="4" cellspacing="0">
  ///TODO Add Table Rows here.
</table>
<input type="button" id="print-button" value="Make this table printable contact@ {{context.session.UserContext.emailId}}"/>
<script>
/*
 * HTML: Print Wide HTML Tables
 * http://salman-w.blogspot.com/2013/04/printing-wide-html-tables.html
*/
$(function() {
$("#print-button").on("click", function() {
   var table = $("#table1"),
       tableWidth = table.outerWidth(),
       pageWidth = 600,
       pageCount = Math.ceil(tableWidth / pageWidth),
       printWrap = $("<div></div>").insertAfter(table),
       i,
       printPage;
   for (i = 0; i < pageCount; i++) {
      printPage = $("<div></div>").css({
          "overflow": "hidden",
          "width": pageWidth,
          "page-break-before": i === 0 ? "auto" : "always"
        }).appendTo(printWrap);
   table.clone().removeAttr("id").appendTo(printPage).css({
      "position": "relative",
      "left": -i * pageWidth
     });
   }
 table.hide();
 $(this).prop("disabled", true);
});
});
</script>
</body>
</html>

The preceding HTML example, when table rows are added into the example, can render the following image to an end-user.
HTML Image Example

Defining Alert Subscription Service

You can now automatically subscribe your bot users to send contextually relevant alerts as part of the dialog journey. For example, a person booking a flight ticket for a specific date can be auto-subscribed to get regular updates on the weather forecast for the destination city.
To set up an Alert Subscription service

  1. Open the Properties panel of the Service Node to which you want to associate the alert.
  2. In the Service Type drop-down list, select Auto Subscription Service.
  3. Click Define Request. It opens the Smart/Automatic Alerts dialog.
    Note: To create an Alert Subscription service, you must base it on an existing alert task. Users will be auto-subscribed to the alert task on reaching the associated service node in the dialog.
  4. From the Choose Alert drop-down list, select an alert task. The list consists of only the published alert tasks related to your bot.
  5. Enter the necessary information as explained below.

Alert Subscription (Smart Alert) Configurations

In a typical alert setup, the alert parameters, filters, and other necessary details are entered by the bot users. Since this is an auto-subscription for alerts, you need to configure those details as a developer.

ALERT PARAMETERS

These vary according to the alert you select. Provide the default parameter values to be used for the Alert Subscription service.
In this example, the parameters to be defined for the alert are Topic name and News Region. Since the idea is to send weather forecast to the user for the destination city, you could set the parameter values are Weather Forecast and context.entity.destinationcity respectively.

FILTERS

These vary according to the alert you select. Provide the filter criteria to be used for the Alert Subscription service.

ALERT FREQUENCY

Provide the frequency for sending alert notifications. You need to select a Scheme, Frequency and a Time Frame.

  • From the Select Scheme drop-down, select daily, weekday, or weekend, depending on when you want to send the alert.
  • From the Select Frequency drop-down, select Every if you want to send the multiple alerts at regular intervals of time in a day or select at to send one alert a specific time of the day.
  • From the Select Time drop-down, select an interval time value or a time of the day, depending on the frequency value chosen above.

In our example, we have selected Daily At 6 a.m. which means an alert is sent to the user every day at 6 a.m.

SMART ALERT EXPIRY

Configure when to expire sending alerts to the users from one of the following options:

  • Duration: Stops sending notification after the entered number of days from the date of subscription.
  • Number of Notifications: Stops sending alerts after an entered number of notifications are sent.
ALERT UPGRADES

Define the expected behavior of this alert if an upgraded version of the underlying alert task (the published alert that you have selected at the beginning) is published.

  • Remove Existing Instances
    All existing subscriptions of this smart alert will be removed and users will no longer receive notifications. Users will be auto-subscribed to the upgraded alert task only when they execute the dialog and reach the service node in the dialog journey.
  • Allow Users To Manually Upgrade Subscription
    Users will receive an Upgrade notification on the selected channel which a link that guides them through to upgrade their auto-subscription. If the upgrade is successful, the user will receive a success notification.
Menu