Dashboard
You are modifying an existing Python project called **Crystal-Agents**. The project already contains:
* an orchestrator CLI (orchestrator/cli.py)
* workflows triggered via run --task
* a dashboard
* scheduler and reports
* Docker deployment
The CLI currently supports these commands:
run
dashboard
reports
scheduler
The system also has a config file config/config.json with a section:
"telegram": {
  "enabled": false,
  "bot\_token": "",
  "chat\_id": ""
}However, the Telegram integration is not implemented.
Your task is to implement a **Telegram conversational interface and natural-language task routing** so that a user can send messages to the bot and trigger workflows automatically without specifying --task.
Do NOT break existing CLI behavior.
-–
GOALS
1. Add a **Telegram bot listener**
2. Add a **natural language router** that maps user messages to workflows
3. Allow messages like:
“Write a LinkedIn post about AI agents”
“Create a feature spec for multi-tenant billing”
“Review this content for grammar”
“Generate customer analytics report”
to automatically select the correct workflow.
-–
FEATURE 1 — TELEGRAM BOT
Create a new module:
orchestrator/telegram_bot.py
Responsibilities:
• Load configuration from config/config.json
• If telegram.enabled == true, start polling Telegram
• Use https://api.telegram.org/bot<TOKEN>/getUpdates polling loop
• When a message is received:
* extract text
* extract chat\_id
* route the message using the router
* run the workflow
* send the result back using sendMessage
Polling interval: ~2 seconds.
The bot should run continuously.
-–
FEATURE 2 — NATURAL LANGUAGE ROUTER
Create:
orchestrator/router.py
Function:
def route\_task(message: str) -> tuple\[str, str]Return:
(task\_name, prompt)The router should map natural language to existing workflows.
Mapping rules:
content drafting
trigger words:
blog
post
tweet
article
marketing copy
write content
→ task = “content”
content review
trigger words:
review
proofread
edit
improve writing
→ task = “content_review”
feature specification
trigger words:
feature
spec
architecture
design
→ task = “feature_spec”
customer reporting
trigger words:
report
analytics
customer stats
metrics
→ task = “customer_reporting”
Fallback default:
task = "content"Return the original message as the prompt.
-–
FEATURE 3 — EXECUTE WORKFLOW PROGRAMMATICALLY
The CLI currently runs tasks using:
python -m orchestrator.cli run –task X –prompt Y
Refactor the logic so it can also be called from Python code.
Create a function:
def run\_workflow(task: str, prompt: str) -> strReturn a short text summary of the result.
This function should internally reuse the same workflow execution logic already used by the CLI.
-–
FEATURE 4 — TELEGRAM BOT EXECUTION FLOW
The telegram bot should:
receive message
↓
call router.route_task(message)
↓
call run_workflow(task, prompt)
↓
send response to Telegram
Response example:
Workflow executed: content
Prompt:
Write a LinkedIn post about AI agents.
Status: completed
Run ID: run\_20260412\_xxxx-–
FEATURE 5 — CLI COMMAND
Add a new CLI command:
python -m orchestrator.cli telegramWhen executed, it should start the Telegram bot loop.
Do not affect existing commands.
-–
FEATURE 6 — DOCKER SUPPORT
Update docker-compose.yml so the container runs both:
dashboard
telegram bot
Example pattern:
command: bash -c "
python -m orchestrator.cli dashboard \&
python -m orchestrator.cli telegram
"-–
FEATURE 7 — SAFETY
The bot must only respond to messages from the configured chat\_id.
Ignore all other chat IDs.
-–
EXPECTED RESULT
After implementation:
User sends message in Telegram:
“Write a LinkedIn post about AI automation”
System behavior:
Telegram message
↓
router selects task “content”
↓
workflow executes
↓
artifacts saved in runs/
↓
dashboard shows the run
↓
bot replies with summary
-–
Keep implementation clean and minimal. Do not introduce heavy frameworks. Use standard Python libraries (requests, time, etc.).
After Codex applies this, your system will work like this:
Telegram → router → workflow → dashboard.
You will be able to type natural language messages such as:
* “Write a LinkedIn post about ERP automation”
* “Create feature spec for multi-tenant billing”
* “Generate weekly customer analytics”
and the orchestrator will choose the workflow automatically.
Dashboard
Currently the dashboard is plain HTML. Please make it look professional with a bit of css styling.