将 Twilio 出站呼叫连接到 Watson Assistant

Connect Twilio Outbound call to Watson Assistant

我正在尝试使用 Twilio 的 API 进行出站呼叫,并将我正在呼叫的号码连接到我的 Watson Voice Agent(已链接到我的 Watson Assistant)。我可以呼叫 phone,但呼叫不会重定向到助手。

我正在为 java 使用 Twilio API。我已将我的 Twilio 号码的 SIP 中继设置为使用我的语音代理的 SIP

这是方法实现

public String callPhone(String to, String from)throws URISyntaxException{
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

        Call call = Call.creator(

                new com.twilio.type.PhoneNumber(to),
                new com.twilio.type.PhoneNumber(from),
                new URI("http://www.example.com/sipdial.xml"))
                .create();

        return call.getSid();

这是我的电话:

tw.callPhone(phoneIWantToCall,TwilioPhoneNumber);
tw.callPhone("sip:TwilioPhoneNumber@us-south.voiceagent.cloud.ibm.com",TwilioPhoneNumber);

我接到了来自我的 Twilio 号码的电话,但没有转到我的智能助理

这里是 Twilio 开发人员布道者。

这里的问题是您正在创建两个未连接的单独呼叫。

您需要 return TwiML from the URI in your URI parameter that connects the call to the person to the Watson agent. So you should set the URI in your callPhone method to a URL in your own application. And that URI should return TwiML that includes <Dial> to connect to the agent in this case using <Sip>.

而不是使用 REST API 生成两个调用

TwiML 应该看起来像这样:

<Response>
  <Dial>
    <Sip>sip:TwilioPhoneNumber@us-south.voiceagent.cloud.ibm.com</Sip>
  </Dial>
</Response>

如果有帮助请告诉我。