Page 1 of 3 123 LastLast
Results 1 to 15 of 40
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919

    VBA REST API to GET SMS from Twilio

    Does anyone by chance have a VBA code segment using the REST API that is used to "GET" an incoming SMS XML string from the Twilio? Thanks to Paul and others I've been successful in sending both SMS and Voice. I'm assuming it's similar to listening for a outgoing reply but there's no coupling of two-way traffic so there's a slight difference?

    Thanks,


    Bill

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    I have code to both send and receive SMS messages and voice messages using the Twilio API.
    However, I use CSV imports rather than XML. I've also experimented with JSON import but not XML.

    I used an excellent article by Devin Rader to get me started - see https://www.twilio.com/blog/2013/08/...nd-access.html
    You may also find it useful to read a lengthy thread that I started at AWF on the topic a couple of years ago - https://www.access-programmers.co.uk...ghlight=Twilio
    The Twilio API documentation is also very good.

    NOTE: I haven't looked at any of this code for almost 2 years so my memory of the details is now very hazy...

    Hope that helps.
    If you think the CSV code could be of any use, let me know
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Hi Colin,
    Yes, I started with Rader's article and Baldy had reminded me recently of the thread you'd started a couple of years ago so all of that helped to get running code to send out SMS and Voice Calls. From the end-user's point-of-view, those text/call messages are coming from the phone number that I essentially "rent" from Twilio. What I've been struggling with is how to "GET" the text strings at Twilio resulting from messages sent from that number. NOT REPLIES to an outgoing SMS but rather spontaneous messages arriving from that number. Such messages will be encoded in such a way that my Access app will know what to do with them. I will have a module that runs off of a Windows timer that will "GET" SMS XML text string and the Access app will carry out its task.

    I think my problem is how to configure MessageUrl so that

    Code:
    http.Open "GET", MessageUrl, False, ACCOUNTSID, AUTHTOKEN
    properly correlates to my Twilio "number".

    Thanks,
    Bill

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    I may be misunderstanding, but from our discussion I thought you were trying to grab messages sent TO your Twilio number. Your person would send a text from her phone to the Twilio number and you want to handle it. Or am I screwed up?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    You are correct. I want to "GET" the message "my person" sends to my Twilio number. (I might even get a 2nd number from Twilio solely for that purpose.)

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Then Colin's csv import is probably what you want. I suspect it's along the lines of what I was going to try before I found out I didn't have to handle incoming messages. I was going to import periodically and handle anything new. If Colin's method actually gets triggered by an incoming message all the better.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    By the way, your second number idea may be a good one, as no matter what you tell people, your outgoing number will get replies sent to it. And you'll probably have to watch out for incoming spam as well, so maybe testing the "from" number if you only want to handle messages from that one person.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    I tried to follow Colin's method but I'm sure the problem is that I don't know how to describe to Twilio what I'm asking for. I.e., I think the "MessageURL" needs to somehow be configured such that Twilio will know I'm referring to SMS arriving from "my Twilio number".

  9. #9
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    No, you're right. I think a second number will save me a lot of screwing around over the long haul.

  10. #10
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Why do you think you need a second number?
    I use the same Twilio number for all four messaging features - both sending and receiving SMS and voicemail
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  11. #11
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Just so i don't have to deal with unsolicited replies. The ratio of outgoing msgs to authorized incoming app commands is probably in the range of 50:1.
    Twilio does have a feature whereby incoming messages are only accepted by specific authorized numbers so that's a possibility as well, the downside being one then has to play an administrator role.

  12. #12
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    Unsolicited replies wasn't an issue for the situation I used Twilio for SMS/voice messaging (contacts with parents of school students re absence; late or non arrival; school closures; special events etc).
    Incoming calls via Twilio were not answered by a member of staff but the call contents were logged to my Access app then matched to the student(s) concerned
    However perhaps I'm being dense but I don't see how a second number helps deal with unsolicited calls.
    Surely it just gives two numbers that can receive such calls...unless you have restricted one to outgoing only
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  13. #13
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Hi Colin,

    Maybe I'm missing something here? The recipients of the SMS are very likely going to ignore the well publicized DO NOT REPLY to GCC/TMS (the app) text message broadcasts. Monthly volume is in the neighborhood of 1500 to 2000.

    The app has a companion module running on a timer that "GETs", at least that's what I'm trying to solve, incoming SMS that contain commands for the app to process. It's my understanding that SMS records at Twilio all need to be attended to one way or another. If that's a correct understanding, then my "GET module" could possibly be inundated with "non-command" traffic and spend some time having to "Delete" any such records.

    My "old school" mentality typically urges me to avoid un-necessary program execution so the impetus for a possible unpublished 2nd number lays there. As yet, I have no idea what Twilio does with accumulated records if not explicitly deleted by the user, so this discussion will eventually have to include that issue.

    BTW, I think your approach in using the CSV format for incoming SMS is a good suggestion. It got a second vote of approval from Paul as well

    Thanks,
    Bill

  14. #14
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    I didn't have to deal with responses, so I'll defer to Colin on this. I suspect the processing power to deal with non-relevant responses is trivial. I assume the csv would include the sending number; you simply delete the others or flag them as handled. Then handle the relevant one and flag it as handled.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  15. #15
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    I've been successful in running Colin's code with a couple changes so that I can run in Debug independent of the host app. The resulting CSV file has everything in it but the kitchen sink, as my father used to say. So, the issue as to how to purge data off the server has emerged. I can easily find any pertinent GCC/TMS commands in the <TwilioResponse> string found in the CSV file, but how to clear the message history totally escapes me.

    (I'll post the final code when the appropriate time comes.)

Page 1 of 3 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Refreshing one object, and leave the rest alone!
    By Calego in forum Programming
    Replies: 6
    Last Post: 05-01-2017, 06:52 AM
  2. REST Endpoints
    By foo in forum Programming
    Replies: 1
    Last Post: 12-04-2016, 07:53 PM
  3. REST api POST method
    By irade92 in forum Programming
    Replies: 7
    Last Post: 02-03-2015, 03:21 PM
  4. Help with subforms (and the rest)
    By Franco27 in forum Reports
    Replies: 0
    Last Post: 03-14-2011, 09:43 AM
  5. Combox not filling the rest of the form
    By britt britt in forum Forms
    Replies: 2
    Last Post: 10-27-2009, 04:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums