Xano removing '+' in an api call - Sending SMS with Twillo

Options

Hey guys,

Not sure if I am missing something obvious but I keep getting this error message when trying to use the twillo sms integration. This is a fake number but it has the same error when I test with a real verified one.

It seems to be sending the number without the ‘+’ in front which defines the area code even though this is exactly how my data looks in the db. Any idea why?

I have it set up as a text field which is what was done in the youtube tutorial.

Tagged:

Best Answer

  • MattLaro
    MattLaro Member ✭✭
    edited February 2023 Answer ✓
    Options

    Perhaps the phone number you're providing is truly not valid for Twilio to send a SMS.

    We used that function and it does indeed remove the + in the “To” field. Here's the culprit inside the function call :



    However, on our side, it does send the SMS successfully without having the + in the “To” field

    I'd check perhaps if there's something missing in the phone number format ?

    I believe some places in the world uses different number prefix whenever you call them locally, from outside or when you text them. The number of reasons the number is not a valid phone number can be vast :).

Answers

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options

    You probably have to apply the url_encode filter to your E.164-formatted number string when you add it to your API call. A “plus” in HTTP encoding represents a space, while a “%2b” represents a plus.

    If that doesn't work, please share more about the API call you are building, and maybe we can find a solution together!

    Working on APIs is a core part of the “hardest 5%” we work on in State Change and our daily office hours.

  • jimmy
    jimmy Member
    Options

    Hi @Ray Deck, thanks for your reply. Unfortunately, this didn't work either. It seems to still not accept % or the B.

    I added more photos of my set up. Essentially I am just trying to send an sms to all players via this api call.

  • jimmy
    jimmy Member
    Options

    Interesting, thanks @MattLaro ! Are you sending from a US number to a US number?

    In my case, I'm sending from a US number to a United Kingdom number (+44), so I think the area code is required.

  • MattLaro
    MattLaro Member ✭✭
    Options

    Yes @jimmy from America :). We have it easy here! It's 1 then the number for all cases, locally or abroad.

    Try indeed an international call setting for Twilio by adding all the required area codes for international communication. It's probably what's missing here.

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options

    Thanks for setting me straight on that function @MattLaro - I didn't know about the intermediate work it did!

  • jimmy
    jimmy Member
    Options

    @MattLaro Thanks so much, this worked like a charm!

    Just removed the “+” replace and it worked fine.

    They may want to consider removing that as standard as it basically makes it useless for sending internationally.