JAA-ATS-Tool / relay /README.md
saitejatirunagari's picture
feat: Telegram via Cloudflare Worker relay (HF blocks Telegram egress)
1dc6052
|
Raw
History Blame
2.55 kB

Telegram β†’ Resume PDF relay (Cloudflare Worker)

HF Spaces block outbound traffic to api.telegram.org, so the HF app can receive Telegram webhooks but can't send replies. This tiny Cloudflare Worker runs on a network that can reach Telegram: it receives the webhook, calls your HF /api/generate (which works publicly), and sends the PDF back to Telegram.

Cloudflare Workers are free, always-on, and ctx.waitUntil() lets the Worker ack Telegram instantly then finish the ~30–60s job in the background (so Telegram doesn't time out and retry).

One-time setup (~15 min)

  1. Create the Worker

    • Go to https://dash.cloudflare.com β†’ Workers & Pages β†’ Create β†’ Create Worker.
    • Give it a name (e.g. jaa-telegram-relay) β†’ Deploy (creates a placeholder).
    • Click Edit code, delete the sample, paste the contents of relay/cloudflare-worker.js, then Deploy.
    • Copy the Worker URL, e.g. https://jaa-telegram-relay.<you>.workers.dev.
  2. Set the Worker's Variables & Secrets Worker β†’ Settings β†’ Variables and Secrets β†’ add (type "Secret" for the token):

    Name Value
    TELEGRAM_BOT_TOKEN your BotFather token
    ALLOWED_USER_IDS your numeric Telegram ID (comma-separated for more)
    HF_API_URL https://saitejatirunagari-jaa-ats-tool.hf.space
    HF_API_TOKEN your API_SECRET_TOKEN (same value as the HF secret)
    WEBHOOK_SECRET any random string (optional but recommended)
    Re-deploy after saving.
  3. Point Telegram at the Worker (paste in a browser, filling in token/secret/worker URL):

    https://api.telegram.org/bot<TOKEN>/setWebhook?url=https://jaa-telegram-relay.<you>.workers.dev&secret_token=<WEBHOOK_SECRET>
    

    Expect {"ok":true,...,"description":"Webhook was set"}. (This replaces the old HF webhook β€” the bot now flows through Cloudflare.)

  4. Make sure API_SECRET_TOKEN is set on the HF Space (it gates /api/generate) and equals the Worker's HF_API_TOKEN.

Use

Message the bot a job link or paste the job description β†’ it replies with the tailored PDF. The HF Space must be public (the Worker calls it unauthenticated with the API token).

Notes

  • First request after the HF Space has been idle is slower (cold start ~30s).
  • LinkedIn/Indeed links may not be fetchable server-side; the bot will ask you to paste the description text (always works).
  • The Worker holds no resume data β€” HF uses your bundled default resume.