Skip to main content

switch

Use the switch reply type for switching the dialog from the bot to an agent.

tip
You can also switch dialogs and calls to agents using the TransferToOperator and TransferCallToOperator action tags.

Properties

In text channels

For text channels, all properties are optional.

PropertyTypeDescription
firstMessageStringThe message that will be sent to an agent after switching the dialog to them.
The default value is the customer’s last phrase.
lastMessageStringThe message that will be sent to the customer if they ended the dialog with an agent using a command specified in the closeChatPhrases property.
closeChatPhrasesArrayA list of commands. The user can use them to close the chat with an agent and redirect it back to the bot.
When a command is sent, the chat closes. The command gets processed by the bot script in the context of the state where switching took place.
appendCloseChatButtonBooleanIndicates whether to display the button that closes the chat with an agent.
The text of the button is taken from the first element of the closeChatPhrases array.
The customer can stop communicating with an agent and switch the dialog to the bot using this button.
If true is specified when the closeChatPhrases array is empty, the button will not be displayed.
destinationStringThe ID of the agent group the dialog will be routed to.
This property is only used by Aimychat and Operator API.
themeStringThe request subject. It is used for customer request statistics in Aimychat.
sendMessagesToOperatorBooleanIndicates if the customer message history should be sent to an agent.
The default value is false.
sendMessageHistoryAmountNumberThe number of customer messages that will be sent to an agent.
Specify this property only if you have set the sendMessagesToOperator property to true.
attributesObjectInformation about the customer that should be transferred to an agent. Use the following format for the value:
attributes: 
{
"Key 1": "Value 1",
"Key 2": "Value 2"
}
• Key is the name of a field supported the customer engagement platform.
• Value is a piece of information to be sent to an agent when switching the dialog.
This property is only used by the LiveTex customer engagement platform and Operator API.
hiddenAttributesObjectInformation about the customer that should not be transferred to an agent. The value format is the same as for the attributes property.
This property is only used by the LiveTex customer engagement platform and Operator API.
ignoreOfflineBooleanThis property determines further actions if there is no agent available on switching the dialog:
• true — make a forced switch to an agent.
• false — do not make a switch.
The default value is false.
oneTimeMessageBooleanIf true is specified, the dialog will not be switched to an agent. Instead, they will get a message with the text from the firstMessage property. This way they can get information about the customer.
The default value is false.

In phone channel

For the phone channel, you must specify the phoneNumber or sipUri property.

PropertyTypeDescription
phoneNumberStringThe phone number the call will be transferred to.
Transferring to extension phone numbers is not supported.
sipUriStringThe SIP URI the call will be transferred to.
If you pass sipUri, you do not need to pass phoneNumber.
timeoutStringAgent response timeout in seconds. When the timeout expires, the bot will switch to the nearest state that contains the transfer event.
The default value is 60 seconds.
methodStringCall routing method:
invite — call transfer with the connection preserved. This is the default value.
refer — call transfer with the connection terminated. If you use refer, the headers, transferChannel, continueCall, and continueRecording properties will be ignored.
headersObjectSIP headers that will be sent in the SIP INVITE message to the specified phone number.
This feature is usually used to transmit the customer’s caller ID details.
transferChannelStringSpecify botId in the field to route the call over the SIP trunk connected to the channel. The parameters of the enabled SIP trunk will be applied.
continueCallBooleanWhen true, the customer will be redirected back to the bot after the conversation with an agent ends.
When false, the call will be ended.
If an agent is unavailable, the transfer will not happen.
The default value is false.
continueRecordingBooleanWhen true, conversation recording continues, including the conversation with an agent and with the bot after the customer has returned to it. The call recording will be saved to conversation logs.
The default value is false.
tip
When switching a call to an agent, you can:
• Monitor the status of the customer transfer.
• Specify what the script should do if an agent is unavailable.
• Configure the display of the customer phone number.

Syntax

In text channels

state: TransferToAgent
intent!: /TransferToAgent
random:
a: I’m transferring you to an agent.
a: Putting you through to an agent.
script:
$response.replies = $response.replies || [];
$response.replies.push({
"type": "switch", // Bot reply type.
"firstMessage": $jsapi.chatHistory(), // An agent will get the chat history.
"closeChatPhrases": ["/closeChat", "Close dialog"] // Commands that will enable the customer to close the chat with an agent.
});

In phone channel

state: TransferToAgent
intent!: /TransferToAgent
random:
a: Transferring you to an agent. Please stay on the line.
a: Putting you through to an agent. Please stay on the line.
script:
$response.replies = $response.replies || [];
$response.replies.push({
type: "switch", // Bot reply type.
phoneNumber: "79123456789", // The phone number the call will be transferred to.
// You can send a SIP URI (SIP number) instead of a phone number:
// sipUri: "79123456789@sip.voximplant.com",
timeout: "30", // Agent response timeout.
headers: { // SIP headers.
"callReason": "support",
"crmClientId": $client.id || "none"
},
transferChannel: "237-test-237-VDQ-28334674", // botId. The call will be routed over the SIP trunk connected to the channel.
continueCall: true, // Redirect the customer back to the bot after the conversation with the agent.
continueRecording: true // Continue recording the conversation.
});

Channel restrictions

switch is not supported in the following channels:

  • In voice assistants:
    • Alice
    • Marusia
    • Sber Salut
  • Aimybox
  • Zendesk
  • Zendesk Chat (the transfer to an agent can be implemented in another way)

How to use

In text channels

theme: /
state: SwitchSuggestion
random:
a: Shall I put you through to an expert?
a: Should I transfer this chat to an agent?
buttons:
"Yes" -> /Switch
"No" -> /AnythingElse
intent: /Agree || toState = /Switch
intent: /Disagree || toState = /AnythingElse

state: Switch
intent!: /TransferToAgent
random:
a: I'm transferring our chat to an agent.
a: Putting you through to an agent.
script:
$response.replies = $response.replies || [];
$response.replies.push({
type: "switch",
firstMessage: $jsapi.chatHistory(), // An agent will get the chat history.
destination: $injector.operatorGroup, // The dialog will switched to this agent group.
lastMessage: "Thanks for contacting us, hoping to see you back soon!"
});

state: BackToBot
event: livechatFinished
a: Chat with an agent is over. The bot is online again.
go!: /AnythingElse

state: AnythingElse
a: Is there anything else I can do for you?

In phone channel

require: functions.js

theme: /
state: TransferToAgent
intent!: /TransferToAgent
if: isOff() // Call the function that checks whether the customer is calling during business hours or not.
go!: /TransferToAgent/WorkingHours
else:
go!: /TransferToAgent/NotWorkingHours

state: WorkingHours
random:
a: Transferring you to an agent. Please stay on the line.
a: Putting you through to an agent. Please stay on the line.
script:
$response.replies = $response.replies || [];
$response.replies.push({
type: "switch",
phoneNumber: "79123456789",
transferChannel: "237-test-237-VDQ-28334674",
continueCall: true,
continueRecording: true
});

state: TransferError
event: transfer
if: $dialer.getTransferStatus().status === "FAIL"
a: I’m sorry, it is not possible to transfer the call to an expert for technical reasons. Please call back later.
go!: /AnythingElse

state: NotWorkingHours
random:
a: Unfortunately, a transfer to an agent is not possible at this time.
a: I’m sorry, I can’t connect you with an expert right now.
a: Please call back during business hours from nine AM to eight PM on weekdays.
go!: /AnythingElse

state: AnythingElse
a: Is there anything else I can do for you?

state: Goodbye
intent!: /Bye
random:
a: Thanks for contacting us, have a nice day!
a: Thanks for calling, have a good day!
go!: /HangUp

state: HangUp
event!: hangUp
script:
$dialer.hangUp("(The bot hung up)");
$jsapi.stopSession();