Resources for the "Putting the user on hold in chatbot" tutorial

Get the complete script developed in the "Putting the user on hold in chatbot" tutorial.

Before you begin

To run the script, you need:

  • Use the Script tab in IBM RPA Studio


Copy and paste the script in the IBM RPA Studio:

defVar --name cultureEnUS --type Language
defVar --name userName --type String
defVar --name userResponse --type String
defVar --name urlFound --type Boolean
defVar --name nameInstance --type String --value "browser-instance"
defVar --name titleSite --type String
createLanguage --culture "en-US" cultureEnUS=value
botConnect --type "Chat" --language ${cultureEnUS} --timeout "00:05:00"
	botAskName --text "Hello, my name is Sofia, and I will be your virtual assistant. First, what is your name?" --timeout "00:02:00" userName=first
	botAsk --beep  --text "${userName}, please enter a valid URL for the site you want to browse in." --timeout "00:02:00" userResponse=value
	while --left "${urlFound}" --operator "Is_True" --negate
		isMatch --text "${userResponse}" --regexPattern "^(http:\\/\\/www\\.|https:\\/\\/www\\.|http:\\/\\/|https:\\/\\/)?[a-z0-9]+([\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,5}(:[0-9]{1,5})?(\\/.*)?$" --regexOptions "IgnoreCase" urlFound=value
		if --left "${urlFound}" --operator "Is_True" --negate
			botAsk --text "${userName}, we did not find the URL entered. Could you re-enter a valid URL, please?" --timeout "00:02:00" userResponse=value
	botStartOnHold --message "Wait until navigation is complete."
		webStart --name "${nameInstance}" --type "Chrome"
		webNavigate --url "${userResponse}"
		webGet --selector "CssSelector" --css "head > title" titleSite=value
		webClose --name "${nameInstance}"
	botSay --text "${userName}, the site name is \'${titleSite}.\' Thank you for contacting us, see you soon!"
	delay --timeout "00:00:05"