Search code examples
twilio

Does twillo verify supports custom sms code verify?


My goal is achive custom sms code login like over 6 digits also include a-z alphabet, But I am not sure twillo sms code is customizable, All I found on offical document is they provide 4-10 code (4-10 characters), But I am not sure characters are also include a-z alphabet, any ideas?


Solution

  • Yes, it's possible to send custom verification codes but you need to contact Twilio Sales if you want to use this feature. Then, you can use the following snippet to send them:

    const accountSid = process.env.TWILIO_ACCOUNT_SID;
    const authToken = process.env.TWILIO_AUTH_TOKEN;
    const client = require('twilio')(accountSid, authToken);
    
    client.verify.v2.services('VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
                    .verifications
                    .create({
                       customCode: '867530',
                       to: '+15017122661',
                       channel: 'sms'
                     })
                    .then(verification => console.log(verification.sid));
    

    Here's also the docs page.