Chatbot Example
The chatbot example (apps/chatbot) is a production-style AI chat app built on Next.js and the Vercel AI SDK. It shows the lightest-touch Walrus Memory integration: wrap the model once, and memory works for every conversation turn.
How it uses Walrus memory
The server wraps the selected model with withMemWal, so recall runs before each generation and the middleware can save new context after each turn:
import { withMemWal } from "@mysten-incubation/memwal/ai";
const model = withMemWal(baseModel, {
key,
accountId,
serverUrl,
maxMemories: 5,
autoSave: true,
});
The UI lets the user enable Walrus Memory, collect a delegate key and account ID, and pass them to the chat API. Everything else stays a normal AI SDK chat app, which is the point: the middleware adds memory without changing the generation code. See AI Integration for the middleware options.
Run it locally
From the repo root:
Source: examples/chatbot.md$ pnpm install
$ cp apps/chatbot/.env.example apps/chatbot/.env
Fill in these variables in apps/chatbot/.env:
AUTH_SECRETOPENROUTER_API_KEYBLOB_READ_WRITE_TOKENPOSTGRES_URLREDIS_URL
Then add the Walrus Memory values from the dashboard:
MEMWAL_PRIVATE_KEYMEMWAL_ACCOUNT_IDMEMWAL_SERVER_URL
Run pnpm --filter chatbot verify:memwal to catch credential mismatches before the first relayer call.
With the environment configured, apply the database migrations and start the app:
Source: examples/chatbot.md$ pnpm --filter chatbot db:migrate
$ pnpm dev:chatbot
The app runs on localhost:3001. To exercise memory end to end, open the app, enable Walrus Memory in the UI, and supply the delegate key and account ID so the UI passes them to the chat API. The chatbot source documents each variable.