Configuring the Action Task Response

After you describe your Bot action task, and if required, configure the task request objects, you are ready to set up how the task results are displayed to the end-user. This section describes how to configure a task response.

The following illustration shows an example the Task Response page.

Defining a Response Object

To define a response object for a task, there are four basic sections:

  • Post Title -You must define the Post Title of the message to display when the response object collects the data received from the task in Kore. The message is displayed as a topic post for the end-user, and defined usually, as a well-formed HTML message that contains one or more variables, such as the ID number or subject, from the request object data.
  • Post Description - The Post Description contains the body content of the data from the request object in the task displayed to the end-user. The description is defined as a well-formed HTML message that may contain one or more dynamic variables to display the content of the status or completion of the task.
  • Title Keyword - Inserts a formatted string preceding the Post Description, for example, if you use New Ticket for the Title Keyword field, it is displayed before the Post Description as highlighted in the following illustration.
  • Additional Information - For some tasks, you may want to display data to the end-user as a link that can display the payload response using a template, such as a table, contact card, or formatted for a specific message type such as a weather report. Use Additional Information when the payload data contains a large amount of data, for example, a list of contacts, that the end-user can request on-demand using the link.

Defining the Post Title and Description

In Kore, task messages are delivered and displayed on the Bots Tasks tab on the Messages page as shown in the following illustration.

In the previous illustration for the Twitter Follow task, the message displayed is defined using the Post Title and Post Description fields in the response object editor.

Using the Response Object Editor

The Response Object editor has three interrelated tabs that you can use to define your response object for your task. 

The Normal tab is used to formulate the message notification displayed in the end-user interface using basic editor controls and HTML. You can enter text, and then format the text using the formatting buttons for bold, italics, and underline. In the Select any key drop-down list, you can choose to insert variables parsed from the Sample Response field defined in the request object, or any variables declared on the Java Script tab as shown in the following illustration for the prefix, link, and action variables added on the Normal tab.

To add a variable, place the cursor where you want to add the response key or variable, and the in the select any key drop-down list, select the object that you want to add as shown in the following illustration.

On the Java Script tab, you can add code to handle the end-user message notification, declare variables, and interact with third-party applications.

For the task described in the previous illustration, the following JavaScript is added to the Java Script tab to define four variables, and to verify updates.

var linkLabel = Id;
if (Name)
   linkLabel = Name;
var link = '<a href="https://login.salesforce.com/' + Id + '" target="_blank">' + linkLabel + '</a>';

var prefix = 'New Opportunity';
var action = 'created';

if (CreatedDate !== LastModifiedDate) {
   prefix = 'Opportunity';
   action = 'updated';
}

By combining the objects defined on the Java Script tab, with the static text and variables added on the Normal tab, you can create the title of the post to, for example, contain a link from the message notification in the Kore application directly back to the web application.

On the Preview tab, you can view a sample of the rendered output message that is displayed to the end-user for the Sample Response data you added in the request object, as shown in the following illustration for a Post Title.

Examples

The following examples show response objects using Java Script to define the Post Title and Post Description sections that display output messages to the end-user when the task notification message is sent.

In the following example, the variable labeled desc is only displayed if the value for caption is defined in the JSON response. 

var desc = (caption !== "undefined" ? caption : "")

In the next example, a clickable URL using the task title is displayed in the notification message.

var tasklink = '<a href="https://www.wunderlist.com/webapp#/tasks/' + id + '" target="_blank">' + title + '</a>';

In this last example, the link variable depends on the type, either video or photo. Based on the type, the proper link is displayed.

var link = "";
  switch (type) {
    case "video":
      var video = (typeof(video_url) != "undefined") ? video_url : permalink_url;
      link = '<video controls><source src ="' + video + '" type="video/mp4"></video>';
      break;
    case "photo":
      link = '<img src="' + image_permalink + '"></img>';
      break;
}

You can create custom script to handle task-specific requirements on the Java Script tab in the response object for the task.

Adding Additional Information

You can add a link to a task response message post to display additional information about the post, for example, a list of user accounts, calendar event list, extended weather forecasts, and so forth. By providing a link, you can minimize the message post size and dynamically enable the user to request more information when needed.

To create the report, you need to map fields from the payload response into a template as a table, contact card, or weather report.

To add additional information

Click the Add Additional Information  icon to display the configuration parameters for adding a link to a report as part of the end-user response as shown in the following illustration.

 Define the following parameters for the additional information:

  • Link Title - The link text displayed to the end-user in the task post.
  • Header - The title displayed when the report is displayed to the end-user.
  • Details - End-user help information displayed directly below the Header in the report that describes the content of the report.
  • Template - Select one of the following format templates to display the data from the task response. For each type, define the Column Name, Key Mapping, Data Type, and template specific options.
    • Table - Data is presented in a table format with defined columns. Each mapping for the Table template can be set to Is Sortable, Display as an image, and Display it as a link.
    • Fixed Column Table - Data is presented in a table format with the one or more columns fixed. Each mapping for the Fixed Column Table template can be set to Is Sortable, Column in fixedDisplay as an image, and Display it as a link.
    • Card Layout - Data is presented in a contact card format. Each mapping for the Card Layout template can be set to Is Sortable, Display as an image, and Display it as a link.
    • Weather Info - Date for a weather service response payload can be defined. Each mapping for the Weather Info template can be set to Is Sortable, Display as an image, and Display it as a link.

Next Steps

After the response object is configured to display the message data for the end-user, you should consider defining task-specific error messages in the event a task fails or is denied. For more information, see Error Messages for Tasks.

Comments