Adding Features
Guide to adding new features to MMPS.
Feature Development Workflow
1. Plan
- Identify which bot/service needs the feature
- Design the feature API
- Write tests first (TDD)
2. Implement
- Create service layer
- Create controller layer (if Telegram)
- Implement business logic
3. Test
- Write unit tests
- Test locally with bot
- Verify error handling
4. Document
- Update code documentation
- Add examples
- Update VitePress docs
5. Deploy
- Merge to main
- Deploy to production
- Monitor for issues
Adding Bot Commands
typescript
// features/chatbot/chatbot.controller.ts
private async myCommandHandler(ctx: Context): Promise<void> {
const { chatId, text } = getMessageData(ctx);
const response = await this.chatbotService.myNewFeature(text, chatId);
await ctx.reply(response);
}
init(): void {
this.bot.command('mycommand', (ctx) => this.myCommandHandler(ctx));
}Adding AI Tools
- Create tool file:
shared/ai/tools/{name}/{name}.tool.ts - Define Zod schema
- Implement tool function
- Add to chatbot agent
- Test with bot
See AI Tools for details.
Adding Database Models
- Define type in
types.ts - Create repository functions
- Add database indexes (if needed)
- Test with MongoDB
Adding External Service
- Create service in
services/ - Define types
- Implement API calls
- Add error handling
- Test integration