Call transfer to agent
Use $response.replies
with the switch
type
or the TransferCallToOperator
action tag to transfer a call to an agent.
Syntax
- switch reply type
- TransferCallToOperator action tag
state: TransferToAgent
intent!: /TransferToAgent
random:
a: Transferring you to the 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: "16123456789", // The phone number the call will be transferred to.
// You can send a SIP URI (SIP number) instead of a phone number:
// sipUri: "16123456789@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.
});
state: TransferToAgent
intent!: /TransferToAgent
random:
a: Transferring you to the agent. Please stay on the line.
a: Putting you through to an agent. Please stay on the line.
TransferCallToOperator:
phoneNumber = 16123456789
timeout = 30
timeoutState = /Switch/Timeout
errorState = /Switch/Error
state: Timeout
a: Unfortunately, all our agents are busy at the moment. Is there anything I can help you with?
state: Error
a: Unfortunately, we cannot connect you with an agent. We’ll be sure to get back to you soon.
script:
$dialer.hangUp();
Agent transfer status
Use the $dialer.getTransferStatus
method to monitor the status of the call transfer to an agent.
For example:
theme: /
state: Start
q!: $regex</start>
a: Hi! How can I help?
state: Switch
q!: transfer to agent
script:
$response.replies = $response.replies || [];
$response.replies.push({
"type": "switch",
"phoneNumber": "16123456789",
"continueCall": true,
"continueRecording": true
});
state: TransferEvent
event: transfer
script:
var status = $dialer.getTransferStatus();
log(status);
An entry in the following format will be added to the log:
17:14:40.459 [main] INFO js - {"status":"SUCCESS","hangup":false,"number":"16123456789"}
17:14:40.482 [main] INFO js - {"status":"FAIL","hangup":true,"number":"16123456789"}
Agent is unavailable
If the transfer to an agent failed (e.g. the transfer number is busy), the customer may be re-directed back to the bot.
To do so, specify continueCall: true
in $response.replies
and monitor event: transfer
in your script.
For example:
theme: /
state: Start
q!: $regex</start>
a: Hi! How can I help?
state: Switch
q!: transfer to agent
script:
$response.replies = $response.replies || [];
$response.replies.push({
"type": "switch",
"phoneNumber": "16123456789",
"continueCall": true,
"continueRecording": true
});
state: TransferEvent
event: transfer
if: $dialer.getTransferStatus().status === 'FAIL'
a: All our agents are currently busy. We will reach out to you later.
else:
a: Thank you for contacting us. Please rate our service.
Note that the customer will be returned to the state where the event: transfer
event is monitored. Here you can add bot replies or reactions.
Phone number display
When transferring a call to an agent, you can configure the display of the actual customer number, instead of the bot number. To do this, you need to create a telephone connection and configure a SIP trunk without registration and password:
- go to SIP server connection on the side left tab > Add new connection;
- in the Main settings > Password leave the field blank;
- in the Extended settings > Registration is required leave the switch inactive;
- follow the instructions to fill in the rest of the fields.