收集动词的行为,例如说,在说话/动作URL有效后挂断电话

时间:2018-12-15 20:01:35

标签: twilio-api

我不知所措,因为我看不到Twilio无法正确处理此问题的任何原因,而且我尝试着像疯了一样对其进行微调。它返回Twilio ...实际上可能是问题..但是由于语音响应的序列化是一个问题,我必须将它作为字符串发送回控制器,然后再从控制器发送回twilio ...

这是XML:

    <?xml version="1.0" encoding="utf-8"?>
<Response>
  <Gather action="http://xxxx.ngrok.io/api/Voice/CallService" method="POST" numDigits="1">
    <Say voice="Polly.Carmen"></Say>
    <Say>blah, blah, blah</Say>
    <Say>Please press 0 followed by the pound sign</Say>
    <Pause length="5"></Pause>
  </Gather>
  <Say>We didn't receive any input. Goodbye!</Say>
</Response>

我使用C#库通过以下代码生成XML:

var response = new VoiceResponse();
      var callServices = new Uri(xxxxConfiguration.GetConfigurations[EnvironmentVariables.xxxxCallServices]);

      var gather = new Gather(
                              action: callServices,
                              method: Twilio.Http.HttpMethod.Post,
                              numDigits: 1
                              );

      gather
        .Say(voice: Say.VoiceEnum.PollyCarmen)
        .Say("blah, blah, blah")
        .Say("Please press 0 followed by the pound sign")
        ;

      response.Append(gather); //if gathered, the post occurs in the gather..otherwise it falls through to this final comment
      response.Say("We didn't receive any input. Goodbye!");

      return response.ToString();

1 个答案:

答案 0 :(得分:0)

Twilio没有响应,因为响应使用的是text / plain的内容类型。我使用的C#Sdk返回类型为:new TwiMLResult(“ XML作为字符串传递”);