0
Check Verification Token
One script reply has been approved by the moderators Verified

Check if user-provided token is correct. See the documentation for more information

Created by hugo697 423 days ago Viewed 8993 times
0
Submitted by hugo697 Bun
Verified 423 days ago
1
import { Twilio } from "twilio";
2

3
type Twilio = {
4
  accountSid: string;
5
  token: string;
6
};
7

8
export async function main(
9
  twilio: Twilio,
10
  token: string,
11
  serviceId: string,
12
  phoneNumber: string
13
) {
14
  const client = new Twilio(twilio.accountSid, twilio.token);
15
  const verificationCheck = client.verify.v2
16
    .services(serviceId)
17
    .verificationChecks.create({
18
      to: phoneNumber,
19
      code: token,
20
    });
21
  return verificationCheck;
22
}
23