PHPackages                             wramirez83/telegram - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. wramirez83/telegram

ActiveLibrary[API Development](/categories/api)

wramirez83/telegram
===================

Laravel 12 compatible library for sending Telegram messages, including texts and files

2.0.0(5mo ago)052MITPHPPHP ^8.2CI passing

Since Nov 6Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/wramirez83/telegram)[ Packagist](https://packagist.org/packages/wramirez83/telegram)[ RSS](/packages/wramirez83-telegram/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (6)Used By (0)

Telegram Bot API Library for Laravel 12
=======================================

[](#telegram-bot-api-library-for-laravel-12)

Librería PHP compatible con Laravel 12 para enviar mensajes y archivos a través de la API de Telegram Bot.

Requisitos
----------

[](#requisitos)

- PHP &gt;= 8.2
- Laravel &gt;= 12.0
- Composer

Instalación
-----------

[](#instalación)

```
composer require wramirez83/telegram
```

Si estás usando Laravel, publica el archivo de configuración:

```
php artisan vendor:publish --tag=telegram-config
```

Configuración
-------------

[](#configuración)

Agrega las siguientes variables de entorno en tu archivo `.env`:

```
TELEGRAM_BOT_TOKEN=tu_token_del_bot
TELEGRAM_CHANNEL_ID=tu_channel_id
```

O configura en `config/telegram.php`:

```
return [
    'bot_token' => env('TELEGRAM_BOT_TOKEN', ''),
    'channel_id' => env('TELEGRAM_CHANNEL_ID', ''),
];
```

Métodos Disponibles
-------------------

[](#métodos-disponibles)

### Información del Bot

[](#información-del-bot)

#### `getMe()`

[](#getme)

Obtiene información básica sobre el bot.

```
use Wramirez83\Telegram\Telegram;

$botInfo = Telegram::getMe();
```

### Mensajes

[](#mensajes)

#### `sendMessage($message, $chatId = '', $mode = 'Markdown')`

[](#sendmessagemessage-chatid---mode--markdown)

Envía un mensaje de texto a un chat.

**Parámetros:**

- `$message` (string): El mensaje a enviar
- `$chatId` (string|int, opcional): ID del chat destino. Si está vacío, usa el canal por defecto
- `$mode` (string, opcional): Modo de parseo. Valores: `'Markdown'`, `'HTML'`, `'MarkdownV2'`

```
use Wramirez83\Telegram\Telegram;

// Mensaje simple
Telegram::sendMessage('Hola desde Laravel 12!');

// Mensaje con formato HTML
Telegram::sendMessage('Texto en negrita', '', 'HTML');

// Mensaje a un chat específico
Telegram::sendMessage('Mensaje personalizado', '@mi_canal');
```

#### `forwardMessage($chatId, $fromChatId, $messageId, $disableNotification = false)`

[](#forwardmessagechatid-fromchatid-messageid-disablenotification--false)

Reenvía un mensaje de cualquier tipo.

```
use Wramirez83\Telegram\Telegram;

Telegram::forwardMessage(
    '@destino',      // Chat destino
    '@origen',       // Chat origen
    12345,           // ID del mensaje
    false            // Notificación silenciosa
);
```

### Archivos y Medios

[](#archivos-y-medios)

#### `sendPhoto($file, $message = '', $chatId = '')`

[](#sendphotofile-message---chatid--)

Envía una foto.

```
use Wramirez83\Telegram\Telegram;

// Desde ruta local
Telegram::sendPhoto('/ruta/imagen.jpg', 'Descripción de la imagen');

// Usando CURLFile
Telegram::sendPhoto(Telegram::curFile('/ruta/imagen.jpg'), 'Mi foto');
```

#### `sendDocument($file, $message = '', $chatId = '')`

[](#senddocumentfile-message---chatid--)

Envía un documento.

```
use Wramirez83\Telegram\Telegram;

Telegram::sendDocument(
    Telegram::curFile('/ruta/documento.pdf'),
    'Nuevo documento',
    '@mi_canal'
);
```

#### `sendAudio($audio, $caption = '', $chatId = '', $duration = null, $performer = null, $title = null)`

[](#sendaudioaudio-caption---chatid---duration--null-performer--null-title--null)

Envía un archivo de audio.

```
use Wramirez83\Telegram\Telegram;

Telegram::sendAudio(
    Telegram::curFile('/ruta/audio.mp3'),
    'Mi canción',
    '',
    180,              // Duración en segundos
    'Artista',        // Intérprete
    'Título'          // Título
);
```

#### `sendVideo($video, $caption = '', $chatId = '', $duration = null, $width = null, $height = null)`

[](#sendvideovideo-caption---chatid---duration--null-width--null-height--null)

Envía un video.

```
use Wramirez83\Telegram\Telegram;

Telegram::sendVideo(
    Telegram::curFile('/ruta/video.mp4'),
    'Mi video',
    '',
    60,    // Duración
    1920,  // Ancho
    1080   // Alto
);
```

#### `sendVoice($voice, $caption = '', $chatId = '', $duration = null)`

[](#sendvoicevoice-caption---chatid---duration--null)

Envía un mensaje de voz.

```
use Wramirez83\Telegram\Telegram;

Telegram::sendVoice(
    Telegram::curFile('/ruta/voice.ogg'),
    'Mensaje de voz',
    '',
    30  // Duración en segundos
);
```

#### `sendSticker($sticker, $chatId = '')`

[](#sendstickersticker-chatid--)

Envía un sticker (.webp).

```
use Wramirez83\Telegram\Telegram;

Telegram::sendSticker(Telegram::curFile('/ruta/sticker.webp'));
```

### Ubicación

[](#ubicación)

#### `sendLocation($latitude, $longitude, $chatId = '', $horizontalAccuracy = null, $livePeriod = null, $heading = null, $proximityAlertRadius = null)`

[](#sendlocationlatitude-longitude-chatid---horizontalaccuracy--null-liveperiod--null-heading--null-proximityalertradius--null)

Envía un punto en el mapa.

```
use Wramirez83\Telegram\Telegram;

Telegram::sendLocation(
    40.7128,  // Latitud
    -74.0060, // Longitud
    '@mi_canal'
);
```

### Acciones del Chat

[](#acciones-del-chat)

#### `sendChatAction($action, $chatId = '')`

[](#sendchatactionaction-chatid--)

Indica al usuario que algo está pasando del lado del bot.

**Acciones válidas:**

- `typing` - Escribiendo
- `upload_photo` - Subiendo foto
- `record_video` - Grabando video
- `upload_video` - Subiendo video
- `record_voice` - Grabando audio
- `upload_voice` - Subiendo audio
- `upload_document` - Subiendo documento
- `find_location` - Buscando ubicación
- `record_video_note` - Grabando nota de video
- `upload_video_note` - Subiendo nota de video

```
use Wramirez83\Telegram\Telegram;

Telegram::sendChatAction('typing', '@mi_canal');
```

### Actualizaciones y Webhooks

[](#actualizaciones-y-webhooks)

#### `getUpdate($offset = null, $limit = null, $timeout = null, $allowedUpdates = null)`

[](#getupdateoffset--null-limit--null-timeout--null-allowedupdates--null)

Obtiene actualizaciones del bot.

```
use Wramirez83\Telegram\Telegram;

// Obtener todas las actualizaciones
$updates = Telegram::getUpdate();

// Con parámetros
$updates = Telegram::getUpdate(
    0,      // Offset
    10,     // Límite
    30,     // Timeout en segundos
    ['message', 'callback_query']  // Tipos de actualizaciones
);
```

#### `setWebhook($url, $certificate = null, $ipAddress = null, $maxConnections = null, $allowedUpdates = null, $dropPendingUpdates = false, $secretToken = null)`

[](#setwebhookurl-certificate--null-ipaddress--null-maxconnections--null-allowedupdates--null-droppendingupdates--false-secrettoken--null)

Configura un webhook para recibir actualizaciones.

```
use Wramirez83\Telegram\Telegram;

Telegram::setWebhook(
    'https://tudominio.com/webhook/telegram',
    null,  // Certificado (opcional)
    null,  // IP fija (opcional)
    40,    // Máximo de conexiones
    ['message', 'callback_query'],  // Tipos permitidos
    true,  // Eliminar actualizaciones pendientes
    'mi_secret_token'  // Token secreto
);
```

#### `removeWebhook($dropPendingUpdates = false)`

[](#removewebhookdroppendingupdates--false)

Elimina el webhook configurado.

```
use Wramirez83\Telegram\Telegram;

Telegram::removeWebhook(true);  // Eliminar actualizaciones pendientes
```

### Archivos

[](#archivos)

#### `getFile($fileId)`

[](#getfilefileid)

Obtiene información sobre un archivo.

```
use Wramirez83\Telegram\Telegram;

$fileInfo = Telegram::getFile('BAACAgIAAxkBAAIBY2...');
```

#### `getFileUrl($fileId)`

[](#getfileurlfileid)

Obtiene la URL completa para descargar un archivo.

```
use Wramirez83\Telegram\Telegram;

$url = Telegram::getFileUrl('BAACAgIAAxkBAAIBY2...');
// Retorna: https://api.telegram.org/file/bot{token}/{file_path}
```

### Perfil de Usuario

[](#perfil-de-usuario)

#### `getUserProfilePhotos($userId, $offset = 0, $limit = 100)`

[](#getuserprofilephotosuserid-offset--0-limit--100)

Obtiene las fotos de perfil de un usuario.

```
use Wramirez83\Telegram\Telegram;

$photos = Telegram::getUserProfilePhotos(123456789, 0, 10);
```

### Utilidades

[](#utilidades)

#### `curFile($routeFile)`

[](#curfileroutefile)

Crea un objeto CURLFile para subir archivos.

```
use Wramirez83\Telegram\Telegram;

$file = Telegram::curFile('/ruta/archivo.pdf');
Telegram::sendDocument($file, 'Mi documento');
```

Ejemplos Completos
------------------

[](#ejemplos-completos)

### Enviar mensaje con formato

[](#enviar-mensaje-con-formato)

```
use Wramirez83\Telegram\Telegram;

$message = ok) {
    foreach ($updates->result as $update) {
        if (isset($update->message)) {
            $chatId = $update->message->chat->id;
            $text = $update->message->text;

            Telegram::sendMessage("Recibí: $text", $chatId);
        }
    }
}
```

Compatibilidad con Laravel 12
-----------------------------

[](#compatibilidad-con-laravel-12)

Esta librería es completamente compatible con Laravel 12 y utiliza:

- Sistema de configuración de Laravel
- Soporte para PHP 8.2+
- Estructura compatible con Service Providers de Laravel

Referencias
-----------

[](#referencias)

- [Telegram Bot API Documentation](https://core.telegram.org/bots/api)
- [Telegram Bot SDK Reference](https://telegram-bot-sdk.readme.io/reference/getme)

Licencia
--------

[](#licencia)

MIT

Autor
-----

[](#autor)

Wilson Ramirez Z -

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance69

Regular maintenance activity

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~186 days

Total

5

Last Release

179d ago

Major Versions

1.2.1 → 2.0.02025-11-20

### Community

Maintainers

![](https://www.gravatar.com/avatar/dd11480feff23989c23a202a8601179e35a4dc5430c17fbcc67db23f3bbcac8e?d=identicon)[wramirez83](/maintainers/wramirez83)

---

Top Contributors

[![wramirez83](https://avatars.githubusercontent.com/u/14268794?v=4)](https://github.com/wramirez83 "wramirez83 (5 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/wramirez83-telegram/health.svg)

```
[![Health](https://phpackages.com/badges/wramirez83-telegram/health.svg)](https://phpackages.com/packages/wramirez83-telegram)
```

###  Alternatives

[alexpechkarev/google-maps

Collection of Google Maps API Web Services for Laravel

5653.2M2](/packages/alexpechkarev-google-maps)[andreaselia/laravel-api-to-postman

Generate a Postman collection automatically from your Laravel API

1.0k586.2k3](/packages/andreaselia-laravel-api-to-postman)[dymantic/laravel-instagram-feed

Fetches the instagram feed for given authenticated profiles

151157.7k](/packages/dymantic-laravel-instagram-feed)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[ivanwilliammd/satusehat-integration

Build SATUSEHAT FHIR Object in Easy Way

754.0k](/packages/ivanwilliammd-satusehat-integration)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
