node.js - 未使用 Twilio 节点服务器发起来电(未发送 VoIP 通知) - 已修复
问题描述
我正在尝试通过我的节点服务器在我的移动应用程序(入站呼叫)上发起呼叫。我已经在 env 文件中设置了所有凭据并多次交叉检查它们。我正在使用 Twiml 这样做。我正在向 Twilio 发送下面的 Twiml 响应,但调用只是继续路由回 Webhook URL。如果这不是正确的方法,我如何在设备上路由呼叫。
Twiml 响应:
<Response>
<Dial>
<Number>+12528881526</Number>
</Dial>
</Response>
我的 Node.js 代码
let twimlResponse = new VoiceResponse()
const dial = twimlResponse.dial()
dial.number({}, "+1234567891")
console.log(twimlResponse.toString())
return response.send(twimlResponse.toString())
解决方案: 我们需要使用身份发起呼叫,Twilio 将开始发送 VoIP 通知
let twimlResponse = new VoiceResponse()
const dial = twimlResponse.dial()
dial.client({}, "alice")
console.log(twimlResponse.toString())
return response.send(twimlResponse.toString())
解决方案
我相信您使用的过程是将收到的呼叫重定向到另一个号码“new VoiceResponse()”,我相信您要发起呼叫,您应该使用下面的代码。请让我知道 tha 是否有效。
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = require('twilio')(accountSid, authToken);
client.calls
.create({
twiml: '<Response><Say>Ahoy there!</Say></Response>',
to: '+15558675310',
from: '+15552223214'
})
.then(call => console.log(call.sid));
推荐阅读
- go - 第三方配置结构的封装
- mysql - Windows 10 上的 Perl 到 mysql 连接
- qt - dlsym' collect2:错误:ld 返回 1 退出状态
- javascript - 在 Google Apps 脚本对话框中显示 PDF 查看器
- sql - SQL Server - 根据行数返回不同的值
- java - java中任何形式的日期实现的格式化日期
- r - 使用 gsub 将方括号替换为括号
- matplotlib - 将 Matplotlib 输出保存到 Databricks 上的 DBFS
- javascript - 如何读取每个字符串的最后一个字符?
- javascript - 错误:mergeProps 参数的类型对象值无效