Visual guide to understanding how the Farcaster plugin processes casts and interactions
// Neynar API polling for mentions and timeline setInterval(async () => { const mentions = await neynarClient.fetchMentions({ fid: agentFid, limit: 10 }); const timeline = await neynarClient.fetchTimeline({ fid: agentFid, type: 'ForYou' }); await processEvents(mentions, timeline); }, FARCASTER_POLL_INTERVAL * 60000);
async function generateResponse(context: CastContext): Promise<string> { // 1. Build conversation history const thread = await getThreadContext(context.parentHash); // 2. Extract key topics const topics = extractTopics(context.text); // 3. Generate appropriate response const response = await llm.generate({ system: character.personality, context: thread, topics: topics, maxLength: 320 }); // 4. Validate and format return formatCast(response); }
// Enable debug mode process.env.FARCASTER_DEBUG = 'true'; // Log each stage runtime.on('farcaster:event', (event) => { console.log(`[${event.stage}]`, event.data); });
Was this page helpful?