Skip to content

Pass verified JWT session context into chatbot webhook actions safely

Prevent account-spoofing attacks by binding cryptographic user identity tokens between your web/mobile app, AI runtime, and backend APIs.

Copy the prompt and paste it into the AI assistant you already use.

Security architecture for authenticated chat actions

  1. 01

    Require signed server-issued identity tokens

    Never accept plain `user_id` or `email` strings from browser JavaScript—sign short-lived JWTs or HMAC hashes using a server-side secret.

  2. 02

    Inject `user_id` at the tool executor, not LLM

    Omit `user_id` from LLM-writable tool arguments entirely; bind the caller's verified identity inside backend tool-execution middleware.

  3. 03

    Trigger step-up auth on sensitive mutations

    Even inside logged-in sessions, require a fresh MFA/OTP check before executing payout destination edits, API key reveals, or account deletion.

  4. 04

    Clear widget state atomically on app logout

    Hook `chat.shutdown()` into your app's logout handler so shared computers or kiosk browsers never expose prior user transcripts.

Questions and answers

What happens if an developer lets the LLM pass `user_id` as a tool parameter?

Prompt-injection attackers can coax the LLM into calling `get_invoices(user_id='victim_123')`—creating a critical IDOR data breach.

How should long chat sessions handle 15-minute expiring access tokens?

Register a silent token-refresh callback in the widget SDK so expiring JWTs renew seamlessly before invoking authenticated webhooks.

How do we authenticate users on WhatsApp or SMS where no browser JWT exists?

Send a short-lived one-time verification link or 6-digit code to their account email/authenticator and bind the verified session for a fixed TTL.

Learn more

Related guides and background articles for this task