Get a memory-aware agent running with Threadline in a few minutes.
01
Store the key in your secrets manager (e.g. THREADLINE_KEY in
.env).
02
npm install threadline-sdk03
Threadline exposes a tiny surface area:
tl.inject(userId, basePrompt) — returns a context-enriched prompt.
tl.update({ userId, userMessage, agentResponse }) — updates the
user's context.
Example — Express.js chatbot with memory
import express from "express"
import bodyParser from "body-parser"
import { Threadline } from "threadline-sdk"
const app = express()
app.use(bodyParser.json())
const threadline = new Threadline({
apiKey: process.env.THREADLINE_KEY!,
baseUrl: process.env.THREADLINE_BASE_URL ?? "http://localhost:3000",
})
app.post("/chat", async (req, res) => {
const { userId, message } = req.body as { userId: string; message: string }
// 1) Build a base system prompt for your agent.
const basePrompt = "You are a concise, helpful assistant for this user."
// 2) Ask Threadline to inject user context.
const injectedPrompt = await threadline.inject(userId, basePrompt)
// 3) Call your model using the injected prompt.
// Replace this with your model integration (OpenAI, Anthropic, etc.)
const agentResponse = `You said: ${message}\n\n(Injected context applied here.)`
// 4) Send the reply back to the client.
res.json({ reply: agentResponse })
// 5) Tell Threadline what just happened so it can update context.
await threadline.update({
userId,
userMessage: message,
agentResponse,
})
})
app.listen(3001, () => {
console.log("Memory-aware chatbot listening on :3001")
})As users talk to your chatbot:
Threadline learns their communication style, ongoing tasks, key relationships, domain expertise, preferences, and emotional state signals.
tl.inject() returns system prompts that reflect this context, so the same user feels
known no matter which agent they're using.
The user can always inspect and edit this context from the /account trust dashboard.
Next:
Wire the same Threadline client into your other agents (email, support, coding).
Explore the API Reference and SDK Reference for details and advanced usage.