AI Command Generation Guide

Learn how to harness the power of AI to create sophisticated Telegram bot commands without writing a single line of code. This guide covers everything from basic concepts to advanced techniques.

🎯 What You'll Learn

  • How AI transforms natural language into working bot commands
  • Best practices for writing clear, effective prompts
  • How to define input parameters and output types
  • Common patterns and real-world examples
  • Troubleshooting and optimization techniques

How AI Command Generation Works

Our platform uses advanced language models to convert your plain English descriptions into production-ready Python code. Here's the process:

1

Describe Your Command

Tell the AI what you want your command to do in plain language. Be specific about inputs, processing, and desired outputs.

Example:

"Take a user's photo file and convert it to black and white, then send the converted photo back to the user"

2

AI Analyzes & Plans

The AI breaks down your request, identifies required inputs, determines output types, and plans the implementation logic.

  • Identifies input parameters (file, text, numbers, etc.)
  • Determines output type (sendMessage, sendPhoto, sendDocument)
  • Selects appropriate libraries (PIL for image processing, pandas for data)
  • Plans error handling and validation
3

Code Generation

AI generates complete Python code including imports, input validation, main logic, error handling, and output formatting.

from PIL import Image
import io

def process(photo_file):
    img = Image.open(photo_file)
    bw_img = img.convert('L')
    output = io.BytesIO()
    bw_img.save(output, format='PNG')
    return output.getvalue()
4

Automatic Deployment

Code is packaged with dependencies in an isolated microservice container and deployed to your bot instantly.

Writing Effective Prompts

The quality of your command depends heavily on how well you describe it. Follow these principles:

✅ Good Prompts Are:

Specific

Clearly state what inputs are needed and what output is expected.

Good: Take a user's name (text) and age (number) and generate a birthday greeting message

Bad: Make a greeting

Action-Oriented

Use clear verbs that describe what the command does.

Good: Fetch weather data from OpenWeather API using city name and return temperature and conditions

Bad: Weather stuff

Complete

Include all necessary details about data processing and formatting.

Good: Download CSV file from URL, parse it with pandas, filter rows where status='active', and send summary statistics

Bad: Process CSV

💡 Prompt Template

Use this template structure for consistent results:

1. Input Description: What data does the user provide?

2. Processing Steps: What should happen with that data?

3. Output Format: How should results be returned?

4. Special Requirements: Any error handling, validations, or edge cases?

Input Parameters

Parameters define what information users must provide when using your command. Our platform supports various parameter types that automatically create conversation flows.

Supported Parameter Types

📝 Text (str)

Free-form text input from the user

Example: Username, message content, description

🔢 Integer (int)

Whole numbers

Example: Age, count, quantity, ID

💯 Float (float)

Decimal numbers

Example: Price, temperature, percentage

✅ Boolean (bool)

True/false choice

Example: Enable feature, public/private

📁 File

Any file upload (image, document, video)

Example: Photo to process, CSV to analyze

🎨 Photo

Image files specifically

Example: Profile picture, product image

📄 Document

Documents (PDF, DOCX, etc.)

Example: Contract, report, spreadsheet

📋 List

Multiple values of the same type

Example: Tags, email addresses, IDs

⚡ Auto-Generated Conversations

When you define parameters, the platform automatically creates a conversational flow that:

  • Asks users for each required parameter one by one
  • Validates input types (ensures numbers are numbers, etc.)
  • Provides helpful prompts and error messages
  • Allows users to skip optional parameters
  • Lets users cancel at any time

Output Types

Your bot commands can send responses using any Telegram message type. You can also combine multiple output types in a single command to send different message types based on your command's logic.

🎯 Multiple Output Types

A single command can return different output types depending on its logic. For example:

  • Send a message with instructions, then a photo with results
  • Send a chart image and a CSV document with raw data
  • Send a video and a message with processing stats

Simply select multiple output types when creating your command!

📱 Available Output Types

💬 sendMessage

Plain text message with formatting (Markdown/HTML)

Best for: Status updates, text results, confirmations

Max: 4,096 characters

🖼️ sendPhoto

Send images (JPG, PNG, GIF) with optional caption

Best for: Generated images, processed photos, charts, diagrams

Max: 10 MB per photo, 1024 char caption

📄 sendDocument

Send any file type (PDF, Excel, ZIP, etc.)

Best for: Reports, exports, generated documents, CSVs

Max: 50 MB per file

🎥 sendVideo

Send video files (MP4, MOV) with thumbnail

Best for: Video processing, animations, tutorials, clips

Max: 50 MB per video

🎵 sendAudio

Send audio files (MP3, M4A) with metadata

Best for: Audio processing, music, podcasts, voice synthesis

Max: 50 MB per audio file

🎬 sendAnimation

Send GIF or short video animations

Best for: Animated graphics, GIF creation, motion graphics

H.264/MPEG-4 AVC video without sound

🎙️ sendVoice

Send voice messages (OGG with OPUS)

Best for: Text-to-speech, voice notes, audio memos

Displays as waveform in chat

📹 sendVideoNote

Send rounded square video messages

Best for: Video messages, video memos (max 1 minute)

Rounded square MPEG4 format

📊 sendPoll

Create interactive polls or quizzes

Best for: Surveys, voting, quizzes, feedback collection

2-10 options, quiz mode available

📍 sendLocation

Share geographic coordinates and live location

Best for: Maps, location services, tracking, directions

Supports live location updates

🏢 sendVenue

Share location with venue details (name, address)

Best for: Business locations, event venues, POI information

Includes Foursquare/Google Places

👤 sendContact

Share contact information (phone, name, vCard)

Best for: Contact sharing, vCard generation, networking

Supports full vCard format

🎲 sendDice

Send animated dice, darts, or casino emojis

Best for: Games, random number generation, entertainment

🎲 🎯 🏀 ⚽ 🎳 🎰

📦 sendMediaGroup

Send 2-10 photos or videos as an album

Best for: Photo galleries, multiple files, image collections

Photos and videos in single message

💭 sendChatAction

Show "typing..." or upload indicators

Best for: Long-running commands, improving UX

typing, upload_photo, record_video, etc.

⚡ None (Silent)

No message sent (background processing)

Best for: Data logging, webhook handlers, silent updates

Command executes without sending output

💰

💎 sendPaidMedia - Monetize Your Bot!

Make money directly through your bot! The sendPaidMedia output type allows you to sell exclusive photos and videos to users for Telegram Stars.

How It Works:

  • Set your price: Charge 1-2,500 Telegram Stars for access to media
  • Send content: Include 1-10 photos or videos in a single paid message
  • Get paid: Users pay with Stars to unlock and view your content
  • Commission model: Our platform takes a small commission based on your membership plan

Perfect For:

✅ Premium content creators
✅ Exclusive photo/video access
✅ Educational content
✅ Digital products
✅ Private communities
✅ Subscription-style content

Example AI Prompt:

"Generate a high-quality AI image based on the user's text prompt using DALL-E. Send it as paid media for 50 stars. Include a caption explaining what was generated."

💡 Tip: Combine with other output types to send a preview message before the paid content!

💬

🔄 Interactive User Input During Execution

Request user input mid-command! Your bot commands can dynamically ask users for additional information during execution using the built-in request_user_input() function.

Why This Is Powerful:

Unlike pre-defined parameters (collected before command execution), interactive input allows your command logic to:

  • Make decisions on the fly: Ask different questions based on previous answers
  • Create dynamic workflows: Build conversational experiences
  • Reduce initial friction: Only ask for what's needed, when it's needed
  • Handle complex logic: "If user says yes, ask for email; if no, end command"

Supported Input Types:

📝
Text input: Ask users to type any text response

Example: "What's your email address?"

🔢
Number input: Request integer or float values

Example: "How many items do you want? (1-10)"

🔘
Button clicks: Present multiple choice buttons

Example: "Choose format: [PDF] [Excel] [CSV]"

Example Use Cases:

Multi-step form: Ask name → ask email → ask preferences → generate personalized document
Conditional logic: "Do you want charts? [Yes/No]" → If yes, ask "Which type? [Bar/Line/Pie]"
Confirmations: Show preview → "Send this email? [Confirm] [Edit] [Cancel]"
Settings wizard: Guide users through configuration step-by-step

💡 Pro Tip: In your AI prompt, simply say "ask the user for [input type]" and the AI will generate code using request_user_input(). Example: "Ask the user if they want to proceed using buttons (Yes/No)"

Real Command Examples

Learn from these proven command patterns used by successful bots on our platform.

Weather Report Command

AI Prompt:

"Fetch current weather data from OpenWeather API using the city name provided by the user. Return a formatted message with temperature in Celsius, weather conditions, humidity, and wind speed. Handle API errors gracefully."

Parameters:

  • city_name (str)

Output:

sendMessage

CSV Data Analyzer

AI Prompt:

"Accept a CSV file from the user, parse it with pandas, calculate summary statistics (mean, median, max, min) for numeric columns, and generate a bar chart visualization. Return both the statistics as text and the chart as an image."

Parameters:

  • csv_file (document)

Output:

sendMessage + sendPhoto

Email Sender (OAuth)

AI Prompt:

"Send an email via Gmail API using OAuth authentication. Accept recipient email, subject, and message body from the user. Validate email format and handle authentication errors. Confirm when email is sent successfully."

Parameters:

  • recipient (str)
  • subject (str)
  • body (str)

Parameters:

  • csv_file (document)

Output:

sendMessage + sendPhoto

Email Sender (OAuth)

AI Prompt:

"Send an email via Gmail API using OAuth authentication. Accept recipient email, subject, and message body from the user. Validate email format and handle authentication errors. Confirm when email is sent successfully."

Parameters:

  • recipient (str)
  • subject (str)
  • body (str)

Output:

sendMessage

Requires Gmail OAuth

Best Practices

✅ Do:

  • Be specific about data types: "Accept an integer between 1 and 100" is better than "accept a number"
  • Mention error handling: "If API fails, return a friendly error message"
  • Specify validations: "Validate email format before processing"
  • Define output format: "Return results as a bulleted list"
  • Use environment variables: "Use API_KEY from environment variables"

❌ Don't:

  • Be vague: "Do something with the data" won't produce useful results
  • Skip validation: Always handle edge cases and invalid inputs
  • Hardcode secrets: Never put API keys directly in prompts
  • Overcomplicate: One command = one clear purpose. Break complex tasks into multiple commands

Troubleshooting

🔴 Problem: Generated command doesn't work as expected

Solutions:

  • • Review your prompt - was it specific enough?
  • • Check the generated code in the command details
  • • Add more details about edge cases in your prompt
  • • Regenerate with a clearer, more specific description

🔴 Problem: Command fails with dependency errors

Solutions:

  • • Mention specific library versions in your prompt if needed
  • • Check if the library is compatible with our platform
  • • Try using alternative, well-supported libraries
  • • Contact support if a critical library is missing

🔴 Problem: Command times out

Solutions:

  • • Break long-running tasks into smaller commands
  • • Add "process data in batches" to your prompt
  • • Use async operations for I/O-heavy tasks
  • • Consider upgrading your plan for higher limits

Advanced Techniques

Chaining Multiple Commands

Create workflows by having one command trigger another using webhooks or shared workspace files.

Using Environment Variables

Reference environment variables in your prompts for API keys and configuration:

"Fetch data from API at API_ENDPOINT using API_KEY from environment variables"

Working with File Workspace

Commands can read from and write to their workspace:

"Load configuration from config.json in the workspace, process user data accordingly, and save results to output.csv"

OAuth Integration

When creating commands that need OAuth, mention it clearly:

"Using Gmail OAuth, send an email with the provided subject and body to the recipient. Authenticate the user if not already authorized."

Ready to Create Your First AI Command?

Start your free trial and build professional bot commands in minutes.

Start Building Now →