You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create automatic response rules with keyword matching, regex patterns, cooldowns, and conditional triggers. Use when users want to set up auto-replies, scheduled messages, or pattern-based bot responses.
emoji
🤖
Auto-Reply - Complete API Reference
Create rules for automatic responses based on patterns, keywords, and conditions.
Chat Commands
List Rules
/autoreply list List all rules
/autoreply active Show active rules only
/autoreply stats Rule statistics
// Keyword matchawaitautoReply.addRule({name: 'greeting',pattern: {type: 'keyword',value: 'hello',caseSensitive: false,},response: 'Hi there! How can I help?',});
// With conditionsawaitautoReply.addRule({name: 'trading-hours',pattern: {type: 'keyword',value: 'trade',},conditions: [// Only during market hours{type: 'time',start: '09:30',end: '16:00',timezone: 'America/New_York',},// Only on weekdays{type: 'day',days: ['mon','tue','wed','thu','fri'],},// Only for certain users{type: 'user',userIds: ['user-123','user-456'],},],response: 'Markets are open! What would you like to trade?',elseResponse: 'Markets are closed. Try again during trading hours.',});
Add Cooldown
// Prevent spamawaitautoReply.addRule({name: 'faq',pattern: {type: 'keyword',value: 'faq',},response: 'Check our FAQ at https://...',cooldown: {perUser: 60000,// 60s per userperChannel: 10000,// 10s per channelglobal: 5000,// 5s global},});
Dynamic Responses
// Response with variablesawaitautoReply.addRule({name: 'welcome',pattern: {type: 'exact',value: '!welcome',},response: 'Welcome {{user.name}}! You joined {{user.joinDate}}.',variables: {'user.name': (ctx)=>ctx.user.displayName,'user.joinDate': (ctx)=>ctx.user.createdAt.toDateString(),},});// Response with API callawaitautoReply.addRule({name: 'portfolio',pattern: {type: 'keyword',value: 'portfolio',},response: async(match,ctx)=>{constportfolio=awaitgetPortfolio(ctx.user.id);return`Your portfolio: $${portfolio.totalValue.toFixed(2)}`;},});
// Test which rules would matchconstmatches=awaitautoReply.test('hello world',{userId: 'user-123',channelId: 'telegram-456',});for(constmatchofmatches){console.log(`Rule: ${match.rule.name}`);console.log(`Response: ${match.response}`);}