# Twilio Phone Number Formatting

**URL:** <https://forum.inductiveautomation.com/t/twilio-phone-number-formatting/26281>\
**Category:** Ignition\
**Tags:** ignition79\
**Created:** [July 3, 2019, 8:01pm UTC](https://forum.inductiveautomation.com/t/twilio-phone-number-formatting/26281 "2019-07-03T20:01:11Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Herbie](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/herbie/32/65288_2.png) [@Herbie](https://forum.inductiveautomation.com/u/Herbie)\
**Post date:** [July 3, 2019, 8:01pm UTC](https://forum.inductiveautomation.com/t/twilio-phone-number-formatting/26281/1 "2019-07-03T20:01:11Z")

</div>

We purchased the Twilio module (from Kymera, but the IA one looks similar) and are running into some problems with improperly formatted phone numbers for SMS and Voice. We are using AD authentication and pulling contact information in from that source. We are figuring out how to manage the on-call roster better (other than the webpage), but cannot figure out the best way to get the phone numbers formatted exactly as Twilio expects it (+12345678901). I know we can edit the contact information for each user added, but that is so tedious and time consuming. Our AD system has so many variations, and having IT format to this standard for 100k+ entries would be quite the ask (not to mention the data is hand entered and could be incorrectly formatted in the future). I would think some sort of code to handle this would be straightforward, but nothing has been done yet.

Is anyone else faced with this problem? What have you done to resolve it?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [July 3, 2019, 8:07pm UTC](https://forum.inductiveautomation.com/t/twilio-phone-number-formatting/26281/2 "2019-07-03T20:07:08Z")

</div>

This seems like a problem best solved in the IA and/or Kymera module by normalizing/formatting the phone numbers before passing them to the Twilio library, if possible.

Maybe someone else has a better suggestion though…

---

<div class="post-metadata">

**Author:** ![chi](https://avatars.discourse-cdn.com/v4/letter/c/0ea827/32.png) [@chi](https://forum.inductiveautomation.com/u/chi)\
**Post date:** [July 3, 2019, 8:20pm UTC](https://forum.inductiveautomation.com/t/twilio-phone-number-formatting/26281/3 "2019-07-03T20:20:58Z")

</div>

You could use a ‘Calculated Roster’ and normalize the phone numbers in a script. There is a python library for this purpose [https://github.com/daviddrysdale/python-phonenumbers](https://github.com/daviddrysdale/python-phonenumbers) that should work in Ignition.

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [July 4, 2019, 2:52am UTC](https://forum.inductiveautomation.com/t/twilio-phone-number-formatting/26281/4 "2019-07-04T02:52:54Z")

</div>

Hello Herbie,  
I will talk with out developers and see what we can do to help normalize the numbers. Will have someone respond to your email.

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [July 4, 2019, 2:56am UTC](https://forum.inductiveautomation.com/t/twilio-phone-number-formatting/26281/5 "2019-07-04T02:56:35Z")

</div>

Also, using libphonenumber in Java or python-phonenumbers could be used.

---

<div class="post-metadata">

**Author:** ![Herbie](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/herbie/32/65288_2.png) [@Herbie](https://forum.inductiveautomation.com/u/Herbie)\
**Post date:** [July 10, 2019, 12:11am UTC](https://forum.inductiveautomation.com/t/twilio-phone-number-formatting/26281/6 "2019-07-10T00:11:58Z")

</div>

@Kyle_Chase, thanks for looking into this. @chi, I was looking into into the Calculated Roster, but I’m not sure how to access the existing list to “condition” the numbers. Is the existing roster passed in on the event or builder objects?

I really don’t want to build the list in a Calculated Roster (which is kind of what this looks to be doing, but I could be wrong.) I must be missing something here.

---

<div class="post-metadata">

**Author:** ![chi](https://avatars.discourse-cdn.com/v4/letter/c/0ea827/32.png) [@chi](https://forum.inductiveautomation.com/u/chi)\
**Post date:** [July 10, 2019, 7:10pm UTC](https://forum.inductiveautomation.com/t/twilio-phone-number-formatting/26281/7 "2019-07-10T19:10:11Z")

</div>

> [@Herbie](#):
>
> I was looking into into the Calculated Roster, but I’m not sure how to access the existing list to “condition” the numbers. Is the existing roster passed in on the event or builder objects?

In the script you can use `system.alarm.getRosters()` to get your defined rosters. From there you have to get a list of users in the specific roster.  
Then iterate over that list and call `system.user.getUser` and `user.getContactInfo()` to get the user and its contact information.

---

<div class="post-metadata">

**Author:** ![Kyle\_Chase](https://avatars.discourse-cdn.com/v4/letter/k/9de0a6/32.png) [@Kyle\_Chase](https://forum.inductiveautomation.com/u/Kyle_Chase)\
**Post date:** [July 10, 2019, 7:27pm UTC](https://forum.inductiveautomation.com/t/twilio-phone-number-formatting/26281/8 "2019-07-10T19:27:15Z")

</div>

Hi Nicholas,  
Are you able to get me a list of phone numbers so we can validate the parser vs those numbers? Email them to [support@kymerasystems.com](mailto:support@kymerasystems.com) please.
