Telegram send

From leopu00/job-hunter-team · View interactive version

Telegram send is an AI agent skill from the GitHub repository leopu00/job-hunter-team. Send a message to the user via Telegram (outbound). Use this on the Telegram bridge — the user is on their phone, NOT in front of the web dashboard. Wrapper `jht-telegram-send` resolves bot token + chat_id per-agent from config (`--from assistente|capitano|mentor`); never call the Bot API directly.

How to use this skill

Skill file

telegram-send — outbound to the user via Telegram

The user reaches you primarily from their phone. They send PDFs, voice notes, plain messages to your dedicated bot. The bridge relays inbound traffic to your tmux. Outbound — your reply, a welcome message, a generated CV — goes through jht-telegram-send.

3 bot dedicati (decisione 2026-05-13 rev2)

Each user-facing agent has its own Telegram bot:

The wrapper picks token + chat_id from channels.telegram.bots.<role> in the config. If you omit --from, you can also set JHT_TG_BOT_ROLE=<role> in the agent env — the wrapper reads it as default.

When to use it

Do not use it for:

Usage

# Default = bot Assistente (oppure ruolo letto da JHT_TG_BOT_ROLE)
jht-telegram-send "<message body>"

# Routing esplicito per ruolo
jht-telegram-send --from capitano "Notifica: 10 nuove posizioni ready."
jht-telegram-send --from mentor --html "<b>Step di crescita</b> della settimana..."

# Override chat_id (raro — debug / multi-tenant futuro)
jht-telegram-send --chat-id 1401844094 "explicit override"

Resolution order (no need to memorise — the wrapper does it):

  1. $TELEGRAM_BOT_TOKEN / $TELEGRAM_CHAT_ID env vars (override esplicito)
  2. $JHT_HOME/jht.config.json → channels.telegram.bots.<role>.{bot_token,chat_id} (role = --from o $JHT_TG_BOT_ROLE, default assistente)
  3. $JHT_HOME/credentials/telegram_bot.json (.token) — fallback legacy

If either is missing, the wrapper exits non-zero with a clear message. Don't try to recover — surface the error to the user in a jht-send reply on the web channel, or log it.

Examples

# (Assistente) — Welcome on first boot (no profile yet)
jht-telegram-send "Ciao! Sono l'Assistente del Job Hunter Team. Mandami qui il tuo CV (PDF va benissimo) o raccontami in due righe cosa cerchi — parto da lì."

# (Assistente) — Reply to inbound TG
jht-telegram-send "Ricevuto, sto guardando il CV. Dammi 30s."

# (Capitano) — Notifica batch di posizioni ready
jht-telegram-send --from capitano "10 posizioni ready, top 3 per score: ..."

# (Mentor) — Nudge strategico settimanale
jht-telegram-send --from mentor --html "<b>Step di crescita</b> della settimana: ..."

# (Assistente) — Push artifact
jht-telegram-send --html "<b>CV per Acme — Senior FE</b> pronto.\nLo trovi in <code>~/Documents/Job Hunter Team/output/2026-05-12/acme-senior-fe/</code>."

Escape sequences (`\n`, `\t`, `\r`)

The wrapper interprets \n, \t, \r in your message as real newlines/tabs/CRs before sending to Telegram. So you can write:

jht-telegram-send "Ciao!\n\nTi aiuto a configurare il profilo."

and the user receives a proper paragraph break — not the literal \n\n text. Same applies to --html (Telegram renders a newline as a line break in the HTML stream).

If you need a literal backslash followed by n (rare), pre-escape it: \\n → wrapper turns it into \n (since the first \\ becomes \ only in your shell string; inside the wrapper there's no double-substitution).

Long messages

The Bot API truncates at 4096 chars. The wrapper splits on \n / spaces and sends multiple messages. The user receives a sequence — keep tone consistent across chunks.

HTML / Markdown

Telegram supports a subset:

If you're unsure, send plain text (no flag). The user gets a perfectly readable message.

Failure modes

| Exit | Cause | What to do |

|------|-------|------------|

| 2 | Token missing | The bot was never configured. Surface error on web channel, ask the user to re-run setup. |

| 3 | chat_id missing | Same as above — the wizard didn't capture the chat_id. |

| 4 | HTTP non-200 | Network blip or Telegram outage. Retry once after 5s. If still failing, log and move on. |

| 5 | ok: false from Bot API | Usually invalid chat_id or bot blocked by user. Don't retry — capture the response body in your scratch dir and notify on web channel. |

No reply keyboard — commands live in the ☰ menu

Do not attach keyboards. The persistent 6-button keyboard covered half of the

chat on the user's phone, so the three user-facing bots (assistente / capitano /

mentor) expose their commands only in the bot's ☰ menu (setMyCommands, see

below). Send plain messages:

jht-telegram-send --from assistente "Pipeline: 15 CVs ready to apply, ..."

--keyboard <role> is still accepted so old callers do not break, but it

attaches nothing: it removes the keyboard a phone may still show. Every bot also

removes the old keyboard once by itself, on its first message.

A command chosen from the menu reaches you as a normal message (/budget,

/top_cv, …); answer it as you answered the old button text:

Assistente — /budget · /budget_prev · /budget_week · /pipeline · /candles · /mappa · /mappa_it · /top_cv · /reset · /stato · /help
Capitano   — /pipeline · /budget · /team · /ready · /triage · /help
Mentor     — /digest · /patterns · /top · /salary · /help

Slash commands menu (F-1.A, task #50)

The tg-bridge.py registers a per-role setMyCommands set at boot

(/budget, /pipeline, /help, …). They appear in the Telegram

client's / sticky menu — first thing a new user sees. You don't need

to do anything: cli/role configuration is enough, the bridge handles

the API call. List per role in .launcher/tg-bridge.py::BOT_COMMANDS.

Anti-patterns

See also

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.