0

I am trying to implement Tropo into my MVC4 application. I have a simple Gateway that creates a call to a number and says a message. I can't seem to get it working, all that happens is Tropo dials the number and hangs up when the person answers.

Here is my Gateway code:

public void SendAppointmentNotification()
        {
            var httpWReq =
                (HttpWebRequest)WebRequest.Create("https://api.tropo.com/v1/sessions");

            var encoding = new ASCIIEncoding();
            var postDataTemplate = "<session>" +
                                   "<token>{0}</token>" +
                                   "<var name=\"numberToDial\" value=\"{1}\"></var>" +
                                   "<var name=\"msg\" value=\"{2}\"></var>" +
                                   "</session>";

            var tokenToUse = [APIKEY]-Removed;
            var numberToDial = "XXXXXXXXXX";
            var message = "Greetings. This is a reminder that you have a service call appointment scheduled.";

            var postData = string.Format(postDataTemplate, tokenToUse, numberToDial, message);

            var data = encoding.GetBytes(postData);

            httpWReq.Method = "POST";
            httpWReq.Accept = "text/xml";
            httpWReq.ContentType = "text/xml";
            httpWReq.ContentLength = data.Length;

            var newStream = httpWReq.GetRequestStream();
            newStream.Write(data, 0, data.Length);
            var response = (HttpWebResponse) httpWReq.GetResponse();
            byte[] buffer = new byte[response.ContentLength];
            using (var stream = response.GetResponseStream())
            {
                stream.Read(buffer, 0, (int) response.ContentLength);
            }
            var bufferAsString = buffer.Aggregate("", (current, t) => current + (char) t);

            if (response.StatusCode != HttpStatusCode.OK)
            {
                throw new Exception("Did not get status OK 200 from POST");
            }
            newStream.Close();
        }

Tropo's site seems to show much love to all languages other than C# and the Github repository they have is quite old and lacks documentation.

I just want to call a person and say a message... has anyone been down this road and can offer me some example of their implementation?

4

1 回答 1

1

此问题并未具体说明您在尝试运行此应用程序时遇到的问题类型。但要检查的一件事是,您已被授予拨打外线电话的权利。除非情况发生变化,否则您必须向 Tropo 支持请求此功能。

VoiceModel是一个在 MVC 4 上运行以开发 Tropo 应用程序的优秀 C# 框架。它在 Apache 许可下是开源的,简化了语音应用程序的开发。您开发应用程序一次,它将在 Tropo 和任何 VoiceXML 兼容系统上运行。这是一篇关于使用 VoiceModel 创建出站应用程序的文章。

于 2013-09-16T12:22:35.457 回答