7 Replies Latest reply on Feb 24, 2017 3:27 PM by bhamm

    Twilio, how to get responses to SMS? Sending is easy

    martinc

      We use this to Send SMS to employees:

      Set variable to

      "httpspost://" &

      $sms_accountID & ":" & $sms_token & "@api.twilio.com/2010-04-01/Accounts/" & $sms_accountID & "/Messages.json?To=+1" & $phone_number & "&From=+1" & $from & "&Body=" & $message

       

      the url returns a message Id that we log.

       

      Any idea on how to "Get" any replies to the SMS?

       

      Thanks

       

      Martin

        • 1. Re: Twilio, how to get responses to SMS? Sending is easy
          monkeybreadsoftware

          Please read in the documentation for Twilio.

          There you can specify a StatusCallback.

           

           

          e.g. point it to your own website with PHP script.

          Or use MBS Plugin to open a socket to listen for incoming connections.

          1 of 1 people found this helpful
          • 2. Re: Twilio, how to get responses to SMS? Sending is easy
            databuzz

            You'll need to setup a webhook on your server and have Twilio push incoming messages to your server.

             

            If you're looking for an off the shelf solution we include the PHP files for Twilio (and many other SMS Gateways) in our fmSMS solution:

             

            http://www.fmsms.com

             

            These process the incoming message and coverts them into records in a table with the sender, message body etc in individual fields.

            • 3. Re: Twilio, how to get responses to SMS? Sending is easy
              martinc

              It seems that this basis with Twilio (and many others) is a Rest API.

               

              It appears that FMs ability to 'Post'(the ""httpspost://" &..." above)  and Get are essentially items that work with a Rest API. 

               

              The 'post' is quite simple.  It's essentially a single line of code.

               

              It's my understanding that FM can Post and Get in the same manner.  There is very little information on this, but it seems like it may be very useful to FM folks.

               

              For those of us who don't have a Rest/PHP/Ruby... clue.... can we have a script where we set a variable to something like:

              "https://" & PREFERENCES::baseURL & PREFERENCES::request & "/users/" & $id & ".json"

              and then follow with a script line

               

              Insert from URL to collect the data to be parsed out?

              Or,,is this type of thing really only one way traffic?  Wherein, I send them something, they send me something.

               

              If it's much more than that, I'll just hire someone or buy the FMSMS app.

               

              Side note: I'm starting to sense that FM is getting left behind as other systems that utilize faster data transfer are becoming more common place.  We use FM go with separated files for remote workers.  FM go is useful but slow and feels old school.

              • 4. Re: Twilio, how to get responses to SMS? Sending is easy
                bhamm

                I use Twilio with FileMaker, in 3 of my solutions. I use it as you indicated in your original post, as a one-way send (outgoing only), but also bi-directionally. Replies to our Twilio SMS number are checked for certain keywords. Depending on the keyword match, Twilio can respond by querying our database for the sender's cell number, and reply appropriately... including record data, if desired. Here's one of the easier queries (attached), where our Executive Team members can request a URL to update their database record. The URL opens a simple Bootstrap form, loading their record data from the uuid field passed in the URL. Something like, "http://your.domain/executives/?uuid=uuidField"

                 

                Our form is just standard PHP/CWP stuff, like you would do for any FileMaker database.

                 

                Hope this helps?
                Screen Shot 2017-02-23 at 7.43.39 PM.png

                 

                Let me know what you need. I'm available if you want/need to contract something out.

                • 5. Re: Twilio, how to get responses to SMS? Sending is easy
                  bhamm

                  I may have misunderstood your original question.

                   

                  If you're just wanting to capture the message content, take $record from line 206 in my previous post and edit the record to append a 'smsReponses' field (or related record) with $_REQUEST['Body'].

                   

                  We do something similar with our volunteers, so that they can track their donated time. They text "5 hours" to our SMS number and the "5" gets added as a related record. They get a SMS reply thanking them for their time. That looks like this:
                  Screen Shot 2017-02-24 at 2.04.48 AM.png

                  1 of 1 people found this helpful
                  • 6. Re: Twilio, how to get responses to SMS? Sending is easy
                    martinc

                    Thank you BHamm,

                     

                    I'll play with this out of curiosity.  If it's too far out of my league, I'll touch base about making this a project.

                     

                    Martin

                    • 7. Re: Twilio, how to get responses to SMS? Sending is easy
                      bhamm

                      You're welcome. The other thing you need (not included in my last screenshot) is a simple switch statement, to check the incoming message for targeted words.

                       

                      switch ($result) {

                       

                          case strpos($result, 'hour') !== false ;

                             hours() ;

                             break ;

                       

                          default:

                              index() ;   // no match, respond with default reply or help message

                      }