【问题标题】:why twilio is not reading xml from url?为什么 twilio 不从 url 读取 xml?
【发布时间】:2020-09-08 06:30:59
【问题描述】:

这是代码,我希望 twilio 从一个发布路由的路由中读取,但它不会从那里读取 xlm,我想从用户那里获取数字,并在通话期间根据该输入然后我想要流程根据该输入工作。

      .create({
        method: 'POST',
        url: 'https://stormy-everglades-64562.herokuapp.com/voice',
        to: '+923047931504',
        from: '+17207344485'
       })
      .then(call => console.log(call.sid));

   app.post('/voice', (request, response) => {
   // Create TwiML response
   const twiml = new VoiceResponse();

    twiml.gather(
    {
      numDigits: 1,
      action: '/gather',
    },
    gatherNode => {
      gatherNode.say('For sales, press 1. For support, press 2.');
    }
   );

   // If the user doesn't enter input, loop
   twiml.redirect('/voice');

  // Render the response as XML in reply to the webhook request
  response.type('text/xml');
  response.send(twiml.toString());
 });```

【问题讨论】:

    标签: javascript twilio twilio-twiml


    【解决方案1】:

    试试下面的:

      app.post('/voice', (request, response) => {
        // Create TwiML response
        const twiml = new twilio.twiml.VoiceResponse();
     
         const gather = twiml.gather(
         {
           numDigits: 1,
           action: '/gather',
         })
         gather.say('For sales, press 1. For support, press 2.');
      
        // If the user doesn't enter input, loop
        twiml.redirect('/voice');
    
      // res.set('Content-Type','text/xml');
      response.type('text/xml');
      response.send(twiml.toString());
    
      });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-11
      • 1970-01-01
      相关资源
      最近更新 更多