Twilio 我如何让twiml.say与我';我拨了

Twilio 我如何让twiml.say与我';我拨了,twilio,Twilio,我有一个功能,应该与911调度员通话,但在“调度员”挂断电话之前什么也不说。如何让twiml.say在拨号后立即发生 exports.handler = function(context, event, callback) { let twiml = new Twilio.twiml.VoiceResponse(); // Wrap the phone number or client name in the appropriate TwiML verb //

我有一个功能,应该与911调度员通话,但在“调度员”挂断电话之前什么也不说。如何让twiml.say在拨号后立即发生

exports.handler = function(context, event, callback) {
    let twiml = new Twilio.twiml.VoiceResponse();

      // Wrap the phone number or client name in the appropriate TwiML verb
      // if is a valid phone number
      const attr = isAValidPhoneNumber(event.To) ? 'number' : 'client';
var got = require('got');

console.log('from', event.From.slice(7))
got('https://911callbot.com/api/get_incident?date_code_and_code='+event.From.slice(7), {'json': true})
  .then(function(response) {
   const dial = twiml.dial({
        callerId: context.CALLER_ID,
        record: 'record-from-ringing-dual'
      });
      console.log('RESPONSE', response.body)
      console.log('test', response.body.code)
      response_body = response.body
      dial[attr]({}, event.To);
      code = response_body[0] + ' ' + response_body[1] + ' ' + response_body[2] + ' ' + response_body[3]
      msg = 'This is 911callbot.com again 911callbot.com the incident code is '+response_body['code']+' again the incident code is '+code+' the address is '+response_body['address']+' again the address is '+response_body['address']+' caller is reporting '+response_body['what_reporting'];
      console.log(msg)
      twiml.say(msg);
      callback(null, twiml)
    })
};

/**
* Checks if the given value is valid as phone number
* @param {Number|String} number
* @return {Boolean}
*/
function isAValidPhoneNumber(number) {
  return /^[\d\+\-\(\) ]+$/.test(number);
}

这里是Twilio开发者福音传道者

要让Twilio立即开始读出a,首先需要将它添加到
语音应答中

这是您当前回调的核心:

  const dial = twiml.dial({
    callerId: context.CALLER_ID,
    record: 'record-from-ringing-dual'
  });
  console.log('RESPONSE', response.body)
  console.log('test', response.body.code)
  response_body = response.body
  dial[attr]({}, event.To);
  code = response_body[0] + ' ' + response_body[1] + ' ' + response_body[2] + ' ' + response_body[3]
  msg = 'This is 911callbot.com again 911callbot.com the incident code is '+response_body['code']+' again the incident code is '+code+' the address is '+response_body['address']+' again the address is '+response_body['address']+' caller is reporting '+response_body['what_reporting'];
  console.log(msg)
  twiml.say(msg);
  callback(null, twiml)
你想换个位置,这样你就可以叫‘twiml’了

  code = response_body[0] + ' ' + response_body[1] + ' ' + response_body[2] + ' ' + response_body[3]
  msg = 'This is 911callbot.com again 911callbot.com the incident code is '+response_body['code']+' again the incident code is '+code+' the address is '+response_body['address']+' again the address is '+response_body['address']+' caller is reporting '+response_body['what_reporting'];
  console.log(msg)
  twiml.say(msg);
  const dial = twiml.dial({
    callerId: context.CALLER_ID,
    record: 'record-from-ringing-dual'
  });
  console.log('RESPONSE', response.body)
  console.log('test', response.body.code)
  response_body = response.body
  dial[attr]({}, event.To);
  callback(null, twiml);

这会对两个打电话的人都说吗?如何在911接听时与两位呼叫者通话?通过webrtc“呼叫”911的人我先拨打911,然后在911接听时想说出911呼叫者的信息这不会向两位呼叫者都传达信息不。现在这样做有点尴尬。您需要将此初始呼叫设置为会议呼叫,然后,在两位参与者都加入后,作为第三方呼叫,并连接到显示消息的脚本。不过,我会对这种方法持谨慎态度,因为你可能会拨打911,让代理在对方听到任何消息之前等待对方联系,这可能是在浪费他们的时间。