Quickstart: Embedded Flow with Inquiry Template
An Embedded Flow embeds Persona’s verification UI directly into your website as an iframe.
There are two ways to use Embedded Flow:
- Generate inquiries from an inquiry template (Minimal code required)
- Pre-create inquiries via API (More code required)
This guide walks you through the first method: generating inquiries from an inquiry template.
You will:
- Create a web page that shows a user onboarding flow
- Configure a button to open a Persona verification via Embedded Flow
- Test that your flow works
- View inquiry results via API
- (optional) Set up and receive webhook alerts about changes to the inquiry
Alternative: Pre-create inquiries
Generating inquiries from an inquiry template (the method shown in this guide) is the fastest way to implement Embedded Flow. However, due to limitations of this method, we recommend you pre-create inquiries in production. To learn how, see Quickstart: Pre-create inquiries for Embedded Flow.
Prerequisites
You’ll need:
- A Persona account
- Python installed locally
- This guide shows how to host an HTML page on
localhostusing Python, but you can adapt the setup to another language.
- This guide shows how to host an HTML page on
Before you start, you should:
- Understand what an inquiry is
- Sign into the Persona dashboard and switch into your Sandbox environment
Scenario
A user named Alexander Sample just joined your dog walking app as a dog walker. You want to verify his identity to ensure the safety of users on your service.
Alexander’s user ID in your app is “usr_ABC123”. During account signup in your app, he stated his birthdate is August 31, 1977.
Step 1: Create an inquiry template
Every inquiry is created from an inquiry template, which defines details like the specific verification logic and UI text and branding of that inquiry. You can think of inquiry templates as a mold that lets you create many inquiries.
Persona offers a suite of solutions that include preconfigured inquiry templates. In this tutorial, use the “KYC” solution to verify your dog walkers.
Follow these instructions to add the “KYC” solution to your Sandbox environment.
Step 2: Locate the inquiry template ID
Find the ID of the newly-created inquiry template.
In the Persona dashboard, navigate to Inquiries > Templates. Find the “KYC” template in the list of inquiry templates, and note the value in the ID field. The value should begin with itmpl_.
Step 3: Create the web page
Now, set up the user onboarding page that will display the verification flow to Alexander.
-
Create a new directory called
embedded-flow-demo/. -
Inside that directory, create a file called
onboarding.htmlwith the following code:
-
Start a local Python server to host this file:
-
Load
localhost:8000/onboarding.htmlin a browser to view the page.
You should see the onboarding flow for our newly-registered dog walker:
Right now, the “Start Verifying” button doesn’t work. You’ll wire it up in Step 5.
Step 4: Add the Persona Web SDK
The web page code does not yet contain the Persona SDK. Let’s add it.
- In the
<head>section ofonboarding.html, add the following lines right after the closing</style>tag:
- In the code you added, replace
X.Y.Z.in the CDN URL with the latest version of the SDK. Check the SDK changelog for the latest version.- For example, if the latest version is 5.4.0:
https://cdn.withpersona.com/dist/persona-v5.4.0.js
- For example, if the latest version is 5.4.0:
Alternative: npm
You can also install the SDK as an npm package.
Step 5: Make the button open the Persona flow
Right now, if you click “Start Verifying”, you see an alert. Make the button trigger a Persona verification flow instead.
- Locate the following lines in the HTML:
- Replace those lines with the following code:
- In the code, fill in the following values:
- templateId: Replace
itmpl_XXXXXXXXXXXXXwith your inquiry template ID from Step 2. - environmentId: Replace
env_XXXXXXXXXXXXXwith the ID of the Persona environment you’re using. In this tutorial, we’re using your Sandbox environment. Here’s how to find the ID of your environment.
- templateId: Replace
About the code
This code creates a new Persona web client (new Persona.Client({...})). Note that:
- A new inquiry is created when
new Persona.Client({...})is invoked. - You must provide a
templateIdat minimum. If you don’t provide an environment ID, by default your production environment is used. - Callbacks, like
onCompleteandonError, let you coordinate your app’s UI with changes in the Persona UI. Do not rely on them for up-to-date data about the state of the inquiry. Use webhooks (Step 6) for logic that depends on inquiry state.
This code demonstrates two best practices for initiating inquiries:
- Pass a reference ID: “usr_ABC123” is set as the
reference-id. A reference ID lets you tag an inquiry as being associated with a particular end user. Persona recommends using the user’s UID from your internal systems. - Prefill inquiry fields: We prefill the inquiry with information we know about Alexander: his first name, last name, and birthdate. Providing this information helps streamline the verification experience for Alexander, and helps increase your confidence that his information is valid.
Step 6: Set up a webhook (optional)
You can receive notifications when any inquiry’s state changes. For example, you can be alerted when any inquiry is started by a user, or when any inquiry is completed. See the full list of inquiry events you can be alerted about.
To receive automatic notifications:
- Create a webhook endpoint (for a sample server, see Webhook quickstart)
- In the dashboard, navigate to Webhooks > Webhooks.
- Add your endpoint URL
- Select the following “Enabled events”:
inquiry.started,inquiry.completed,inquiry.approved,inquiry.declined, andinquiry.failed
For this tutorial, you can skip webhooks and view results in the dashboard.
Step 7: Test the flow
In production, Alexander would click the “Start Verifying” button and complete verification on his own.
For this tutorial, you’ll complete the flow yourself as Alexander:
- Click “Start Verifying”. The Persona verification flow will open in a modal.
- Click through the verification steps.
- Do not enter real personal information, since this is Sandbox.
- Keep the “Pass verifications” toggle enabled (visible at the bottom of the flow) to simulate passing all the checks.
- After you complete the flow, note the inquiry ID printed to the “Debug info” section of the page. You’ll use it in Step 9.
The inquiry ID will look like inq_XXXXXXXXXXXXX.
Step 8: (optional) Inspect webhook events
If you set up the webhook in Step 6, check your server logs. You should see events from inquiry.started, inquiry.completed, and inquiry.approved.
Note: If you want to receive the inquiry.failed event, you can reload the page and click “Start Verifying” again. Then click through the verification flow, this time with the “Pass verifications” toggle disabled.
Step 9: View inquiry results via API
Now that you’ve completed the inquiry, take a look at the results. Note that because this inquiry was created in Sandbox, some of the data will be demo data.
Retrieve the inquiry details:
The response includes:
data.attributes.reference-id: The reference ID you provideddata.attributes.status: Should beapproveddata.attributes.fields: Prefilled and collected data
Note that:
- The final status of your inquiry is
approvedinstead ofcompletedbecause the KYC solution includes Workflows that automatically approve passing inquiries. See the Next Steps section to learn more. - Because this inquiry was created in Sandbox, much of the data will be null or empty. Keep in mind you’ll see different outputs in Production.
Alternative: View in Dashboard You can also view results in the dashboard at Inquiries > All Inquiries. See this Help Center guide for details.
Summary
In this tutorial, you:
- Created a web page that shows a step in a user onboarding flow
- Added the Persona Web SDK
- Configured a button click to open a Persona verification in a modal (Embedded Flow)
- Tested the complete flow
- (Optional) Received alerts about changes to the inquiry, via webhook
- Retrieved inquiry results via API
This is a complete Embedded Flow integration that creates inquiries using an inquiry template.
Limitations of this approach
This implementation is simple, but has drawbacks:
- Users may create duplicate inquiries: Each time a user clicks “Start Verifying”, a new inquiry is created. If they click multiple times, they will create multiple inquiries, which create noise in your data.
- Users can’t resume inquiries: If a user reloads the page mid-flow, they must start over with a new inquiry.
- Users can spoof information: Since the client is providing the user information (user ID and user fields), this information could be spoofed by the user.
To address these issues, Persona recommends you pre-create inquiries on your server in production. See Quickstart: Pre-create inquiries for Embedded Flow to learn how.
Next steps
Enhance this integration:
- Pre-create inquiries: Complete the next quickstart to learn how Persona recommends you deploy Embedded Flow in production.
- Subscribe to additional events: Understand the different inquiry events you can be alerted about, and the difference between the “Done” and “Post-inquiry” phases.
- Learn webhook best practices: In production, you’ll need to handle duplicate events and other issues.
Explore further:
- Explore the KYC solution: The KYC solution includes two Workflows and a Case template. In this tutorial, the Workflows seamlessly ran in the background and changed the final status of your inquiry from
completedtoapproved. - Explore other integration methods: Try Hosted Flow if you’re looking to distribute verification flows as links. See Choosing an integration method.

