Skip to main content

Call transfer to agent

Use $response.replies with the switch type or the TransferCallToOperator action tag to transfer a call to an agent.

Syntax

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: "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.
});

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": "79123456789",
"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":"79123456789"}
17:14:40.482 [main] INFO js - {"status":"FAIL","hangup":true,"number":"79123456789"}

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": "79123456789",
"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.
caution
Note that the SIP trunks of the Beeline provider do not allow the use of these settings. Therefore, the display of the actual customer number is not available for them.