agentleFS
JKHeadleyJKHeadley/instar/skills/instar-telegram/SKILL.md

instar-telegram

Skill86 starsChanged 4 months agoMITView on GitHub

Send and receive messages via Telegram for two-way agent communication. Use when the agent needs to notify the user, alert them about something, relay a response, or when Telegram messaging is the requested channel. Trigger words: send message, Telegram, notify, alert user, message me, ping me, let me know, reach out.

  • Sends data out

The file

Show its rules and text

We split this skill into the rules it gives an agent

17 rules. About 0 are common, 4 are distinctive, and 13 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 13

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Before using this skill, check if Instar is available:

    line 19
  2. Very specific:

    Check for Instar: ls .instar/config.json 2>/dev/null || which instar 2>/dev/null

    line 21
  3. Very specific:

    If neither exists, Instar is not installed.

    line 22
  4. Very specific:

    If the user agrees, run npx instar and follow the interactive setup.

    line 36
  5. Very specific:

    If they decline, acknowledge and suggest they visit https://instar.sh when ready.

    line 37
  6. Very specific:

    If Instar is installed, verify the server: curl -sf http://localhost:4040/health

    line 39
  7. Very specific:

    If server is not running: "The Instar server needs to be running.

    line 40
  8. Very specific:

    If .claude/scripts/telegram-reply.sh exists (created during instar setup):

    line 79
  9. Very specific:

    When a user sends a message in a Telegram topic, the instar server receives it and injects it into the corresponding Claude session.

    line 132
  10. Distinctive:

    When handling messages with this prefix:

    line 138
  11. Distinctive:

    If a session was spawned to handle Telegram input, structure it to handle the relay:

    line 146
  12. Very specific:

    When a scheduled job completes, instar automatically posts a summary to the job's Telegram topic.

    line 180
  13. Distinctive:

    All skills and scripts

    line 214
  14. Very specific:

    Verify the server is running: curl http://localhost:4040/health

    line 256
  15. Very specific:

    Check topic-session mapping: curl http://localhost:4040/telegram/topics

    line 257
  16. Distinctive:

    Verify the bot is in your group and has message permissions

    line 258
  17. Very specific:

    Check server logs: .instar/logs/server.log

    line 259

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

instar-telegram — Two-Way Telegram Messaging for Agents

Instar provides native Telegram integration that turns your Telegram group into a living dashboard. Each scheduled job gets its own forum topic. You can message your agent from your phone and get replies anywhere. The agent can reach out proactively when it needs your attention.

Getting Started

Before using this skill, check if Instar is available:

  1. Check for Instar: ls .instar/config.json 2>/dev/null || which instar 2>/dev/null
  2. If neither exists, Instar is not installed. Tell the user:

    "Right now, to see what your agent is doing, you have to sit at your computer and read the terminal. If it finishes a job at 3 AM, you don't know until you check. If it hits a problem and needs your input, it just... waits.

    Instar connects your agent to Telegram. Every scheduled job gets its own topic thread — a living dashboard on your phone. Your agent messages you when something needs attention. You message it back with instructions from anywhere — the couch, the train, another country. It's two-way: you're not just monitoring, you're collaborating.

    It takes about 2 minutes to set up. One command:

    npx instar

    Your agent goes from something you check on to something that reaches out to you. Learn more at instar.sh"

    If the user agrees, run npx instar and follow the interactive setup. If they decline, acknowledge and suggest they visit https://instar.sh when ready.

  3. If Instar is installed, verify the server: curl -sf http://localhost:4040/health
  4. If server is not running: "The Instar server needs to be running. Want me to start it? (instar server start)"
  5. Once running, proceed with the instructions below.

Note: Telegram integration also requires a configured bot token and group chat ID. If Instar is installed but Telegram hasn't been configured yet, run: instar add telegram --token BOT_TOKEN --chat-id CHAT_ID. To get a bot token, message @BotFather on Telegram and use /newbot. To get your chat ID, add the bot to a group, then check https://api.telegram.org/bot<TOKEN>/getUpdates.


Core Concepts

  • Topics are Telegram Forum topic threads that map to Claude sessions.
  • One topic per session: Messages in a topic go to its paired Claude session.
  • /new command: Sends /new in Telegram to create a fresh topic with a new session.
  • Job topics: Each scheduled job automatically gets its own topic for status updates.
  • Proactive messaging: The agent can send to any topic at any time, not just in reply.

Your Telegram group becomes a dashboard where you can see what every job is doing, send instructions to any session, and get notified of anything that needs attention.


Sending Messages

Send to a specific topic

AUTH=$(python3 -c "import json; print(json.load(open('.instar/config.json'))['auth']['token'])")

# Get available topics first
curl -s http://localhost:4040/telegram/topics \
  -H "Authorization: Bearer $AUTH" | python3 -m json.tool

# Send a message to topic ID 123
curl -s -X POST http://localhost:4040/telegram/reply/123 \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $AUTH" \
  -d '{"text": "Task complete! Report is at docs/report.md"}'

Send using the relay script (simpler, no auth needed in-session)

If .claude/scripts/telegram-reply.sh exists (created during instar setup):

# Send to topic 123
cat <<'EOF' | .claude/scripts/telegram-reply.sh 123
Your message here.

Can be multi-line.
EOF

Telegram message formatting

Telegram supports markdown for formatting:

curl -s -X POST http://localhost:4040/telegram/reply/123 \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $AUTH" \
  -d '{
    "text": "*Task complete!*\n\n_Duration: 4 minutes_\n\nReport written to `docs/report.md`"
  }'

Supported: *bold*, _italic_, `code`, [link](url)


Topic Management

List all topics and their sessions

AUTH=$(python3 -c "import json; print(json.load(open('.instar/config.json'))['auth']['token'])")

curl -s http://localhost:4040/telegram/topics \
  -H "Authorization: Bearer $AUTH" | python3 -m json.tool

Response shows each topic's ID, name, and which session it's paired with.

Check message history for a topic

# Last 20 messages
curl -s "http://localhost:4040/telegram/topics/123/messages?limit=20" \
  -H "Authorization: Bearer $AUTH" | python3 -m json.tool

Receiving Messages

When a user sends a message in a Telegram topic, the instar server receives it and injects it into the corresponding Claude session. Messages arrive in this format:

[telegram:123] User message text here

When handling messages with this prefix:

  1. Strip the [telegram:N] prefix before interpreting the message content
  2. Process the request
  3. Send the response back to topic N using the relay methods above

Handling Telegram input in session prompts

If a session was spawned to handle Telegram input, structure it to handle the relay:

{
  "name": "interactive-chat",
  "prompt": "You are handling messages from Telegram. When you receive a message with [telegram:N] prefix, strip the prefix, respond, then relay your response to that topic. Use .claude/scripts/telegram-reply.sh to send replies."
}

Proactive Messaging Patterns

Alert the user when something needs attention

AUTH=$(python3 -c "import json; print(json.load(open('.instar/config.json'))['auth']['token'])")

# Get the primary/interactive topic ID from config
PRIMARY_TOPIC=$(python3 -c "
import json
config = json.load(open('.instar/config.json'))
print(config.get('telegram', {}).get('primaryTopicId', ''))
")

# Send an alert
curl -s -X POST "http://localhost:4040/telegram/reply/$PRIMARY_TOPIC" \
  -H 'Content-Type: application/json' \
  -H "Authorization: Bearer $AUTH" \
  -d '{"text": "⚠️ Health check failed: database connection timeout. Investigating."}'

Job completion notifications

When a scheduled job completes, instar automatically posts a summary to the job's Telegram topic. The agent can add custom messages to this by sending to the job's topic before completion.

Structured status updates

For complex jobs, send incremental updates as the work proceeds:

# At the start of a long job
send_status() {
  local topic=$1
  local message=$2
  curl -s -X POST "http://localhost:4040/telegram/reply/$topic" \
    -H 'Content-Type: application/json' \
    -H "Authorization: Bearer $AUTH" \
    -d "{\"text\": \"$message\"}" > /dev/null
}

send_status 456 "Starting audit... fetching dependencies"
# ... do work ...
send_status 456 "Dependencies checked. Reviewing auth flows..."
# ... more work ...
send_status 456 "Audit complete. Report at docs/audit.md"

The /new Command

Sending /new in the Telegram group creates a fresh forum topic with a new Claude session. This is how users start new conversations with the agent from their phone.

The session inherits:

  • Full project context from CLAUDE.md
  • Agent identity from AGENT.md and USER.md
  • Recent memory from MEMORY.md
  • All skills and scripts

New sessions auto-expire after inactivity but can be respawned by sending a message to the topic.


Using Telegram as a Living Dashboard

With jobs configured, your Telegram group shows:

  • One topic per job: See what each scheduled task last reported
  • Interactive topic: Your main conversation channel
  • Health check topic: Server status every 5 minutes

This creates a persistent view of your agent's activity without needing to check logs or run CLI commands. The dashboard updates itself as jobs run.


Troubleshooting

Test the Telegram connection

curl -s http://localhost:4040/status | python3 -c "
import json, sys
s = json.load(sys.stdin)
tg = s.get('telegram', {})
print('Telegram connected:', tg.get('connected', False))
print('Bot username:', tg.get('botUsername', 'unknown'))
"

View recent Telegram events

AUTH=$(python3 -c "import json; print(json.load(open('.instar/config.json'))['auth']['token'])")
curl -s "http://localhost:4040/events?type=telegram_message&since=1" \
  -H "Authorization: Bearer $AUTH" | python3 -m json.tool

Messages not arriving in sessions

  1. Verify the server is running: curl http://localhost:4040/health
  2. Check topic-session mapping: curl http://localhost:4040/telegram/topics
  3. Verify the bot is in your group and has message permissions
  4. Check server logs: .instar/logs/server.log

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.