Answer questions about a codebase via Slack or Telegram messages using an AI agent.
These workflows:
- Receive a message via webhook containing a question about a codebase
- Use an AI agent to analyze the codebase and find the answer
- Respond with a concise paragraph answering the question
| Workflow | File | Description |
|---|---|---|
| Slack | workflow-slack.md |
Receive questions from Slack, respond in Slack |
| Telegram | workflow-telegram.md |
Receive questions from Telegram, respond in Telegram |
-
Create a Slack App
- Go to api.slack.com/apps
- Click "Create New App" > "From scratch"
- Name your app and select your workspace
-
Configure Bot Permissions
- Go to "OAuth & Permissions"
- Add these Bot Token Scopes:
chat:write- Send messageschannels:history- Read message historyapp_mentions:read- Respond to @mentions
-
Enable Event Subscriptions
- Go to "Event Subscriptions"
- Enable events and set Request URL to your webhook endpoint
- Subscribe to bot events:
message.channels,app_mention
-
Install and Get Token
- Go to "Install App" and install to your workspace
- Copy the "Bot User OAuth Token"
-
Create a Telegram Bot
- Open Telegram and search for
@BotFather - Send
/newbotand follow the prompts to create your bot - Copy the bot token (looks like
123456789:ABCdefGHIjklMNOpqrsTUVwxyz)
- Open Telegram and search for
-
Get Your Chat ID
- Start a conversation with your bot in Telegram
- Send a message to the bot
- Visit:
https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates - Look for
"chat":{"id":YOUR_CHAT_ID}in the response
-
Set Webhook
curl -X POST "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/setWebhook" \ -H "Content-Type: application/json" \ -d '{ "url": "https://your-server.com/webhooks/telegram/codebase-qa", "allowed_updates": ["message"] }'
# For Slack
export SLACK_BOT_TOKEN="xoxb-your-bot-token"
# For Telegram
export TELEGRAM_BOT_TOKEN="your-bot-token"# Run the Slack workflow manually
marktoflow run examples/codebase-qa/workflow-slack.md \
--agent claude-agent \
--input codebase_path="/path/to/your/project" \
--input channel="C0123456789" \
--input question="How does the authentication system work?"# Run the Telegram workflow manually
marktoflow run examples/codebase-qa/workflow-telegram.md \
--agent claude-agent \
--input codebase_path="/path/to/your/project" \
--input chat_id=123456789 \
--input question="What is this project about?"# Use GitHub Copilot
marktoflow run examples/codebase-qa/workflow-slack.md --agent copilot ...
# Use OpenCode
marktoflow run examples/codebase-qa/workflow-slack.md --agent opencode ...
# Use Ollama (local)
marktoflow run examples/codebase-qa/workflow-slack.md --agent ollama ...- "What is this project about?"
- "How does the authentication system work?"
- "Where are database queries handled?"
- "What testing framework does this project use?"
- "How is error handling implemented?"
- "What are the main dependencies?"
- "Where are the API routes defined?"
- "How is the project structured?"
The AI agent has read-only permissions:
| Permission | Allowed | Description |
|---|---|---|
read |
Yes | Read any file in the codebase |
glob |
Yes | Search for files by pattern |
grep |
Yes | Search file contents |
bash |
Read-only | Run non-destructive shell commands (ls, cat, etc.) |
write |
No | Cannot create files |
edit |
No | Cannot modify files |
# Start the webhook server (scans for all workflows)
marktoflow serve --port 3000
# Or serve a specific workflow
marktoflow serve -w examples/codebase-qa/workflow-slack.md --port 3000The server will automatically:
- Discover workflows with webhook triggers
- Register endpoints based on the
pathin each trigger - Handle Slack URL verification
- Extract inputs from webhook payloads
Use ngrok to expose your local server:
# Terminal 1: Start marktoflow
marktoflow serve --port 3000
# Terminal 2: Expose with ngrok
ngrok http 3000Copy the ngrok URL (e.g., https://abc123.ngrok.io) and use it as your webhook URL in Slack/Telegram.
The codebase_path input needs to be set. You can either:
-
Set a default in the workflow - Edit the workflow's
inputssection:inputs: codebase_path: type: string required: true default: '/path/to/your/codebase'
-
Use environment variable - Reference an env var in the default:
inputs: codebase_path: type: string required: true default: '${CODEBASE_PATH}'
-
Codebase Access: The agent can read all files in the specified codebase path. Ensure you don't point it at directories containing secrets (
.env, credentials, etc.). -
Bot Security: Keep your bot tokens secure. Consider using private bots/channels for sensitive codebases.
-
Access Restrictions: Consider restricting which users/channels can trigger the workflow:
- Slack: Use channel restrictions in app settings
- Telegram: Implement chat ID whitelisting
Edit the agent_config section in the workflow:
agent_config:
model: opus # Use more powerful model for complex questions
max_turns: 15 # Allow more explorationModify the agent prompt to include project-specific context:
prompt: |
You are an expert on the MyProject codebase.
Key technologies: React, Node.js, PostgreSQL
Known structure:
- src/components/ - React components
- src/api/ - Backend API routes
- src/db/ - Database models
Answer the following question about this codebase:
{{ inputs.question }}Slack:
- Verify Event Subscriptions are enabled
- Check the Request URL is correct and verified
- Ensure the bot has been invited to the channel
- Check Slack app logs for errors
Telegram:
- Verify webhook is set:
curl "https://api.telegram.org/bot$TOKEN/getWebhookInfo" - Ensure server is publicly accessible via HTTPS
- Check for pending updates:
curl "https://api.telegram.org/bot$TOKEN/getUpdates"
- Ensure the
codebase_pathis an absolute path - Verify the path exists and is readable
- Check that the agent has the necessary dependencies installed
- Try a simpler question to isolate the issue
- Slack blocks have a 3000 character limit per text field
- Telegram messages are limited to 4096 characters
- Both workflows automatically truncate long responses