Customizing the chatbot actions
You can customize BMC Helix Chatbot to invoke custom actions in a dialog.
To use custom processes and actions in BMC Helix Chatbot
You can use custom processes and actions in BMC Helix Chatbot. The custom processes are created in the Process designer of BMC Helix Innovation Studio. For more information about creating custom processes, see Defining the application business logic through processes in the BMC Helix Platform online documentation.
The custom actions are created in Angular JavaScript service.
After creating the processes and actions, you can invoke the custom processes and actions from a dialog in IBM Watson Assistant Skills. For more information, see Creating custom actions in BMC Helix Platform online documentation.
To view examples of the JSON code of dialog response with chat actions, see Example JSON of BMC Chatbot dialog responses.
Example JSON of BMC Helix Chatbot dialog responses
To enable BMC Helix Chatbot to interact with your users, you must build a dialog in the IBM Watson Assistant Skills. Based on the conversation, IBM Watson sends an action to your application that needs to be performed on the behalf of the user. In the Skills dialog, you can define these actions to call the processes or actions that you have created.
See the following JSON code samples:
- Creating a service request
- Output map
- Searching for a knowledge article
- Getting the status of the service request
- Publishing an event in a chat dialog
Creating a service request
After an employee provides all the details to create a service request, for example, a time-off-request, BMC Helix Chatbot uses these details to create a service request. The following JSON illustrates the dialog response that contains a chat action to create a service request:
"output": {
"text": {
"values": [
""
],
"selection_policy": "sequential"
},
"action": {
"inputMap": {
"536870920": "trigger",
"536870921": "sb_apply_pto",
"536870922": "$loginName",
"536870923": {
"6491c1f4-5dc7-0887-b8b2-6b11284a49fd": "$startDate",
"ab9a845c-0e69-2929-8a25-66a5a319a539": "$vacationType",
"ef1145f2-2730-d43b-706e-d25b812ef041": "$endDate",
"f4036404-f6cb-9173-6bb1-007296a27463": "$userQuestion"
}
},
"outputMap": {
"status": "${actionResult.536870910}",
"requestId": "${actionResult.536870911}"
“description”: “${actionResult.<description field id>}”
},
"processDefinitionName": "com.bmc.dsm.chatbot:Create Service Request",
"waitForActionExecution": true
}
}
}
The following table explains the inputs provided in the action block for creating a service request:
Field ID | Input text | Description |
---|---|---|
536870920 | trigger | Defines the action status. |
536870921 | sb_apply_pto | Specifies the name of the action. Ensure that the name matches to the Service Request Name specified in the BMC Helix Business Workflows Catalog. |
536870922 | $loginName | Specifies the login name of the user. |
536870923 | "6491c1f4-5dc7-0887-b8b2-6b11284a49fd": "$startDate" "ab9a845c-0e69-2929-8a25-66a5a319a539": "$vacationType" "ef1145f2-2730-d43b-706e-d25b812ef041": "$endDate" "f4036404-f6cb-9173-6bb1-007296a27463": "$userQuestion" | Specifies the vacation start date. Specifies the vacation type. For example, paid vacation. Specifies the vacation end date. |
Output map
The following table explains the outputs provided:
Field ID | Output | Description |
---|---|---|
536870910 | Status | Specifies the status of the service request. |
536870911 | Request Id | Specifies the ID of the service request. |
<Description field ID> | Description | Specifies the description of the service request. Ensure that the Field Id exists and the content in the field ID placeholder is not blank. |
In a service request, when the process in the output action map is executed, the process result is embedded in the user message and sent to the user. If you want to return a process result to Watson for validation or conditional child dialog execution, you must use "waitForActionExecution": true in the output action map.
Searching for a knowledge article
If there are any knowledge articles related to a request from a user, you can enable BMC Helix Chatbot to return a list of related knowledge articles. The following JSON illustrates the dialog response that contains a chat action to search for knowledge articles:
"output": {
"text": {
"values": [
"I found the following knowledge articles relating to your issue.${actionResult.536870911} Is this helpful?"
]
},
"action": {
"inputMap": {
"536870920": "<?input.text?>”,
"536870921": "0”,
"536870922": “3”
},
"outputMap": {
"status": "${actionResult.536870910}”,
"results": "${actionResult.536870911}”
},
"processDefinitionName": "com.bmc.dsm.chatbot:Search Knowledge"
},
"result": "${actionResult.536870911}",
"status": "${actionResult.536870910}"
}
}
The following table explains the inputs provided in the action block for retrieving the knowledge articles:
Field | Input text | Description |
---|---|---|
536870920 | <?input.text?> | Specifies the text that has to be searched. |
536870921 | 0 | Specifies the beginning of the search index. |
536870922 | 3 | Specifies the maximum number of knowledge articles that should be returned. |
results | ${actionResult.536870911} | Returns a JSON string with the related knowledge article details. |
Getting the status of the service request
After creating a service request based on the details provided by the user, BMC Helix Chatbot returns the status of the service request.
For example, for time-off request, BMC Helix Chatbot creates a new service request and returns the service request ID to the user.
The following JSON illustrates the dialog response that contains a chat action to get the status of your request:
"output": {
"text": {
"values": [
"Your requests ${actionResult.536870911}"
]
},
"action": {
"inputMap": {
"536870920": "trigger",
"536870922": “$loginName",
"536870923": "4”,
"536870924": [
“@entities.values”
]
},
"outputMap": {
"status": "${actionResult.536870910}",
"seachResult": "${actionResult.536870911}"
},
"processDefinitionName": "com.bmc.dsm.chatbot:Get Request Status"
}
}
}
The following table explains the inputs provided in the action block for receiving the status of the service request:
Field | Input text | Description |
---|---|---|
536870920 | trigger | Defines the action status. |
536870922 | $loginName | Specifies the login name of the user. |
536870923 | 4 | Specifies the maximum number of service requests to show for the user. |
Publishing an event in a chat dialog
If you are tracking an event to derive the chatbot usage metrics, you must publish the event details in the dialog in the IBM Watson Assistant Skills. The following JSON illustrates the dialog that contains the publish event action:
"output":{
"text":{
"values":[
"event created"
],
"selection_policy":"sequential"
},
"action":{
"inputMap":{
"values":{
"BotId":"BotId",
"BotName":"Admin",
"Channel":"SMS",
"UserName":"Hannah",
"ServiceName":"Knowledge"
},
"eventDefinitionName":"com.bmc.dsm.chatbot:ServiceRequest"
},
"actionTypeName":"publishEvent",
"waitForActionExecution":true
}
}
}
The input variables in the JSON change for each event. The following variables are available from chatbot:
Variable name | Description |
---|---|
chatbot_channel | To set the channel |
chatbot_id | To set the chatbot id |
chatbot_name | To set the chatbot name |
Related topics
Importing-chat-enabled-services-from-BMC-Helix-Digital-Workplace-Advanced
Integrating-BMC-Helix-Chatbot-with-other-applications