A common pattern: you want to ask certain users for feedback, but once they’ve completed the interview, stop showing the prompt. This guide walks through the full integration — from checking capacity, to handling the webhook, to fetching the transcript.
What you’ll build
- Check if your study is accepting responses before showing the prompt
- Open the interview in a new tab when the user clicks
- Receive a webhook when the interview completes
- Fetch the transcript via API
- Mark the user in your database so the prompt doesn’t appear again
Prerequisites
- A userjourneys.ai account with an active study
- An API key
- A server that can receive HTTPS POST requests (for the webhook)
Step 1: Configure the webhook
Set up a webhook so userjourneys.ai notifies your server when an interview completes. You only need to do this once per project.
The response includes a signing_secret — save it. You’ll need it to verify incoming webhooks.
The signing secret is only returned once. Store it securely (e.g. in an environment variable). If you lose it, delete the webhook and create a new one.
See Webhooks for the full API reference.
Step 2: Check study capacity
Before showing the prompt, verify that the study can accept responses. This prevents showing a prompt that leads to a closed study.
Cache this response for a few minutes. Study capacity doesn’t change often, and caching avoids unnecessary API calls.
See Studies for the full API reference.
Step 3: Show the prompt and open the interview
On your frontend, show a prompt to users who haven’t completed the interview yet. When they click, open the interview link in a new tab.
The interview_link comes from the study object you fetched in Step 2. It looks like https://app.userjourneys.ai/i/xK9mR2pQ.
Appending ?reference_id= to the link passes the user’s identity through to the webhook payload. This is how you match a completed interview back to the user who clicked — even if multiple users are interviewing at the same time. You can pass any identifier: a user ID, email, UUID, or whatever your system uses.
Step 4: Handle the webhook and fetch the transcript
When a user finishes the interview, userjourneys.ai sends a POST request to your webhook URL. Verify the signature, fetch the transcript, then update your database.
Always verify the signature before processing the webhook. Use crypto.timingSafeEqual (Node.js) or hmac.compare_digest (Python) to prevent timing attacks.
What the payload looks like
See Webhooks — Event: interview.completed for the full payload reference.
Step 5: Stop showing the prompt
Once your database is updated, the check from Step 3 handles the rest — user.interview_completed is now true, so the prompt won’t appear again.
That’s it. The full flow:
- User sees the prompt -> clicks -> interview opens in a new tab
- User completes the interview -> userjourneys.ai sends a webhook
- Your server verifies the signature -> fetches the transcript -> marks the user as completed
- Next time the user loads the page -> no prompt
Testing
Use a tool like webhook.site to inspect webhook payloads during development. Point your webhook URL there, complete a test interview, and verify the payload arrives.
Once you’re seeing payloads, switch the URL to your real server and test the full flow end-to-end.