public ActionResult Index(SmsRequest request)
 {
     var response = new TwilioResponse();
       if(request.body == "hello")
       {
     response.Message("Hi!");
       }
       else if(request.body == "bye")
       {
     response.Message("Goodbye");
       }
       return TwiML(response);
 }
    public ActionResult Index(SmsRequest request)
    {
        var counter = 0;

        // get the session varible if it exists
        if (Session["counter"] != null)
        {
            counter = (int) Session["counter"];
        }

        // increment it
        counter++;

        // save it
        Session["counter"] = counter;

        // make an associative array of senders we know, indexed by phone number
        var people = new Dictionary<string, string>()
        {
            {"+14158675309", "Rey"},
            {"+14158675310", "Finn"},
            {"+14158675311", "Chewy"}
        };

        // if the sender is known, then greet them by name
        var name = "Friend";
        if (people.ContainsKey(request.From))
        {
            name = people[request.From];
        }

        var response = new TwilioResponse();
        response.Message($"{name} has messaged {request.To} {counter} times");
        return TwiML(response);
    }
 // GET: api/TestTwiml
 public HttpResponseMessage Get(TwilioRequest req)
 {
     
     TwilioResponse res = new TwilioResponse();
     res.Message("Hello There", new {voice = "alice"});
     return Request.CreateResponse(HttpStatusCode.OK, res.Element);
 }
Beispiel #4
0
        public void Can_Generate_Single_Message()
        {
            var response = new TwilioResponse();
            response.Message("Hello world");

            Assert.IsTrue(IsValidTwiML(response.ToXDocument()));
        }
 public ActionResult Index(SmsRequest request)
 {
     var response = new TwilioResponse();
     response.Message("The Robots are coming! Head for the hills!",
         new [] { "https://farm8.staticflickr.com/7090/6941316406_80b4d6d50e_z_d.jpg" },
         null);
     return TwiML(response);
 }
Beispiel #6
0
        public void Can_Generate_Single_Message_With_Attributes()
        {
            var response = new TwilioResponse();
            response.Message(
                "Hello world",
                new { to = "+15551111111", from = "+15552222222", action = "sms.php", method = "GET", statusCallback = "status.php" }
            );

            Assert.IsTrue(IsValidTwiML(response.ToXDocument()));
        }
Beispiel #7
0
        public void Can_Generate_Single_Message_With_Media()
        {
            var response = new TwilioResponse();
            response.Message(
                new string[] {
                    "http://example.com/1",
                    "http://example.com/2" },
                new { to = "+15551111111", from = "+15552222222", action = "sms.php", method = "GET", statusCallback = "status.php" }
            );

            Assert.IsTrue(IsValidTwiML(response.ToXDocument()));
        }
        private HttpResponseMessage GetMessage(SmsRequest req)
        {
            try
            {

                using (TreasureContext db = new TreasureContext())
                {
                    User user = _userService.GetUserFromPhoneNo(req.From, db);
                    if (user == null) return Request.CreateResponse(HttpStatusCode.OK, IDontKnowYou().Element, new XmlMediaTypeFormatter());
                    TwilioResponse result = _storyTellerService.ReadStory(user, req.Body, req.To);
                    db.SaveChanges();
                    return Request.CreateResponse(HttpStatusCode.OK, result.Element, new XmlMediaTypeFormatter());
                }
            }
            catch (Exception e)
            {
                TwilioResponse resp = new TwilioResponse();
                resp.Message(e.Message);
                return Request.CreateResponse(HttpStatusCode.OK, resp.Element, new XmlMediaTypeFormatter());
            }
        }
 private TwiMLResult GenerateTwiML(string message)
 {
     var response = new TwilioResponse();
     response.Message(message);
     return TwiML(response);
 }
 public ActionResult Index(SmsRequest request)
 {
     var response = new TwilioResponse();
     response.Message("The Robots are coming! Head for the hills!");
     return TwiML(response);
 }
        private static TwilioResponse Respond(string message)
        {
            var response = new TwilioResponse();
            response.Message(message);

            return response;
        }
 private TwilioResponse IDontKnowYou()
 {
     TwilioResponse resp = new TwilioResponse();
     resp.Message("Sorry, I don't know who you are!");
     return resp;
 }