<script src="https://cdn.withpersona.com/dist/persona-v3.5.1.js"></script>
<script>
const client = new Persona.Client({
templateId: "tmpl_JAZjHuAT738Q63BdgCuEJQre",
environment: "sandbox",
onLoad: (error) => {
if (error) {
console.error(`Failed with code: ${error.code} and message ${error.message}`)
}
client.open();
},
onStart: (inquiryId) => {
console.log(`Started inquiry ${inquiryId}`);
},
onComplete: (inquiryId) => {
console.log(`Sending finished inquiry ${inquiryId} to backend`);
fetch(`/server-handler?inquiry-id=${inquiryId}`);
},
onEvent: (name, meta) => {
switch (name) {
case 'start':
console.log(`Received event: start`);
break;
default:
console.log(`Received event: ${name} with meta: ${JSON.stringify(meta)}`);
}
}
});
</script>