Use AI to integrate Personal Agent Protocol
Use AI to integrate Personal Agent Protocol
- An Auth0 tenant with the Personal Agent Protocol beta enabled. Use a development tenant: this quickstart changes tenant settings
- Node.js 22 or newer, and Git
- ngrok with a free account and its authtoken configured. Agents only call public HTTPS hosts
node --version && git --version && ngrok --versionCommands are for macOS and Linux shells. On Windows, use WSL.Get Started
You start from Drift Bean Demo, a sample coffee store with Auth0 login and guest carts already working. It has a Next.js website, an Express website, and one Node.js API that both websites use. You turn on the Personal Agent Protocol in your tenant, add it to the code with the Auth0 SDKs, and shop the store with a real personal agent, the Poppy Playground. To get started, pick your website’s stack in the stack selector on the right-hand menu. The steps follow your stack choice.apps/web uses @auth0/nextjs-auth0. The API uses @auth0/auth0-api-js. The starter already has both SDKs installed.Install the Auth0 CLI and log in
poppy and agents commands:auth0 command in this quickstart runs on the CLI’s active tenant, so check that auth0 tenants list marks it as active, and that the build has the Poppy commands with auth0 poppy --help. If logging in as a user fails, log in with a machine-to-machine application instead:Get the starter store
starter branch, which contains the sample app without Auth0 configured:Connect the store to Auth0
- Auth0 CLI
- Management API
npm run tenant makes its changes with your CLI login and writes .env.local. Run it without --yes to see the plan first. If your login lacks a permission, it prints the auth0 login --scopes command that adds it. If your tenant already has an application named Drift Bean Storefront, it updates that one: pass --client-id to use another.Give the store public URLs
auth0-poppy-sample folder, open tunnels to the store and its API, and leave it running:.env.local. In the first terminal, stop the store with Ctrl+C and start it again, so it reads them.In a third terminal in the same folder, load the URLs into your shell, and run the rest of this quickstart there:Turn on Personal Agent Protocol in your tenant
poppy.json, the discovery file your website serves:- Auth0 CLI
- Management API
setup shows every change before and after, and asks you to confirm. It marks the settings that affect every application in your tenant, and points the application’s Login URI at this store. It also warns that http://localhost:4000 isn’t an https identifier: that’s expected for this local sample.WEB_UNSCOPED, from step 4, is false for the Next.js website: it asks for the API’s scopes at login, so the API can limit an agent to what the customer approved. It is true for the Express website: @auth0/auth0-express can’t ask for API scopes, so an agent joined through it has the customer’s full access there, and the discovery file says so.Allow a personal agent
- Auth0 CLI
- Management API
npm run tenant -- --store-url adds the store’s public URLs to the application and never removes existing ones.Serve discovery and accept agent browsers
/.well-known/poppy.json and /.well-known/oauth-protected-resource, and accepts the login that ends an agent’s browser join.apps/web/poppy.json, which auth0 poppy setup wrote in step 5, as it is, and the starter’s proxy.ts already lets /.well-known/* through. Pass the file to the client:Show who is driving the browser
apps/web/app/layout.tsx with import { AgentBanner } from "./components/AgentBanner"; and render <AgentBanner /> at the top of <body>:Verify agent requests at your API
Poppy-Session header, and an access token once the customer signs in. The SDK verifies both and returns the agent’s Session. Key the cart by that Session, so a cart filled as a guest is still there after sign-in. Both websites use this API, so this step is the same for both stacks. For the Express API SDK, read Add to Your API.Add the poppy options to the API client:verifyPoppyRequest:apps/carts-api/src/app.ts, replace the cartKey helper near the top of the file, so it keys the cart by the Session:app.post("/orders", …) route inside createApp, so a signed-out agent is asked to sign the customer in, and a signed-in agent needs orders:write:Poppy-Session header is chosen by the agent. Act on the customer’s account only with the sub of a verified access token.Shop with a personal agent
Ctrl+C and start it again. Then check discovery, your tenant, and the agent end to end:- Auth0 CLI
- Management API
poppy:browser-sign-in, and D14 about the API’s localhost identifier. Each failure prints a FIX line that tells you how to resolve it.$APP_BASE_URL, and ask the agent to buy a bag of beans. It adds them to the cart as a guest, and the store shows Shopping via https://poppyplayground.dev/agent.json: guest. At checkout, it asks you to sign in: log in on your Auth0 login page and approve the agent. The agent joins again as you, finds the guest cart still there, and places the order.$APP_BASE_URL/orders in your own browser. The order shows Placed by agent. A personal agent shopped your store as a guest, signed you in with your approval, and placed an order that names it.Troubleshooting
The agent ignores your store
The agent ignores your store
auth0 poppy doctor "$POPPY_DOMAIN". Agents compare your discovery files with your tenant character for character, and skip your store without saying why. Most often the tunnel URL changed since you turned on Poppy, or the store wasn’t restarted after npm run tunnel. Repeat steps 4 to 6.invalid_request: no connections enabled for the client
invalid_request: no connections enabled for the client
invalid_request: Client configuration requires the use of Proof-of-Possession mechanism
invalid_request: Client configuration requires the use of Proof-of-Possession mechanism
proof_of_possession command in step 6.The agent is signed in, but the store still treats it as a guest
The agent is signed in, but the store still treats it as a guest
Prompts are not allowed for an impersonated session for the storefront. The login that ends a browser join can’t show any screen. Check that your API allows skipping consent for first-party applications, and that no post-login Action renders a form during the join.The signed-in join fails
The signed-in join fails
poppy:browser-sign-in. Repeat step 6.invalid_session at your API
invalid_session at your API
PUBLIC_ORIGIN. Check that PUBLIC_ORIGIN is the API’s tunnel URL, and that the store restarted after npm run tunnel.The Playground can't reach your store
The Playground can't reach your store
npm run tunnel are both still running, and that $APP_BASE_URL opens in your browser.See the finished store
Themain branch of the sample is the complete store. It marks each Poppy integration point POPPY n/6 in the code, and adds a code tour, labs, a scripted agent for testing without a tenant, and deploy guides. Compare it with yours: