Attach Chatbot

Attach the same interaction scope of a chatbot to new interactions created from a new script.

Starting from IBM RPA 23.0.3, support for Interactive Voice Response (IVR) is removed from this command due to the removal of IVR. For more information, see Removed.

Command availability: IBM RPA SaaS and IBM RPA on premises

Script syntax

IBM RPA's proprietary script language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in IBM RPA Studio's Script mode.

botAttach [--chat(ChatData)] [--ivr(IvrData)]

Dependencies

  • Use the Connect to Chatbot command to connect to the chatbot.
  • The Attach Chatbot command must be inside the Connect to Chatbot scope.

Input parameters

The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in IBM RPA Studio's Script mode and its Designer mode equivalent label.

Designer mode label Script mode name Required Accepted variable types Description
Chatbot chat Optional Chat Data Connection variable to a chatbot, which can be obtained from the Chat output parameter of the Connect to Chatbot command. The Chat Data is used to make the scope attachment between one script to another.
IVR ivr Optional IVR Data Connection variable to an IVR, which can be obtained from the Ivr output parameter of the Connect to Chatbot command. The IVR Data is used to make the scope attachment between one script to another.

Starting from IBM RPA 23.0.3, this parameter is removed.

Example

The Attach Chatbot command is used in the "Secondary Script" to call the same interaction context started by the Connect to Chatbot command in the "Main Script".

Main Script:

After starting a connection to a Chatbot using the Connect to Chatbot command, which returns the chatbot data in the variable "mainConnection", the bot will utter a greeting and then the Execute Script command is used to receive the path to the "Secondary Script" that should be executed, while also passing the value of the variables "mainConnection" and "enUSLanguage" to the variables "mainChatAttach" and "enUSLanguage", respectively, declared in the "Secondary Script".

defVar --name language --type Language
defVar --name mainConnection --type ChatData
createLanguage --culture "en-US" language=value
botConnect --type "Chat" --language ${language} --autoanswer  --timeout "00:01:00" mainConnection=chat
	botSay --text "Hello, you are in the main script and will soon be transfered to another script, however, we will remain in the same interaction context, that is, in the same chat connection." --textformat "0"
	// The command "Execute Script" is used to pass the value of the variable "mainConnection", obtained from, the return of "Bot Connect", to the variable "mainChatAttach" in the secondary script. In this way, the connection data with the Chatbot will be accessed by the "Bot Attach" command in the secondary script.
	executeScript --name "Full path to the secondary script file" --parameters "mainChatAttach=${mainConnection},${language}=${language}"
botDisconnect

Secondary Script:

The variables "mainChatAttach" and "enUSLanguage" were created manually, enabling the option "Is a parameter", so that they can be used in the Execute Script command to receive the values ​​of the variables "mainConnection" and "enUSLanguage", declared in the "Main Script". Thus, when using the Attach Chatbot command, it is possible to continue the bot's interaction with the user in the same context started by the Connect to Chatbot command in the "Main Script".

defVar --name mainChatAttach --type ChatData --parameter
defVar --name language --type Language --parameter
defVar --name userAnswer --type String
botAttach --chat ${mainChatAttach}
botAskName --beep  --language ${language} --text "Could you please tell me your name?" --textformat "Markdown" --timeout "00:01:00" userAnswer=first
botSay --language ${language} --text "${userAnswer}, you are in another script, but note that the context of our interaction remains the same!" --textformat "Markdown"
botSay --language ${language} --text "See you later, ${userAnswer}!" --textformat "Markdown"
delay --timeout "00:00:03"
Note:The "Secondary Script" must be saved on the same machine as the one executing the "Main Script", so that the full path of its location can be inserted in the Filename parameter of the Execute Script command, used in the "Main Script".