ruby - How would I design this scenario in Twilio? -
i'm working on yrs 2013 project , use twilio. have twilio account set on $100 worth of funds on it. working on project uses external api , finds events near location , date. project written in ruby using sinatra (which going deployed heroku).
i wondering whether guys guide me on how approach scenario: user texts number of twilio account (the message contain location , date data), process body of sms, , send results number asked them. i'm not sure start; example if twilio handle of task or use twilio's api , checking smss , returning results. thinking not using database.
could guide me on how approach task?
i need present project on friday; i'm on tight deadline! our help.
they have great documentation on how of this.
when receive text should parse format need
put existing project , when returns event or events in area need check how long string due constraint twilio has of restricting messages 160 characters or less.
ensure split message elegantly , not in middle of event. if returned "boston celtics game", "the nut cracker play". want make sure if both events cannot put in 1 message first message says "boston celtics game, text coming in 1 second" or similar.
in order receive text message mobile device, you'll have expose endpoint reachable twilio. here example
class receivetextcontroller < actioncontroller def index # let's pretend we've mapped action # http://localhost:3000/sms in routes.rb file message_body = params["body"] from_number = params["from"] smslogger.log_text_message from_number, message_body end end
in example, index action receives post twilio. grabs message body, , phone number of sender , logs it. retrieving information twilio post simple looking @ params hash
{ "accountsid"=>"asdf876a87f87a6sdf876876asd8f76a8sdf595asdd", "body"=> body, "tozip"=>"94949", "fromstate"=>"mi", "tocity"=>"novato", "smssid"=>"asd8676585a78sd5f548a64sd4f64a467sg4g858", "tostate"=>"ca", "to"=>"5555992673", "tocountry"=>"us", "fromcountry"=>"us", "smsmessagesid"=>"hjk87h9j8k79hj8k7h97j7k9hj8k7", "apiversion"=>"2008-08-01", "fromcity"=>"grand rapids", "smsstatus"=>"received", "from"=>"5555992673", "fromzip"=>"49507" }
Comments
Post a Comment