SMS Messaging service

Xbase++ 2.0 Build 554 or later
Message
Author
User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

SMS Messaging service

#1 Post by rdonnay »

We have been trying to use Twilio for SMS messaging and are experiencing many problem with undelivered messages.

I would like some recommendations for a SMS message service that is reliable.
The eXpress train is coming - and it has more cars.

bobvolz
Posts: 114
Joined: Sun Jan 31, 2010 11:25 am

Re: SMS Messaging service

#2 Post by bobvolz »

Roger; Did you register your Twilio Messaging service with the A2P 10DLC that is required for all your purchased numbers.
I have been struggling with this as well. Twilio support is not great. I learned about it on a You Tube video.
Bob Volz

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: SMS Messaging service

#3 Post by rdonnay »

Bob, actually I finally got support from Twilio that was useful. They set up a zoom meeting with Bobby Drakos and myself.
They have been inundated with support requests over this A2P stuff that went into effect on July 5.
Our problems seem to be that the authorizing personnel are overloaded and that it can take many weeks to get fully registered.

Meanwhile they informed us to use a toll free number because it doesn't require the same registration.
Voila!
Our SMS messages are going thru now.
The eXpress train is coming - and it has more cars.

bobvolz
Posts: 114
Joined: Sun Jan 31, 2010 11:25 am

Re: SMS Messaging service

#4 Post by bobvolz »

Hi Roger;
I submitted my A2P twice and got rejected. The last one I did is awaiting decision. I do have a toll free number to use but haven't used it yet.
I guess I may do that if I can't get my campaign registered.
I'd like to see your endpoint code for responses that you access via the webhook. I can then build it into my app. I tried experimenting with xb2Net webserver but can't get the hook to work.
Keep me posted.
Bob Volz

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: SMS Messaging service

#5 Post by rdonnay »

I hope this helps:

Code: Select all

METHOD WebService:Twilio( cData )

LOCAL oResponse, cResponse, oParams := DataObject():new(), oSms2, i, c, ;
      cHack, cUserId := '', cUserLogin := ''

oResponse := DataObject():new()
oResponse:status := 200

oParams:body := ::getVar('BODY')
oParams:&('to') := ::getVar('TO')
oParams:from := ::getVar('FROM')
oParams:SmsSid := ::getVar('SMSSID')
oParams:MessageSid := ::getVar('MESSAGESID')
oParams:SmsStatus := ::getVar('SMSSTATUS')
oParams:NumSegments := ::getVar('NUMSEGMENTS')
oParams:NumMedia := Val(::getVar('NUMMEDIA'))

FOR i := 1 TO oParams:NumMedia
  c := 'MediaContentType' + Alltrim(Str(i-1))
  oParams:&(c) := ::getVar(c)
NEXT
FOR i := 1 TO oParams:NumMedia
  c := 'MediaUrl' + Alltrim(Str(i-1))
  oParams:&(c) := ::getVar(c)
NEXT

::ParamsSetData("Twilio", oParams )

::Write2Log('Twilio', oResponse, oParams)

cResponse := ::ResponseFormat(oResponse,::httpResponse, 'JSON' )

UseDb('DRV')
cHack := DriverHackFromPhone(oParams:from)
DRV->(dbSeek(cHack,,'DRVHACK'))

UseDb('USR')
cUserID := UserFromPhone(oParams:&('to'), @cUserLogin)

UseDb('SMS2')
oSms2 := SMS2->(DC_DbRecord():new())
SMS2->(dbGoTo(0))
SMS2->(DC_DbScatter(oSms2))
oSms2:date := Date()
oSms2:time := Time()
oSms2:body := oParams:body
oSms2:viewedby := ''
oSms2:smstelfrom := oParams:from
oSms2:smstelto := oParams:&('to')
oSms2:hack := cHack
oSms2:mednum := DRV->mednum
oSms2:shift := DRV->shift
oSms2:user_id := cUserId
oSms2:user_name := cUserLogin

FOR i := 1 TO oParams:NumMedia
  c := 'MediaType' + Alltrim(Str(i-1))
  oSms2:&(c) := ::getVar(c)
NEXT
FOR i := 1 TO oParams:NumMedia
  c := 'MediaUrl' + Alltrim(Str(i-1))
  oSms2:&(c) := ::getVar(c)
NEXT

SMS2->(DC_DbGather(oSms2,.t.))

dbCloseAll()

RETURN ''
The eXpress train is coming - and it has more cars.

bobvolz
Posts: 114
Joined: Sun Jan 31, 2010 11:25 am

Re: SMS Messaging service

#6 Post by bobvolz »

Hi Roger;
I integrated the code you sent with my endpoint server running under xb2Net. I can collect and parse the json that is to be posted
to the webhook as a text response from Twilio. I'm not sure the webhook is set up right. I'm assuming it is HTTPS and not just HTTP.

I'm just curious as to how you are protecting your endpoint. Are you 'whitelisting' certain DNS name or IP's that are coming from Twilio?

Also, on your Twilio phone number screen where are you putting the webhook info. See attached .png

Mine will be something like "https://api.meadowlandsystems.com:8445/process" that Twilio would use to post the json response?

Any help would be appreciated.

Bob Volz
Attachments
Twilio_webhook.png
Twilio_webhook.png (47.3 KiB) Viewed 2291 times

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: SMS Messaging service

#7 Post by rdonnay »

This is my configuration:
twilio1.jpg
twilio1.jpg (69.08 KiB) Viewed 2285 times
The eXpress train is coming - and it has more cars.

bobvolz
Posts: 114
Joined: Sun Jan 31, 2010 11:25 am

Re: SMS Messaging service

#8 Post by bobvolz »

Hi Roger; Thanks. I see you use HTTP and not HTTPS.

Do you 'white list' anyone or do you just let anyone hit your server. I set mine up without a whitelist and got 20 'hits'
in 5 minutes from hackers and sniffers. GMDit made me whitelist ips that could talk to it.
Thanks for the info.

This should be fun.

Bob Volz

User avatar
rdonnay
Site Admin
Posts: 4729
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: SMS Messaging service

#9 Post by rdonnay »

We had so many problems getting HTTPS to work that I gave up on it for now.

It would cause complete lockups of the application and require Windows "End Task" to shut down.

I haven't monitored traffic on this webserver, other than valid hits, so I don't know how many bots are hitting it.
This has been running for over 1 1/2 years with no problems - for now.
The eXpress train is coming - and it has more cars.

bobvolz
Posts: 114
Joined: Sun Jan 31, 2010 11:25 am

Re: SMS Messaging service

#10 Post by bobvolz »

Hi Roger; Happy Sunday.

According to their documentation Twilio only uses HTTPS. If yours works under HTTP then their documentation is wrong- no surprise there.

I also noticed a large number of undelivered messages using the purchased phone numbers. I took your advice and switched to the original
toll free number but that doesn't work either. It wants a registration as well. When I try to register it I get a one word response 'Conflict'.
No reason, no nothing pointing to the problem. See attached .png

I'm pretty disappointed with them. Not sure what to try next.

Keep me posted on your progress.

Bob Volz
Attachments
Toll_Free_screen.png
Toll_Free_screen.png (54.36 KiB) Viewed 2219 times

Post Reply