Nexmo Voice API - 连接两个用户并为每个用户播放不同的通话动作
Nexmo Voice API - connect two users and play a different talk action to each user
我正在使用 POST https://api.nexmo.com/v1/calls/
.
向客户拨打电话
我将这个 NCCO 传递给客户播放谈话 Hello customer, please wait while we connect you
并连接到销售人员 (SALESPERSON_PHONE_NUMBER)。
我想做的是只在销售人员回答时与他们进行不同的谈话,比如 outbound call to customer for Example Company
[
{
"action": "talk",
"text": "Hello customer, please wait while we connect you."
},
{
"action": "connect",
"timeout": 20,
"from": "MY_NEXMO_PHONE_NUMBER",
"endpoint": [
{
"type": "phone",
"number": "SALESPERSON_PHONE_NUMBER"
}
]
}
]
如何只对销售人员播放不同的通话信息?我在文档中看不到任何内容。
您似乎想在 connect
操作中使用 onAnswer
功能
https://developer.nexmo.com/voice/voice-api/ncco-reference#connect
A JSON object containing a required url key. The URL serves an NCCO to execute in the number being connected to, before that call is joined to your existing conversation.
[
{
"action": "talk",
"text": "Hello customer, please wait while we connect you."
},
{
"action": "connect",
"timeout": 20,
"from": "MY_NEXMO_PHONE_NUMBER",
"endpoint": [
{
"type": "phone",
"number": "SALESPERSON_PHONE_NUMBER",
"onAnswer": {"url": "https://example.com/my-on-answer-ncco"}
}
]
}
]
然后在 https://example.com/my-on-answer-ncco,你 return 一个包含 talk
动作的 NCCO
connect
NCCO 操作有一个 onAnswer
选项。来自文档:
onAnswer - A JSON object containing a required url key. The URL serves an NCCO to execute in the number being connected to, before that call is joined to your existing conversation. Optionally, the ringbackTone key can be specified with a URL value that points to a ringbackTone to be played back on repeat to the caller, so they do not hear just silence. The ringbackTone will automatically stop playing when the call is fully connected. Example: {"url":"https://example.com/answer", "ringbackTone":"http://example.com/ringbackTone.wav" }. Please note, the key ringback is still supported.
因此,如果您将 NCCO 更改为如下所示,销售人员将在第二个 NCCO 中听到通话动作,而来电者会听到音乐。
[
{
"action": "talk",
"text": "Hello customer, please wait while we connect you."
},
{
"action": "connect",
"timeout": 20,
"from": "MY_NEXMO_PHONE_NUMBER",
"endpoint": [
{
"type": "phone",
"number": "SALESPERSON_PHONE_NUMBER",
"onAnswer": {
"url":"https://example.com/answer",
"ringbackTone":"http://example.com/ringbackTone.wav"
}
}
]
}
]
https://example.com/answer
应该是
[{
"action": "talk",
"text": "Hello salesperson, please wait while we connect you."
}]
我正在使用 POST https://api.nexmo.com/v1/calls/
.
我将这个 NCCO 传递给客户播放谈话 Hello customer, please wait while we connect you
并连接到销售人员 (SALESPERSON_PHONE_NUMBER)。
我想做的是只在销售人员回答时与他们进行不同的谈话,比如 outbound call to customer for Example Company
[
{
"action": "talk",
"text": "Hello customer, please wait while we connect you."
},
{
"action": "connect",
"timeout": 20,
"from": "MY_NEXMO_PHONE_NUMBER",
"endpoint": [
{
"type": "phone",
"number": "SALESPERSON_PHONE_NUMBER"
}
]
}
]
如何只对销售人员播放不同的通话信息?我在文档中看不到任何内容。
您似乎想在 connect
操作中使用 onAnswer
功能
https://developer.nexmo.com/voice/voice-api/ncco-reference#connect
A JSON object containing a required url key. The URL serves an NCCO to execute in the number being connected to, before that call is joined to your existing conversation.
[
{
"action": "talk",
"text": "Hello customer, please wait while we connect you."
},
{
"action": "connect",
"timeout": 20,
"from": "MY_NEXMO_PHONE_NUMBER",
"endpoint": [
{
"type": "phone",
"number": "SALESPERSON_PHONE_NUMBER",
"onAnswer": {"url": "https://example.com/my-on-answer-ncco"}
}
]
}
]
然后在 https://example.com/my-on-answer-ncco,你 return 一个包含 talk
动作的 NCCO
connect
NCCO 操作有一个 onAnswer
选项。来自文档:
onAnswer - A JSON object containing a required url key. The URL serves an NCCO to execute in the number being connected to, before that call is joined to your existing conversation. Optionally, the ringbackTone key can be specified with a URL value that points to a ringbackTone to be played back on repeat to the caller, so they do not hear just silence. The ringbackTone will automatically stop playing when the call is fully connected. Example: {"url":"https://example.com/answer", "ringbackTone":"http://example.com/ringbackTone.wav" }. Please note, the key ringback is still supported.
因此,如果您将 NCCO 更改为如下所示,销售人员将在第二个 NCCO 中听到通话动作,而来电者会听到音乐。
[
{
"action": "talk",
"text": "Hello customer, please wait while we connect you."
},
{
"action": "connect",
"timeout": 20,
"from": "MY_NEXMO_PHONE_NUMBER",
"endpoint": [
{
"type": "phone",
"number": "SALESPERSON_PHONE_NUMBER",
"onAnswer": {
"url":"https://example.com/answer",
"ringbackTone":"http://example.com/ringbackTone.wav"
}
}
]
}
]
https://example.com/answer
应该是
[{
"action": "talk",
"text": "Hello salesperson, please wait while we connect you."
}]