0
votes

I am making a simple to the verify api from a Twilio Function triggered in a studio flow.

The error I am recieving is "verifications resource not found".

I assumed it was an authentication issue, but I have the correct SIDS and have checked that a number of times.

Not sure what I am missing.

const accountSid = process.env.ACCOUNT_SID;
const authToken = process.env.AUTH_TOKEN;
const client = require('twilio')(accountSid, authToken);
const functions = Runtime.getFunctions();
const formatPhone = require(functions['formatters/formatPhone'].path);

exports.handler = function (context, event, callback) {
  const verifyPhone = formatPhone.toSearch(event.verifyPhone);
  const verifyType = event.verifyType;

  client.verify
    .services('<Verify SID>')
    .verifications.create({ to: '+1' + verifyPhone, channel: verifyType })
    .then((verification) => {
      console.log(verification.sid);
      callback(null, 'done');
    })
    .catch((err) => callback(err, null));
};

I can run this code from my machine and hit it from studio using NGROK and an http widget instead of a function.

SAME CODE.

I feel that it may be the work of Legacy Systems!

1

1 Answers

0
votes

So as strange as it sounds it ended up being a library versioning issue.

npm i 'twilio'

and then pushed again to the server

twilio serverless:deploy --override-existing-project

I also realize that I didn't list the error originally. I have edited it to make more sense as to the problem I was having.