How to setup GET API tool inbound customer.number ...
# support
i
I have CRM (HouseCall Pro) accept short numbers only. Have say in advance GET https://api.housecallpro.com/customers?q={{customer.number.substring(2)}} or GET https://api.housecallpro.com/customers?q={{customer.number|remove_first:"+1"}} is not works. Any idea? Based project for United States only maybe is any option to setup global settings ignore country code?
c
Hi Igor_70, To handle the phone number format without the country code +1, you can manipulate the phone number string using JavaScript or another programming language before making the API call to HouseCall Pro. If you're using JavaScript, you could do something like this:
Copy code
javascript
let phoneNumber = "+11231231234";
let shortNumber = phoneNumber.startsWith("+1") ? phoneNumber.substring(2) : phoneNumber;
// Make the API call with shortNumber
This code checks if the phone number starts with "+1" and removes it, providing you the short number to use in your query. Adjust this logic in your application where you prepare the phone number for the API call.
t
Transform the number using JavaScript before sending to API
i
Hi @Tay. Thanx for reply. Have I do in vapi side or use external server like make?
Hi @aniah. Is any option to do at vapi side or I have to use external service like make?
t
You can use make.com
c
Hi Igor_70, To extract a customer's phone number without the country code using Vapi, you need to ensure that the number is processed to remove or adjust the E.164 format as required. This will involve manipulating the phone number data in your application or using a middleware process. Here’s a general approach: 1. **Fetch the Phone Number**: Use the GET API to retrieve the phone number in E.164 format. For example, use the endpoint to get specific phone number details:
Copy code
python
   from vapi import Vapi
   
   client = Vapi(token="YOUR_TOKEN")
   phone_number = client.phone_numbers.get(id="phone-number-id")
[Retrieve API Details](https://docs.vapi.ai/api-reference/phone-numbers/get) 2. **Process Number Data**: Extract the number string and programmatically remove the country code
+1
, assuming all numbers you handle are in this format.
Copy code
python
   def strip_country_code(phone_number):
       if phone_number.startswith('+1'):
           return phone_number[2:]
       return phone_number
   
   short_number = strip_country_code(phone_number["number"])
This will give you the phone number without the
+1
prefix, allowing you to handle or store it as needed. Ensure your solution adheres to any format requirements that might be specific to your integration or application logic.