jarvis
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Viewing readonly version of main branch: v20View latest version
This Telegram bot uses OpenAI's GPT-4o-mini model via the AI SDK to provide intelligent responses to user messages.
- Responds to text messages using OpenAI's GPT-4o-mini
- Shows typing indicator while generating responses
- Handles errors gracefully
- Concise and friendly AI responses optimized for chat
-
TELEGRAM_TOKEN: Your Telegram bot token
- Get this from @BotFather on Telegram
- Create a new bot with
/newbotcommand - Copy the token provided
-
OPENAI_API_KEY: Your OpenAI API key
- Get this from OpenAI Platform
- Create a new API key
- Make sure you have credits in your OpenAI account
/start- Welcome message and bot introduction- Any text message - Gets an AI-generated response
- Uses Grammy framework for Telegram bot functionality
- Integrates AI SDK with OpenAI provider
- Configured to use GPT-4o-mini model (cost-effective and fast)
- Maximum response length: 500 tokens
- Includes system prompt for chat-optimized responses
- Validates required environment variables on startup
- Handles API errors gracefully with user-friendly messages
- Logs errors for debugging
- Only responds to text messages (ignores media, stickers, etc.)
- Set up the required environment variables in Val Town
- Deploy the val as an HTTP endpoint
- Start chatting with your bot on Telegram!
The bot will automatically set up the webhook when it receives its first request.
