My AI Assistant Bot: a Telegram bot that answers questions about my experience using a Hugging Face model, hosted on Vercel.
Telegram sends each message to the Vercel function api/telegram.py. The
function sends the question plus the contents of knowledge/about.md to a
Hugging Face chat model and replies with the answer.
- Fill in
knowledge/about.mdwith the information the bot should know. - Create a Hugging Face token (Inference Providers permission) and a Telegram bot token (@BotFather).
- Deploy:
npm i -g vercel vercel login vercel env add HF_TOKEN vercel env add TELEGRAM_TOKEN vercel env add WEBHOOK_SECRET # any random string vercel env add HF_MODEL # optional, default meta-llama/Llama-3.1-8B-Instruct vercel --prod - Point Telegram at the deployment:
curl "https://api.telegram.org/bot<TELEGRAM_TOKEN>/setWebhook" \ -d url=https://<your-project>.vercel.app/api/telegram \ -d secret_token=<WEBHOOK_SECRET>