userId to someone else’s and impersonate them.
This page covers three approaches to passing context securely, each suited to different integration architectures.
The Problem
Consider a script-tag integration where you pass a user ID as an extra parameter:"user-123" to "user-456". Any downstream function that trusts this value is now operating on the wrong user’s data.
All three approaches below solve this by ensuring user identity is verified server-side before it reaches your flow.
Approach 1: External JWT with Public Key Verification
If your application already issues JWTs to authenticated users (e.g. via an identity provider like Auth0, Cognito, or Keycloak), Dial AI can validate those tokens directly and extract claims from them.How It Works
- Your identity provider issues a signed JWT to the user when they log in
- The user’s browser passes this JWT to Dial AI when creating a chat session
- Dial AI verifies the JWT signature against your provider’s public keys (via a JWKS endpoint)
- Dial AI checks the issuer claim matches your configured issuer
- Verified claims (e.g.
sub,accountId) are extracted and made available as internal parameters
Setup
To configure external JWT verification, provide Dial AI with:- JWKS URL: The endpoint where your identity provider publishes its public keys (e.g.
https://your-idp.com/.well-known/jwks.json) - Issuer: The expected
issclaim in the JWT (e.g.https://your-idp.com/) - Tenant: Which Dial AI tenant this JWT configuration applies to
When to Use This
- You already have an identity provider that issues JWTs with a JWKS endpoint
- You want a zero-backend-work integration — the browser can pass the token directly
- You need access to multiple claims from the token (e.g. user ID, roles, email)
Approach 2: Server-Side Token Verification
If your users authenticate with tokens that aren’t JWTs, or you need to verify additional state beyond what’s in a token (e.g. checking that an account is still active), you can verify the user’s identity via a server-side request before passing context to Dial AI.How It Works
- The user logs in to your application and receives a session token
- When starting a chat, your frontend sends the session token to your backend
- Your backend validates the token against your system of record (database, auth service, etc.)
- Your backend creates a chat session via the Dial AI API, passing verified context as
extraInternalParams - The chat link or session ID is returned to the frontend
Example Flow
When to Use This
- Your auth system doesn’t use JWTs, or uses opaque tokens
- You need to check live state (account status, permissions) at chat-creation time
- You want full control over what context is passed to Dial AI
Approach 3: Backend-Created Chat Links with Baked-In Context
Dial AI supports creating chat links via API with context permanently embedded in them. This is especially useful for short-lived, user-specific sessions.How It Works
- Your backend authenticates the user through your own auth system
- Your backend calls the Dial AI API to create a chat link, including verified user context in
extraInternalParams - The chat link UUID is returned to the frontend
- The frontend uses this link to open the chat — the baked-in context is automatically attached to every conversation created with this link
Permanent Chat Links
Create a chat link with context that persists until explicitly deleted:extraInternalParams: Context baked into the link. Every chat created with this link will have these values as internal parameters. The client cannot override them.settableInternalParams: Parameters the client is allowed to set when creating a chat. Use this for non-sensitive context like UI preferences. If a client attempts to set a parameter not in this list, the request is rejected.
Temporary Chat Links with JWT Claim Extraction
For short-lived sessions, create a temporary chat link that automatically extracts claims from the caller’s JWT:duration: Link lifetime in seconds (must be positive, maximum 6 hours)verifiedExtraInternalParams: Maps parameter names to JWT claim extraction rules. Dial AI reads the specified claim from the caller’s verified JWT and bakes it into the link. If the claim is missing or not a string, the request fails.
When to Use This
- You want the simplest possible frontend — just a chat link UUID, no token handling
- You need per-user or per-session chat links with guaranteed context
- You want to limit which parameters the client can influence via
settableInternalParams
Comparison
| External JWT | Server-Side Verification | Backend-Created Links | |
|---|---|---|---|
| Frontend complexity | Low — pass existing JWT | Low — call your backend first | Lowest — just a UUID |
| Backend work | None (configuration only) | Moderate — verification endpoint | Moderate — link creation endpoint |
| Identity source | JWT claims | Your system of record | Your system of record or JWT claims |
| Context flexibility | All JWT claims available | Full control | Baked at link creation |
| Session lifetime | Per-token expiry | Per-link (optional expiry) | Per-link (optional expiry) |
Using Context in Flows
Regardless of which approach you use, the verified context arrives in your flow as internal parameters. Functions can access these values as inputs by declaring them as internal parameters (context parameters). For example, a “Look Up Account” function could takeuserId as an internal parameter and use it to query your database — knowing that the value was verified and cannot have been tampered with by the end user.