Twilio语音收集未按预期工作。我究竟做错了什么?

时间:2019-07-08 22:59:53

标签: node.js twilio

使用Node.js,我已经设法使DMTF正常工作,但是现在我必须实际收集声音,并且它没有按我预期的那样工作,所以我显然做错了。这是我的两个功能:

exports.testSpeech = functions.https.onRequest(async(req,res)=>{
  const twiml = new VoiceResponse()
  const gather = twiml.gather({
    'voice':'alice',
    'language':'en-US',
    'input':'dmtf speech',
    'finishOnKey':'#',
    'speechTimeout':15,
    'speechModel':'phone_call',
    'action':'testSpeechResults'
  })
  gather.say('Hi. tell me something I don\'t know.')
  console.log(twiml.toString())
  res.status(200).send(twiml.toString())
  return null
})
exports.testSpeechResults = functions.https.onRequest(async(req,res)=>{
  console.log('This is my response:',JSON.stringify(req.body))
  const twiml = new VoiceResponse()
  twiml.say({
    'voice':'alice',
    'language':'en-US'
  },'Sorry, I alrady knew that. Goodbye')
  twiml.hangup()
  res.status(200).send(twiml.toString())
  return null
})
exports.twilioStatusChange = functions.https.onRequest(async(req,res)=>{
  const twiml = new VoiceResponse();
  const from_phone = TEST_PHONE !== '' ? TEST_PHONE : req.body.From
  console.log('twilioStatusChange',from_phone)
  console.log(JSON.stringify(req.body))
  res.status(200).send({})
})

我的日志显示testSPeech被命中,但是在我说了几句并按#键之后,我将其转储到了我期望的testWildsWebhook中,而不是将其转储到了twilioStatusChange Webhook中。这是testSpeech函数末尾的twiml.toString的输出:

<?xml version="1.0" encoding="UTF-8"?><Response><Gather voice="alice" language="en-US" input="dmtf speech" finishOnKey="#" speechTimeout="15" speechModel="phone_call" action="testSpeechResults"><Say>Hi. tell me something I don't know.</Say></Gather></Response>

没有记录错误。

1 个答案:

答案 0 :(得分:0)

聚集不是我需要的正确动词。做我期望的记录