Search code examples
javascriptnode.jstwiliotwilio-functions

Twilio.PHONE_NUMBER does not validate correctly


Twilio.PHONE_NUMBER is accepting input such as '62047' which is obviously not a valid phone number. I tried writing my own custom validation function but I am unable to count number of times this function is triggered, hence running into an infinite loop(in case phone number given by user is always invalid).

Is their any way to solve this or do we have to settle for Twilio.PHONE_NUMBER?


Solution

  • I was able to solve this problem by maintaining a common state between two functions using the sync API.

    You can read about it here: https://www.twilio.com/sync/api