Hey Team,
I was wondering if someone could assist me in completing my blog on Twilio-AuthActions implementation for custom code solutions. Any guidance you can offer would be greatly appreciated.
I have successfully implemented the code to send SMS on Actions.
exports.onExecuteSendPhoneMessage = async (event, api) => {
const accountSid = event.secrets.TWILIO_ACCOUNT_SID;
const authToken = event.secrets.TWILIO_AUTH_TOKEN;
const verifySid = event.secrets.TWILIO_VERIFY_SID;
const client = require(‘twilio’)(accountSid, authToken);
try {
const verification = await client.verify.v2.services(verifySid)
.verifications
.create({
to: event.message_options.recipient,
channel: event.message_options.message_type === “voice” ? “call” : event.message_options.message_type,
customCode: event.message_options.code
});
console.log("verification " + verification.sid + " created for user " + event.user.user_id);
} catch (error) {
console.log(JSON.stringify(error));
throw new Error("Error sending phone message " + error.message);
}
};
This Actions logs a Verification SID in the logs -VE3XXXXXXXXXXXXXXXXXXX
As this involves a custom code implementation, could you please clarify how your customers can verify the successful MFA conversion? What data is sent to their event streams, and how would you suggest retrieving this information to provide feedback to the Twilio system indicating that the OTP conversion has been completed and approved?
Here’s the recommended logic for updating the Twilio system. However, I’m not sure how to retrieve the verification SID from the above and also check the status of MFA conversion. Can you provide more information or guidance?
I need to make another actions call that retrieves both the logs from first action call and also the otp conversion data.
client.verify.v2.services(‘VAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX’)
.verifications(‘VEXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX’)
.fetch()
.then(verification => console.log(verification.status));
I appreciate your help!
Cheers,
Pooja