質問

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?

役に立ちましたか?

解決

This question is not specific on what types of issues you are hitting when trying to run this application. But one thing to check is that you have been given the rights to make outbound calls. Unless things have changed, you have to request this functionality from Tropo support.

A good C# framework that runs on MVC 4 for developing Tropo applications is VoiceModel. It is open source under the Apache license and simplifies voice application development. You develop your application once and it will run on Tropo and any VoiceXML compatible system. Here is an article on using VoiceModel to create outbound applications.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top