Twilio gives error when asked to send SMS due to E...
# support
h
The assistant sends the caller's phone number e.g (555-666-8888) to webhook > Twilio but Twilio comes with error message that the phone number is not in E164 format( +1555-666-8888). I tried adding "+1" to the phone field in twilio but didn't work. How can I change the format to E164? Any advice would be appreciated.
v
@HT To convert a phone number to E.164 format, you need to ensure that it includes the country code, area code, and local number, and it should not contain any dashes or spaces. For a US number, the E.164 format would include the country code
+1
followed by the ten-digit phone number. Here's how you can format the number
(555-666-8888)
to E.164 format: 1. Remove any parentheses, dashes, and spaces. 2. Prepend the country code
+1
to the ten-digit number. The resulting E.164 formatted number should look like this:
+15556668888
. If you're trying to do this programmatically, you can use a simple string replacement function to remove the unwanted characters and then concatenate the country code. Here's a basic example in pseudocode:
Copy code
pseudocode
function formatToE164(phoneNumber):
    cleanNumber = phoneNumber.replace(/[^0-9]/g, "") // Removes anything that's not a digit
    e164Number = "+1" + cleanNumber
    return e164Number
You would call this function with the phone number you have, and it should return the number in the correct E.164 format. If you're still encountering issues after formatting the number correctly, please ensure that the phone number you're using is valid and that you have the correct permissions set up in Twilio to make calls to that number. If the problem persists, please ask support for more info on this.
You can continue this conversation by mentioning me in the message.
s
@HT you just need to append the country code before the phone number without dashes, and then let me know how it goes.
h
Where exactly should I append country code? In the prompt or in twilio module mapping?
s
Yes your correct in the twilio module mapping .
2 Views