/retellai-pack:retellai-sdk-patternsfrom retellai-pack
Provides production-ready Retell AI SDK patterns for voice agent applications: singleton client, typed agent configs, call management with retry, and batch call campaigns.
Ships in retellai-pack. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Production-ready patterns for Retell AI: client singletons, typed agent configurations, call management, and error handling.
retellai-install-authretell-sdk installedimport Retell from 'retell-sdk';
let _retell: Retell | null = null;
export function getRetellClient(): Retell {
if (!_retell) {
_retell = new Retell({ apiKey: process.env.RETELL_API_KEY! });
}
return _retell;
}
interface AgentConfig {
name: string;
voiceId: string;
prompt: string;
functions?: FunctionConfig[];
maxCallDurationMs?: number;
endCallAfterSilenceMs?: number;
}
async function createAgent(config: AgentConfig) {
const retell = getRetellClient();
const llm = await retell.llm.create({
model: 'gpt-4o',
general_prompt: config.prompt,
functions: config.functions,
});
const agent = await retell.agent.create({
response_engine: { type: 'retell-llm', llm_id: llm.llm_id },
voice_id: config.voiceId,
agent_name: config.name,
max_call_duration_ms: config.maxCallDurationMs || 300000,
end_call_after_silence_ms: config.endCallAfterSilenceMs || 10000,
});
return { agentId: agent.agent_id, llmId: llm.llm_id };
}
async function makeCallWithRetry(
fromNumber: string, toNumber: string, agentId: string, maxRetries = 2
) {
const retell = getRetellClient();
for (let attempt = 0; attempt <= maxRetries; attempt++) {
try {
const call = await retell.call.createPhoneCall({
from_number: fromNumber,
to_number: toNumber,
override_agent_id: agentId,
});
return call;
} catch (err: any) {
if (attempt === maxRetries || err.status < 500) throw err;
await new Promise(r => setTimeout(r, 2000 * (attempt + 1)));
}
}
}
async function runCallCampaign(
numbers: string[], agentId: string, concurrency = 3, delayMs = 2000
) {
const results: Array<{ number: string; callId?: string; error?: string }> = [];
const queue = [...numbers];
const active = new Set<Promise<void>>();
while (queue.length > 0 || active.size > 0) {
while (active.size < concurrency && queue.length > 0) {
const number = queue.shift()!;
const p = (async () => {
try {
const call = await makeCallWithRetry(process.env.RETELL_PHONE_NUMBER!, number, agentId);
results.push({ number, callId: call.call_id });
} catch (err: any) {
results.push({ number, error: err.message });
}
await new Promise(r => setTimeout(r, delayMs));
})();
active.add(p);
p.finally(() => active.delete(p));
}
if (active.size > 0) await Promise.race(active);
}
return results;
}
| Pattern | Use Case | Benefit |
|---|---|---|
| Singleton | All SDK calls | One client instance |
| Typed config | Agent creation | Type safety, defaults |
| Retry wrapper | Call failures | Automatic recovery |
| Campaign manager | Outbound calls | Rate-limited concurrency |
Generate a request identifier at the application edge and persist its state before invoking the Retell SDK. If the network response is lost, retrieve the existing result by that identifier or operator-visible correlation data before attempting another call. Keep retries bounded and limited to operations whose outcome can be established; this prevents a transient client failure from creating multiple customer calls.
Apply in retellai-core-workflow-a for agent building.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
retell-ai, voice-agents, telephony, call-management, retry-patterns
30 skills in this plugin
/retellai-advanced-troubleshootingRetell AI advanced troubleshooting — AI voice agent and phone call automation.
Use when working with Retell AI for voice agents, phone calls, or telephony.
Trigger with phrases like "retell advanced troubleshooting", "retellai-advanced-troubleshooting", "voice agent".
/retellai-architecture-variantsRetell AI architecture variants — AI voice agent and phone call automation.
Use when working with Retell AI for voice agents, phone calls, or telephony.
Trigger with phrases like "retell architecture variants", "retellai-architecture-variants", "voice agent".
/retellai-ci-integrationRetell AI ci integration — AI voice agent and phone call automation.
Use when working with Retell AI for voice agents, phone calls, or telephony.
Trigger with phrases like "retell ci integration", "retellai-ci-integration", "voice agent".
/retellai-common-errorsDiagnose and fix Retell AI voice agent errors: call failures, webhook issues, voice quality.
Use when encountering Retell AI errors, debugging call issues, or troubleshooting agents.
Trigger with phrases like "retell error", "call failed", "voice agent not working", "retell debug".
/retellai-core-workflow-aRetell AI core workflow a — AI voice agent and phone call automation.
Use when working with Retell AI for voice agents, phone calls, or telephony.
Trigger with phrases like "retell core workflow a", "retellai-core-workflow-a", "voice agent".
/retellai-core-workflow-bRetell AI core workflow b — AI voice agent and phone call automation.
Use when working with Retell AI for voice agents, phone calls, or telephony.
Trigger with phrases like "retell core workflow b", "retellai-core-workflow-b", "voice agent".
npx claudepluginhub jeremylongshore/tons-of-skills-marketplace --plugin retellai-packOther plugins' skills for the same job