docs/agents/custom-code-agent/setup-your-agent/scaffold-your-project.mdx
After you create an agent in the dashboard, scaffold the bridge application that receives events and runs your handler code.
Open a terminal in the directory where you want the project, then run:
npx novu@latest init -t agent \
--agent-identifier <AGENT_IDENTIFIER> \
-s <NOVU_SECRET_KEY> \
-a <NOVU_API_URL>
The CLI prompts for a project name and creates a starter app. The dashboard also provides a pre-filled copy of this command on the agent setup page with your secret key and API URL already filled in.
A typical scaffold produces a Next.js app with:
<Tree> <Tree.Folder name="app" defaultOpen> <Tree.File name="api/novu/route.ts" /> <Tree.Folder name="novu"> <Tree.Folder name="agents"> <Tree.File name="index.ts" /> <Tree.File name="support-agent.tsx" /> </Tree.Folder> </Tree.Folder> </Tree.Folder> </Tree>api/novu/route.ts exposes your agents over HTTPnovu/agents/index.ts re-exports each agentnovu/agents/support-agent.tsx is the starter handler (name may vary)The /api/novu route is the bridge endpoint. Register it in the dashboard under your agent's bridge URL settings.
You have scaffolded a project with a dev script that runs the bridge application. To run the scaffolded project in local machine:
npx novu@latest dev --port <bridge_application_port> --no-studio
--port is where your app listens (often 3000 or 4000). The CLI tunnels to /api/novu and registers the URL in Novu.