• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
colebemis

colebemis

jarvis

Public
Like
jarvis
Home
Code
3
README.md
H
index.ts
system-prompt.md
Branches
1
Pull requests
Remixes
History
Environment variables
2
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.
Sign up now
Code
/
/
x
/
colebemis
/
jarvis
/
branch
/
main
/
version
/
26
/
code
/
README.md
/
README.md
Code
/
/
x
/
colebemis
/
jarvis
/
branch
/
main
/
version
/
26
/
code
/
README.md
/
README.md
Search
9/23/2025
Viewing readonly version of main branch: v26
View latest version
README.md

AI-Powered Telegram Bot

This Telegram bot uses OpenAI's GPT-4o-mini model via the AI SDK to provide intelligent responses to user messages.

Features

  • 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

Setup

Required Environment Variables

  1. TELEGRAM_TOKEN: Your Telegram bot token

    • Get this from @BotFather on Telegram
    • Create a new bot with /newbot command
    • Copy the token provided
  2. 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

Bot Commands

  • /start - Welcome message and bot introduction
  • Any text message - Gets an AI-generated response

Technical Details

  • 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

Error Handling

  • 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.)

Usage

  1. Set up the required environment variables in Val Town
  2. Deploy the val as an HTTP endpoint
  3. Start chatting with your bot on Telegram!

The bot will automatically set up the webhook when it receives its first request.

FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.