Bot Quick Start - nself-org/nchat GitHub Wiki
Get started with the nself-chat Bot Framework in 5 minutes.
The bot framework is already integrated into nself-chat. No additional installation required!
cd /Users/admin/Sites/nself-chat
pnpm devThe application will start on http://localhost:3000.
API:
curl http://localhost:3000/api/bots?type=availableResponse:
{
"success": true,
"data": [
{
"id": "reminder-bot",
"name": "Reminder Bot",
"description": "Set reminders for yourself or your team",
"installed": false
},
{
"id": "faq-bot",
"name": "FAQ Bot",
"description": "Answer frequently asked questions",
"installed": false
},
{
"id": "scheduler-bot",
"name": "Scheduler Bot",
"description": "Schedule messages and recurring tasks",
"installed": false
}
]
}API:
curl -X POST http://localhost:3000/api/bots \
-H "Content-Type: application/json" \
-d '{
"botId": "reminder-bot",
"config": {
"enabled": true,
"settings": {
"max_reminders": 25,
"max_duration": 365
}
}
}'Response:
{
"success": true,
"data": {
"id": "reminder-bot",
"name": "Reminder Bot",
"enabled": true,
"manifest": { ... }
},
"message": "Bot installed successfully"
}In any chat channel, use the bot commands:
Reminder Bot:
/remind 5m "Check the build"
/reminders
/cancelreminder rem_abc123
FAQ Bot:
/faq how to reset password
/addfaq "How to reset password?" "Go to Settings > Reset"
/listfaqs
Scheduler Bot:
/schedule 1h "Team meeting reminder"
/recurring 1d "Daily standup reminder"
/scheduled
List Installed Bots:
curl http://localhost:3000/api/bots?type=installedGet Bot Details:
curl http://localhost:3000/api/bots/reminder-botDisable a Bot:
curl -X POST http://localhost:3000/api/bots/reminder-bot/enable \
-H "Content-Type: application/json" \
-d '{"enabled": false}'Update Bot Config:
curl -X PATCH http://localhost:3000/api/bots/reminder-bot \
-H "Content-Type: application/json" \
-d '{
"settings": {
"max_reminders": 50
}
}'Uninstall a Bot:
curl -X DELETE http://localhost:3000/api/bots/reminder-botSet reminders for yourself or your team.
Commands:
-
/remind <time> "<message>"- Set a reminder -
/reminders- List your reminders -
/cancelreminder <id>- Cancel a reminder -
/snooze <id> [time]- Snooze a reminder -
/remindchannel <time> "<message>"- Channel reminder
Example:
/remind 30m "Check the deployment"
/remind 1h "Team standup meeting"
/remind 1d "Submit weekly report"
Automatically welcome new members.
Commands:
-
/setwelcome "<message>"- Set welcome message -
/testwelcome- Preview welcome message -
/disablewelcome- Disable welcomes
Variables:
-
{user}- Username -
{channel}- Channel name -
{memberCount}- Member number -
{date}- Current date -
{time}- Current time
Example:
/setwelcome "Welcome {user}! You're member #{memberCount} 🎉"
Create interactive polls and surveys.
Commands:
-
/poll "<question>" "<options>"- Create a poll -
/quickpoll "<question>"- Yes/no poll -
/pollresults <id>- Show results -
/endpoll <id>- End poll early
Example:
/poll "What's for lunch?" "Pizza | Tacos | Sushi"
/quickpoll "Should we have a team meeting today?"
Answer frequently asked questions.
Commands:
-
/faq <question>- Search FAQ -
/addfaq "<question>" "<answer>"- Add FAQ -
/removefaq <id>- Remove FAQ -
/editfaq <id>- Edit FAQ -
/listfaqs [category]- List all FAQs
Example:
/addfaq "How to reset password?" "Go to Settings > Security > Reset Password"
/faq how to reset password
/listfaqs General
Schedule messages and recurring tasks.
Commands:
-
/schedule <when> "<message>"- Schedule a message -
/scheduled- List scheduled messages -
/cancelschedule <id>- Cancel schedule -
/recurring <interval> "<message>"- Create recurring task -
/recurringtasks- List recurring tasks -
/cancelrecurring <id>- Cancel recurring task
Example:
/schedule 1h "Meeting reminder!"
/recurring 1d "Daily standup reminder!"
/scheduled
Access the bot management UI at:
http://localhost:3000/admin/bots
Features:
- View all installed and available bots
- Search and filter bots
- Enable/disable bots
- Configure bot settings
- View bot statistics
- View bot logs
mkdir -p src/bots/my-bot
cd src/bots/my-bot{
"id": "my-bot",
"name": "My Bot",
"description": "A helpful bot",
"version": "1.0.0",
"author": "Your Name",
"icon": "🤖",
"permissions": ["read_messages", "send_messages"],
"commands": [
{
"name": "hello",
"description": "Say hello",
"examples": ["/hello"]
}
]
}import { bot, command, response, embed } from '@/lib/bots'
import type { CommandContext, BotApi } from '@/lib/bots'
import manifest from './manifest.json'
export function createMyBot() {
return bot(manifest.id)
.name(manifest.name)
.description(manifest.description)
.version(manifest.version)
.permissions('read_messages', 'send_messages')
.command(
command('hello').description('Say hello').example('/hello'),
async (ctx: CommandContext, api: BotApi) => {
return response()
.embed(
embed().title('👋 Hello!').description(`Hi ${ctx.user.displayName}!`).color('#10B981')
)
.build()
}
)
.build()
}
export default createMyBot
export { manifest }Edit /src/lib/bots/bot-registry.ts:
// Add import
import { default: createMyBot, manifest: myBotManifest } from '@/bots/my-bot'
// In registerDefaultBots():
registerBotFactory('my-bot', createMyBot, myBotManifest, {
category: 'Utilities',
featured: false,
tags: ['greeting']
})# Restart the app
pnpm dev
# Install your bot
curl -X POST http://localhost:3000/api/bots \
-H "Content-Type: application/json" \
-d '{"botId": "my-bot", "config": {"enabled": true}}'
# Test in chat
/hello- Check if bot is enabled:
curl http://localhost:3000/api/bots/reminder-bot- Check bot logs (if available):
curl http://localhost:3000/api/bots/reminder-bot/logs- Check server logs:
# Look for errors in terminal- Verify command prefix (default is
/) - Check if bot is in the channel
- Verify bot permissions
- Check for rate limiting
- Bots store data in memory by default
- For persistent storage, implement database integration
- Check bot settings for storage configuration
-
Read the complete guide:
/docs/Bot-Framework-Complete.md -
Explore bot examples:
/src/bots/ -
Check API documentation:
/src/app/api-docs/bots/ - Join the community: Get help and share your bots
-
Documentation:
/docs/Bot-Framework-Complete.md -
Bot SDK:
/src/lib/bots/ -
Example Bots:
/src/bots/ -
API Reference: REST endpoints at
/api/bots
For issues or questions:
- Check the documentation
- Review example bots
- Test with API endpoints
- Check server logs
Happy Bot Building! 🤖