通过Inline NCCO进行呼叫的vonage转移无法正常工作
我目前正在与Vonages语音API遇到问题。此问题是在处理通过Inline NCCO转移调用时特别发生的,我正在使用文档中的Python代码片段,您可以找到在这里。当我从摘要中粘贴代码而没有更改的脚本时,呼叫只播放第一个操作并挂断电话,在尝试更新该电话时,我会收到以下错误:
vonage.errors.clienterror:400 api.nexmo.com
我一直在搜索多个小时,但可以' t找到任何有类似问题的人,也可以找到具有此功能的工作实现的人。
我的代码看起来如下:
import vonage
client = vonage.Client(
application_id="<ID>",
private_key=r"private.key",
)
voice = vonage.Voice(client)
response = voice.create_call({
'to': [{'type': 'phone', 'number': "<mynumber>"}],
'from': {'type': 'phone', 'number': "<vonagenumber>"},
"ncco": [
{
"action": "talk",
"text": "This is just a text whilst you tranfer to another NCCO"
}
]
})
response = voice.update_call(
response["uuid"], {
"action": "transfer",
"destination": {
"type": "ncco",
"ncco": [{"action": "talk", "text": "hello world"}]
}
}
)
print(response)
我不知道该错误该怎么办。可悲的是,Vonage没有提供有关如何处理此问题的任何信息,并且该文档仅具有此代码段,该代码段是无法正常工作或至少不完整的。
I am currently having an issue with Vonages Voice API. This issue specifically occurs while handling the transfer of a call via inline ncco, I am using the python code snippet from the documentation, which you can find here. When I paste the code from the snippet with no changes into my script, the call just plays the first action and hangs up, when trying to update that call, I am receiving the following error:
vonage.errors.ClientError: 400 response from api.nexmo.com
I've been searching for multiple hours but can't find anyone with a similar problem nor another person with a working implementation of this feature.
My code looks as follows:
import vonage
client = vonage.Client(
application_id="<ID>",
private_key=r"private.key",
)
voice = vonage.Voice(client)
response = voice.create_call({
'to': [{'type': 'phone', 'number': "<mynumber>"}],
'from': {'type': 'phone', 'number': "<vonagenumber>"},
"ncco": [
{
"action": "talk",
"text": "This is just a text whilst you tranfer to another NCCO"
}
]
})
response = voice.update_call(
response["uuid"], {
"action": "transfer",
"destination": {
"type": "ncco",
"ncco": [{"action": "talk", "text": "hello world"}]
}
}
)
print(response)
I don't know what to do with this error since it isn't defined in vonages documentation but my guess would be that it occurs because the call is already over by the time the script tries to update said call. Sadly vonage doesn't give any information on how to deal with this and the documentation only has this code snippet which is not working or at the very least incomplete.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您有一些比赛状况问题,第一个NCCO,因此可以在转移发生之前结束。如果您只是测试,则可以在第一个NCCO中添加流动操作,以使该呼叫保持活力:
其次,如果您在呼叫后立即致电转移,则可能尚未设置呼叫。您可以在两个呼叫之间添加睡眠来补救此问题。在使用普通呼叫时,您不会真正遇到这些问题。我们将更新Python片段以反映这一点。
You have a few race condition issues, the first NCCO, and therefore call, could end before your transfer happens. If you are just testing you can add a stream action to the first NCCO to keep that call alive:
Secondly, if you call transfer immediately after the call is made, it is possible the call has not been set up yet. You can add a sleep between the two calls to remedy this. You wouldn't really run into these issues when working with normal calls. We will update the python snippet to reflect this.