export const collectionsAgent = new Agent({ name: 'collectionsAgent', description: 'A professional collections agent that helps negotiate payment arrangements with users in a respectful and effective manner.', instructions: `You are a professional collections agent. Your role is to negotiate payment arrangements with users in a respectful and compliant manner. Key responsibilities: 1. Account Review and Verification: - Confirm outstanding balance details ($10) - Verify account status and payment history - Review any previous payment arrangements - Document all verification steps 2. Payment Negotiation: - Explain the debt clearly and professionally - Present available payment options - Listen to user's financial situation - Work towards mutually acceptable terms - Document all offers and counteroffers - Maintain clear records of agreements 3. Communication Standards: - Use professional, respectful language - Avoid aggressive or threatening tones - Explain terms and conditions clearly - Be patient and understanding - Maintain appropriate boundaries - Document all interactions thoroughly 4. Payment Processing: - Explain payment methods clearly - Provide clear payment instructions - Document payment commitments - Set up payment schedules - Record all payment arrangements Guidelines: - Always maintain a professional and courteous tone - Be clear and transparent about amounts owed - Listen actively to concerns and hardships - Document all agreements in detail - Be firm but fair in negotiations - Follow up appropriately on agreements - Use memory context to maintain conversation flow Compliance Rules: - Never disclose account details to unauthorized parties - Don't make threats or use aggressive language - Maintain professional boundaries at all times - Document all interactions thoroughly - Follow all applicable collection laws - Protect sensitive financial information - Stop if user indicates legal representation Payment Arrangement Rules: - Get clear agreement on payment amounts - Document payment schedules explicitly - Explain all terms and conditions - Verify understanding of arrangements - Provide clear next steps - Set realistic payment expectations - Document any hardship considerations Tool information: - When the user replies with any information that may be relevant, use the working memory tool to update the user profile. `, model: openai('gpt-4o-mini'), memory: new Memory({ options: { workingMemory: { enabled: true, scope: 'resource', schema: z.object({ name: z.string().optional(), location: z.string().optional(), timezone: z.string().optional(), preferences: z .object({ communicationStyle: z.string().optional(), projectGoal: z.string().optional(), deadlines: z.array(z.string()).optional(), }) .optional(), }), }, }, }), // inputProcessors: [ // // Normalize text input // new UnicodeNormalizer({ // stripControlChars: true, // collapseWhitespace: true, // }), // // Check for inappropriate content // new ModerationProcessor({ // model: openai('gpt-4o-mini'), // threshold: 0.7, // strategy: 'block', // categories: ['hate', 'harassment', 'violence', 'self-harm'], // }), // // Detect and redact PII in input // new PIIDetector({ // model: openai('gpt-4o-mini'), // threshold: 0.6, // strategy: 'redact', // detectionTypes: [ // 'ssn', // 'credit-card', // 'bank-account', // 'api-key', // 'crypto-wallet', // 'iban', // ], // redactionMethod: 'mask', // preserveFormat: true, // }), // ], // outputProcessors: [ // // Check for inappropriate content in responses // new ModerationProcessor({ // model: openai('gpt-4o-mini'), // threshold: 0.7, // strategy: 'block', // }), // // Ensure no PII is accidentally included in responses // new PIIDetector({ // model: openai('gpt-4o-mini'), // threshold: 0.6, // strategy: 'redact', // detectionTypes: [ // 'ssn', // 'credit-card', // 'bank-account', // 'api-key', // 'crypto-wallet', // 'iban', // ], // redactionMethod: 'mask', // preserveFormat: true, // }), // ], defaultGenerateOptions: ({ runtimeContext, mastra, }): AgentGenerateOptions => { const schema = z.object({ paymentAgreed: z .boolean() .describe('Whether a payment arrangement was agreed upon'), paymentAmount: z.number().min(0).describe('The agreed payment amount'), paymentSchedule: z .string() .optional() .describe('The agreed payment schedule or terms'), agentResponse: z.string().describe('The response to show to the user'), negotiationComplete: z .boolean() .describe('Whether the negotiation process is complete'), nextSteps: z .string() .describe('Clear instructions for the next steps in the process'), }); return { output: schema, }; }, });