Inicio  / Python  / Como Crear un Bot de Telegram con Python Paso a Pa...
Python

Como Crear un Bot de Telegram con Python Paso a Paso

Crea tu propio bot de Telegram con Python. Recibe mensajes, responde automaticamente y mas.

21 vistas 17 Jun 2026

Bot de Telegram con Python


Paso 1: Crear el bot en Telegram

1. Abre Telegram y busca @BotFather

2. Escribe /newbot

3. Dale un nombre y un usuario (debe terminar en bot)

4. BotFather te da un TOKEN — guardalo


Paso 2: Instalar la libreria


pip install pyTelegramBotAPI

Paso 3: El codigo del bot


import telebot

TOKEN = "TU_TOKEN_AQUI"
bot = telebot.TeleBot(TOKEN)

@bot.message_handler(commands=["start"])
def inicio(mensaje):
    bot.reply_to(mensaje, f"Hola {mensaje.from_user.first_name}! Soy tu bot.")

@bot.message_handler(func=lambda m: True)
def responder(mensaje):
    texto = mensaje.text.lower()
    if "hola" in texto:
        bot.reply_to(mensaje, "Hola! Como estas?")
    elif "precio" in texto:
        bot.reply_to(mensaje, "No manejo precios, soy solo un bot.")
    else:
        bot.reply_to(mensaje, f"Dijiste: {mensaje.text}")

print("Bot corriendo...")
bot.polling()

Paso 4: Ejecutar


python bot.py

Abre Telegram, busca tu bot y escribe /start.


Agregar mas comandos


@bot.message_handler(commands=["ayuda"])
def ayuda(mensaje):
    bot.reply_to(mensaje, "Comandos disponibles:\n/start - Iniciar\n/ayuda - Ver comandos")
Tambien te puede interesar