Home > Blockchain >  Carriers receive Twilio SMS sent via curl, but only Google Voice receives when SMS sent via Cloud Ru
Carriers receive Twilio SMS sent via curl, but only Google Voice receives when SMS sent via Cloud Ru

Time:11-11

I have a strange problem that I can't seem to solve. At an impasse and I could really use your help. Here are the key characteristics of the problem.

  1. I CAN send an SMS via Twilio using curl (see below) at the command line and I CAN successfully receive it via T-mobile or Google Voice. Twilio delivery status is 'delivered', as expected.

  2. If I send the SMS using any of the npm packages (listed below) via a Cloud Run express API that I wrote, then:

a. I CAN successfully send the message, and the Twilio delivery status reads: 'delivered'.

b. I CAN successfully receive the message at a Google Voice number.

c. I CANNOT successfully receive the message on a device where T-mobile is the carrier. (Or any other carrier for that matter.) Yet, the Twilio delivery status still reads 'delivered' in this case.

Is there an IP whitelist I should be using at the Twilio console, maybe? Perhaps there's some other configuration I should be making at the console? Sure seems strange that Google Voice receives messages from a Google cloud service, but that the carriers do not. Any help, advice, or insight would be greatly appreciated. Thanks so much in advance.

curl -X POST -d "Body=Hi, this is the message" -d "From= 14155551212" -d "To= 19251012002" "https://api.twilio.com/2010-04-01/Accounts/<SID>/Messages" -u "SID:AUTH_TOKEN"

npm packages tried:

    "axios": "^0.27.2",
    "request": "^2.88.2",
    "twilio": "^3.80.0"

CodePudding user response:

Try this:

fetch('https://api.twilio.com/2010-04-01/Accounts/<SID>/Messages', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
        'Authorization': 'Basic '   btoa('SID:AUTH_TOKEN')
    },
    body: 'Body=Hi, this is the message&From= 14155551212&To= 19251012002'
});

CodePudding user response:

Thanks for your help, all. Solved the problem. A proper facepalm. I had a short url in the message body which was preventing delivery.

  • Related