Quick Start#
cd examples/<example>
cp .env.example .env # edit with your values
npm install
pinecall run agent/index.js # or agent/index.tsRunnable Examples#
Simple Agent#
examples/simple/ — The minimal Pinecall setup. A voice agent with JsonFileHistory for automatic call persistence.
What it shows:
agent/index.jsconvention — auto-connect, export agentgreetingin config — nocall.startedhandler neededJsonFileHistoryfor automatic call persistence- Auto-restored history for returning callers
// agent/index.js
const pc = new Pinecall();
export const agent = pc.agent("simple-agent", {
voice: "elevenlabs/sarah",
stt: "deepgram/flux",
llm: "openai/gpt-4.1-mini",
phoneNumber: process.env.PHONE,
greeting: "Hello! How can I help you today?",
history: new JsonFileHistory("./data/calls.json"),
});📖 Related: Inbound Voice · Conversation History
Reservations Agent#
examples/reservations/ — A restaurant reservation agent with tools. Demonstrates the tool() + Zod pattern with agent/index.ts and agent/tools.ts.
What it shows:
tool()with Zod schemas for type-safe tool definitions- Tools in a separate
agent/tools.tsmodule - Agent exports pattern —
export const agent = pc.agent(...) pinecall run agent/index.tsfor live development
// agent/tools.ts
export const checkAvailability = tool({
name: "checkAvailability",
description: "Check table availability for a date and party size.",
schema: z.object({
date: z.string(),
time: z.string(),
partySize: z.number(),
}),
execute: async ({ date, time, partySize }) => ({ available: true, table: "garden terrace" }),
});📖 Related: Tool definitions · CLI reference
Turn Detection#
examples/turn-detection/ — Debug turn detection events in real-time. Switch between Flux (native turns) and Nova-3 (SmartTurn + Silero) by changing MODEL in .env.
What it shows:
speech.started,user.speaking,user.messageevent flowturn.pause(SmartTurn analyzing) vsturn.end(confirmed)bot.speaking/bot.finished/bot.interrupted(barge-in)- Colored console output with timestamps
Config via .env:
PHONE=+13049709763
MODEL=nova # "flux" or "nova"
STT_LANG=es # "en", "es", "ar", etc.Key difference to observe:
| Flux | Nova-3 | |
|---|---|---|
turn.pause | ❌ Never | ✅ SmartTurn emits while analyzing |
| Turn speed | ~200ms (native) | ~400-600ms (Silero → SmartTurn) |
📖 Related: Turn Detection Guide · STT Providers
Call Ringing#
examples/ringing/ — Accept or reject incoming calls programmatically. When ringing: true, calls emit call.ringing instead of auto-answering.
What it shows:
call.ringingevent with caller infocall.accept()andcall.reject(reason)flow- Blacklist filtering (reject specific numbers)
- Timeout auto-accept (if SDK doesn't respond in time)
agent.on("call.ringing", (call) => {
if (BLACKLIST.includes(call.from)) {
call.reject("busy");
} else {
call.accept();
}
});📖 Related: Call Ringing Guide
Conversation History#
examples/history/ — Conversation persistence across calls. When the same contact calls again, the agent restores the previous conversation context.
What it shows:
JsonFileHistory— save/load to a JSON filehistory.findByContact()— find prior conversationscall.setHistory()— inject previous messages- Custom
HistoryStoreinterface for your own backend
📖 Related: Conversation History Guide
WhatsApp Dashboard#
examples/whatsapp-dashboard/ — A WhatsApp agent with a human takeover dashboard. Express backend + React frontend with SSE live updates.
What it shows:
agent.addWhatsapp()channel registrationwhatsapp.sessionStarted/whatsapp.message/whatsapp.responseeventsagent.pause()/agent.resume()for human takeoveragent.sendMessage()— human operator sends messagesagent.stream(res)— SSE event stream for React dashboard- Conversation history via
JsonFileHistory
const agent = pc.agent("support", {
llm: "openai/gpt-4.1-mini",
prompt: "You are a helpful customer support agent on WhatsApp.",
history: new JsonFileHistory("./data/conversations.json"),
});
agent.addWhatsapp({
phoneNumberId: process.env.WA_PHONE_NUMBER_ID,
accessToken: process.env.WA_ACCESS_TOKEN,
});📖 Related: WhatsApp Guide · Human Takeover · SSE Streaming
Conceptual Examples (docs only)#
These examples live in the docs as full code walkthroughs — no separate examples/ folder.
| Example | What it covers |
|---|---|
| Browser Widget | WebRTC @pinecall/voice-widget integration |
| Chat Bot | Text-only LLM chat (no audio) |
| Headless Agent | Server-side agent without UI |
| Multi-Channel Bot | Voice + WhatsApp + chat on one agent |
| Turn Detection | Flux vs SmartTurn event comparison |
