【问题标题】:Twilio App - Updating Call Resource Ends CallTwilio 应用程序 - 更新通话资源结束通话
【发布时间】:2022-01-19 02:19:02
【问题描述】:

我是一名 Twilio 新手,正在尝试开发一个与自动电话树交互的 C# 应用程序。问题是电话树的开头每次都有些不同,所以我没有尝试自动化所有不同的排列,而是在电话树、应用程序和我的个人电话号码之间创建电话会议。我希望接听我的电话,与树进行交互,直到我到达“可自动化”部分,然后挂断我的电话,让应用程序从那时起与电话会议交互。

到目前为止,我已经能够使用两个 CallResource.Create() 调用成功创建会议。我目前面临的问题是,当我将 CallResource.Update() 与树 Sid 一起使用时,一旦执行 Twiml,它就会挂起该调用资源,我不知道为什么。对我的电话号码的呼叫仍在进行,但无论我向树呼叫资源发送什么 twiml,它都会挂断。

  1. 有关如何在不挂断的情况下使用一些 twiml 更新呼叫的任何帮助
  2. 或者,也许有更好的方法来完成我正在寻找的所有事情?

感谢任何建议!下面是我正在使用的代码

谢谢, 肖恩

    public void MakeCall()
    {
        var accountSid =  ConfigurationManager.AppSettings["TwilioAccountSid"];
        var authToken =  ConfigurationManager.AppSettings["TwilioAuthToken"];
        var mePhoneNumber = ConfigurationManager.AppSettings["MyPhoneNumber"];
        var treePhoneNumber = ConfigurationManager.AppSettings["TreePhoneNumber"];

        var conferenceName = "treeNavigate" + Guid.NewGuid();

        TwilioClient.Init(accountSid, authToken);

        Twimlet treeConferenceTwimlet = new Twimlet();
        treeConferenceTwimlet.Endpoint = "conference";
        treeConferenceTwimlet.Parameters.Add("Name", conferenceName);
        treeConferenceTwimlet.Parameters.Add("Message", "Hi Tree");

        Twimlet meConferenceTwimlet = new Twimlet();
        meConferenceTwimlet.Endpoint = "conference";
        meConferenceTwimlet.Parameters.Add("Name", conferenceName);
        meConferenceTwimlet.Parameters.Add("Message", "Hi Me");

        var meCall = CallResource.Create(
            to: new PhoneNumber(mePhoneNumber),
            from: new PhoneNumber(mePhoneNumber),
            url: new Uri(meConferenceTwimlet.GetFormattedURL()));

        var treeCall = CallResource.Create(
            to: new PhoneNumber(treePhoneNumber),
            from: new PhoneNumber(mePhoneNumber),
            url: new Uri(treeConferenceTwimlet.GetFormattedURL()));
        
        CallResource.Update(
            pathSid: treeCall.Sid,
            twiml: new Twilio.Types.Twiml("<Response><Say>I can hear this on the conference but then it hangs up right after</Say></Response>"));

    }

    public class Twimlet
    {
       private String baseUrl = "http://twimlets.com/";
       public Dictionary<String, String> Parameters { get; set; }
       public String Endpoint { get; set; }

       public Twimlet()
       {
           this.Parameters = new Dictionary<string, string>();
       }

       public String GetFormattedURL()
       {
           return String.Format(
               "{0}{1}?{2}", 
               this.baseUrl, 
               this.Endpoint, 
               String.Join("&", this.Parameters.Select(x => String.Format("{0}={1}", HttpUtility.UrlEncode(x.Key), HttpUtility.UrlEncode(x.Value)))));
       }
   }

【问题讨论】:

    标签: twilio twilio-twiml twimlet


    【解决方案1】:

    这里是 Twilio 开发者宣传员。

    当 Twilio 支持的电话呼叫执行 TwiML 时,它会执行此操作,直到用完 TwiML 然后挂断。在这种情况下,当您使用仅带有 &lt;Say&gt; 元素的新 TwiML 更新调用时,它将说出单词然后完成。

    在会议线上保持通话的方法是在&lt;Say&gt; 完成后做一些事情。例如,您可以暂时&lt;Pause&gt;

    这并不是一个很好的答案,但我不确定你在这个电话之后的计划是什么 &lt;Say&gt; 所以很难建议你如何做得更好。如果你能解释一下,我可以用其他建议编辑这个答案。

    【讨论】:

    • 您好,这很有帮助,谢谢。所以这就是我想要的方式:1)我的应用程序在电话会议中连接电话树和我的手机。连接到电话树的那条腿只是在那里坐了一会儿。 2)从我的手机中,我输入了按键以转发到树腿以通过可变部分。 3)一旦过去,我就在电话树的一部分,它本质上是一个循环。我希望能够挂起我的腿并点击应用程序中的一个按钮,该按钮每次通过菜单都会生成一个 twiml 文件,收集树说出的确认号以显示在我的应用程序中。
    • 听起来最后一部分需要循环&lt;Gather input=:"speech"&gt;,直到您收到确认码。你觉得这对吗?
    • 听起来不错,但我还是有点卡住了。我目前的挑战是,在我对我的应用程序和电话树之间的呼叫进行更新后,即使我在传递的 TwiML 结束时做了一个超长的暂停,该呼叫也会由于某种原因与会议断开连接.我希望
    猜你喜欢
    • 1970-01-01
    • 2012-02-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-03
    • 2011-01-19
    相关资源
    最近更新 更多