语音通话返回对象缺少 dateCreated 值

问题描述 投票:0回答:1

我正在制作一个express/nodejs应用程序,在数据库触发器之后进行多次调用以通知发生了特殊情况。使用 Twilio for NodeJS 进行调用。调用后,返回的对象有几个属性为空值,包括

dateCreated
dateUpdated
,这是我需要的。

拨打电话代码:

MyModule.makeCall = async (datos) => {
    try {
        callData = await client.calls.create({
            twiml: "<Response> " +
                "<Say>Blablabla.</Say>" +
                '<Pause length="1"/>' +
                '<Gather input="dtmf" timeout="15" numDigits="1" action="my_webhook_url" method="POST">'+
                "<Say>More Blablabla.</Say>" +
                "</Gather>"+
                "</Response>",
            to: datos.toNumber,
            from: datos.fromNumber
        }); 
        return callData;
    } catch (error) {
        ...
    }
}

这是我从通话中得到的对象:

{
  sid: 'XXXXX',
  dateCreated: null,
  dateUpdated: null,
  parentCallSid: null,
  accountSid: 'YYYYY',
  to: '+98765432109',
  toFormatted: '+98765432109',
  from: '+12345678901',
  fromFormatted: '(123) 456-7890',
  phoneNumberSid: 'ZZZZ',
  status: 'queued',
  startTime: null,
  endTime: null,
  duration: null,
  price: null,
  priceUnit: 'USD',
  direction: 'outbound-api',
  answeredBy: null,
  apiVersion: '2010-04-01',
  forwardedFrom: null,
  groupSid: null,
  callerName: null,
  queueTime: '0',
  trunkSid: null,
  uri: '/2010-04-01/Accounts/YYYYY/Calls/XXXXX.json',
  subresourceUris: {
    feedback: '/2010-04-01/Accounts/YYYYY/Calls/XXXXX/Feedback.json',
    user_defined_messages: '/2010-04-01/Accounts/YYYYY/Calls/XXXXX/UserDefinedMessages.json',
    notifications: '/2010-04-01/Accounts/YYYYY/Calls/XXXXX/Notifications.json',
    recordings: '/2010-04-01/Accounts/YYYYY/Calls/XXXXX/Recordings.json',
    streams: '/2010-04-01/Accounts/YYYYY/Calls/XXXXX/Streams.json',
    payments: '/2010-04-01/Accounts/YYYYY/Calls/XXXXX/Payments.json',
    user_defined_message_subscriptions: '/2010-04-01/Accounts/YYYYY/Calls/XXXXX/UserDefinedMessageSubscriptions.json',
    siprec: '/2010-04-01/Accounts/YYYYY/Calls/XXXXX/Siprec.json',
    events: '/2010-04-01/Accounts/YYYYY/Calls/XXXXX/Events.json',
    feedback_summaries: '/2010-04-01/Accounts/YYYYY/Calls/FeedbackSummary.json'
} 

如果使用测试凭据进行测试调用,返回的对象将填充这些属性,同时保持相同的调用状态 (

queued
)。我认为至少
dateCreated
会反映我在 Twilio 系统上拨打电话的那一刻,但我得到的是空值。我尝试过使用“呼叫状态更改”选项,将其链接到回调 Webhook,但我的方法从未被调用过。

调用

client.calls.create()
方法时是否可以检索 dateCreated ?我是否在这里遗漏了一些关于
dateCreated
、通话状态或通话状态更改的信息?

谢谢你。

编辑:我在文档(here)中读到,呼叫状态回调仅在呼叫结束后调用,这解释了为什么我在呼叫正在进行时没有收到任何请求,但我没有'我为此目的配置的 webhook 中没有收到任何请求。我想我还缺少其他东西。另外,如果投反对票,我会很高兴地解释我在这个问题上做错了什么。

node.js twilio twilio-api
1个回答
0
投票

我会检查你的序列化器。在反序列化(也称为原始)之前查看从 Twilio 返回的 json 有效负载。看来你有很多空值。也许您的序列化程序期望的情况与响应负载中提供的情况不同并跳过它?

此页面显示了有效负载应是什么样子:https://www.twilio.com/docs/voice/make-calls?code-sample=code-make-an-outbound-call-to-a-phone-数字&代码语言=Node.js&代码sdk-版本=4.x

© www.soinside.com 2019 - 2024. All rights reserved.