Best answer

How to Parse out Phone Numbers from Webhook

  • 30 September 2022
  • 1 reply

Hello - I have a webhook that reaches out and gets phone numbers for potential clients. However, it returns multiple numbers. I’m look to grab the most recent mobile number and put the rest in a comment field. I tried to formatter, but got stuck. Any help would be appreciated. Output attached. 😉 Thank you in advanced.



Best answer by Danvers 3 October 2022, 11:57

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

1 reply

Userlevel 7
Badge +12

Hi @PeterQuinn!

It looks like the phone numbers are line items, which is why the Formatter step isn’t working as you’d expect. 

It’s easy enough to extract the first phone number, getting the others into the comments field will depend on what other actions you need in the Zap. 

Here’s how I would do it:

  1. Add a Formatter > Utilities step to convert the line items into text. Add the number field as the input for the action. This will convert the line items into comma separated text, which wont look different when you’re adding the field in the steps of your Zap, but if you look at the output of the Formatter step, you’ll see that it’s something like “(415) 123456, (415) 234567, (415) 345678”
  2. Add another Formatter action, this time choosing Text and then Split Text as the transform. This will break the text into chunks based on the character you choose, and it uses a comma by default, so your numbers field is already good to go.
  3. The next part depends on what information you get from the webhook each time, specifically if there will always be the same number of phone numbers each time, or if sometimes someone might add one and another they will add three. I’m going to assume that there could be different numbers of phone numbers as that’s the most common use case.
  4. In the Split text step, for the Segment Index field, choose First. This will pull the first piece of information before a comma, ie the first phone number on the list. Tada! You now have the first number as a separate field. 
  5. Add another Formatter > Text step to the Zap but this time choose the transform Replace. The aim of this step is to get the rest of the phone numbers in the list, without the first one. To do that, put the output of the line item to text step in the input field - that’s the ​​​​​​full list of phone numbers from point 1 above. In the Find field, add the output of the Split text step (ie the first phone number) and then type a comma. Leave the Replace field blank and the action will delete the found text. 
  6. The output of that step will then be a list of the other phone numbers, separated by commas that you can add to the comments. 

That’s a lot of Formatter steps, so let me know if you have any questions about them! There may also be a way to do this using a single code step, but that’s beyond my knowledge 😅


Let us know if that works for you :)