PHPackages                             laravel-notification-channels/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. [Mail &amp; Notifications](/categories/mail)
4. /
5. laravel-notification-channels/telegram

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

laravel-notification-channels/telegram
======================================

Telegram Notifications Channel for Laravel

7.0.0(2mo ago)1.1k3.4M—7.3%17320MITPHPPHP ^8.3CI passing

Since Aug 13Pushed 2mo ago28 watchersCompare

[ Source](https://github.com/laravel-notification-channels/telegram)[ Packagist](https://packagist.org/packages/laravel-notification-channels/telegram)[ Docs](https://github.com/laravel-notification-channels/telegram)[ RSS](/packages/laravel-notification-channels-telegram/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (24)Versions (34)Used By (20)

Telegram Notifications Channel for Laravel
==========================================

[](#telegram-notifications-channel-for-laravel)

[![Join PHP Chat](https://camo.githubusercontent.com/29f67fb2289efd1ecede6eaa41c82be0e3f93dbf5a8193f1f0fc1b4f33719fa7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f536c61636b2d504850253230436861742d3563366161612e7376673f7374796c653d666c61742d737175617265266c6f676f3d736c61636b266c6162656c436f6c6f723d344131353442)](https://phpchat.co/?ref=laravel-channel-telegram)[![Chat on Telegram](https://camo.githubusercontent.com/c793b6d887d39dac6773fa734b19b63fb1b8a392156528c648c2564000509eba/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4050485043686174436f2d3243413545302e7376673f7374796c653d666c61742d737175617265266c6f676f3d74656c656772616d266c6162656c3d54656c656772616d)](https://t.me/PHPChatCo)[![Latest Version on Packagist](https://camo.githubusercontent.com/afb682b1bb332a5f8fa641ef9470ba991732060c4d2af1c8d7a7b6f13fe96108/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c61726176656c2d6e6f74696669636174696f6e2d6368616e6e656c732f74656c656772616d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laravel-notification-channels/telegram)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/cbf836d6ed29bc57b269b1a05bacb58bb063229dc58c777b42269ab8f29c1653/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c61726176656c2d6e6f74696669636174696f6e2d6368616e6e656c732f74656c656772616d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laravel-notification-channels/telegram)

This package makes it easy to send Telegram notifications from Laravel via the [Telegram Bot API](https://core.telegram.org/bots).

Contents
--------

[](#contents)

- [Installation](#installation)
    - [Setting up your Telegram Bot](#setting-up-your-telegram-bot)
    - [Retrieving Chat ID](#retrieving-chat-id)
    - [Using in Lumen](#using-in-lumen)
    - [Proxy or Bridge Support](#proxy-or-bridge-support)
- [Usage](#usage)
    - [Text Notification](#text-notification)
    - [Send with Keyboard](#send-with-keyboard)
    - [Send a Dice](#send-a-dice)
    - [Send a Poll](#send-a-poll)
    - [Attach a Contact](#attach-a-contact)
    - [Attach an Audio](#attach-an-audio)
    - [Attach a Photo](#attach-a-photo)
    - [Attach a Document](#attach-a-document)
    - [Attach a Location](#attach-a-location)
    - [Attach a Venue](#attach-a-venue)
    - [Attach a Video](#attach-a-video)
    - [Attach a GIF File](#attach-a-gif-file)
    - [Attach a Sticker](#attach-a-sticker)
    - [Send a Media Group](#send-a-media-group)
    - [Routing a Message](#routing-a-message)
    - [Handling Response](#handling-response)
    - [Exception Handling](#exception-handling)
        - [Using NotificationFailed Event](#using-notificationfailed-event)
        - [Using onError Callback](#using-onerror-callback)
    - [On-Demand Notifications](#on-demand-notifications)
    - [Sending to Multiple Recipients](#sending-to-multiple-recipients)
    - [Using the Telegram Client Directly](#using-the-telegram-client-directly)
- [Available Methods](#available-methods)
    - [Common Methods](#common-methods)
    - [Telegram Message Methods](#telegram-message-methods)
    - [Telegram Location Methods](#telegram-location-methods)
    - [Telegram Venue Methods](#telegram-venue-methods)
    - [Telegram File Methods](#telegram-file-methods)
    - [Telegram Media Group Methods](#telegram-media-group-methods)
    - [Telegram Contact Methods](#telegram-contact-methods)
    - [Telegram Dice Methods](#telegram-dice-methods)
    - [Telegram Poll Methods](#telegram-poll-methods)
- [Alternatives](#alternatives)
- [Changelog](#changelog)
- [Testing](#testing)
- [Security](#security)
- [Contributing](#contributing)
- [Credits](#credits)
- [License](#license)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require laravel-notification-channels/telegram
```

Setting up your Telegram Bot
----------------------------

[](#setting-up-your-telegram-bot)

Talk to [@BotFather](https://core.telegram.org/bots/features#creating-a-new-bot) and generate a Bot API token.

Then, configure your Telegram Bot API token:

```
# config/services.php

'telegram' => [
    'token' => env('TELEGRAM_BOT_TOKEN', 'YOUR BOT TOKEN HERE'),
    // Optional bridge / self-hosted Bot API server
    // 'base_uri' => env('TELEGRAM_API_BASE_URI'),
],
```

Note

The package also supports the legacy `services.telegram-bot-api.*` config keys for backward compatibility, but `services.telegram.*` is the preferred configuration format.

Retrieving Chat ID
------------------

[](#retrieving-chat-id)

To send notifications to a Telegram user, channel, or group, you need its chat ID.

You can retrieve it by fetching your bot [updates](https://core.telegram.org/bots/api#update) with the `getUpdates` method described in the Telegram Bot API [docs](https://core.telegram.org/bots/api#getupdates).

An [update](https://core.telegram.org/bots/api#update) is an object whose shape depends on the event type, such as `message`, `callback_query`, or `poll`. For the full list of fields, see the [Telegram Bot API docs](https://core.telegram.org/bots/api#update).

To make this easier, the package ships with `TelegramUpdates`, which lets you fetch updates and inspect the chat IDs you need.

Keep in mind that the user must interact with your bot first before you can obtain their chat ID and store it for future notifications.

Here's an example of fetching an update:

```
use NotificationChannels\Telegram\TelegramUpdates;

// Response is an array of updates.
$updates = TelegramUpdates::create()

    // (Optional) Get the latest update.
    // NOTE: All previous updates will be forgotten using this method.
    // ->latest()

    // (Optional) Limit to 2 updates. By default, updates start with the earliest unconfirmed update.
    ->limit(2)

    // (Optional) Add more request parameters.
    ->options([
        'timeout' => 0,
    ])
    ->get();

if ($updates['ok']) {
    // Chat ID
    $chatId = $updates['result'][0]['message']['chat']['id'];
}
```

Note

This method will not work while an outgoing webhook is configured.

For the full list of supported `options()`, see the [Telegram Bot API docs](https://core.telegram.org/bots/api#getupdates).

Using in Lumen
--------------

[](#using-in-lumen)

If you're using this notification channel in your Lumen project, you will have to add the below code in your `bootstrap/app.php` file.

```
# bootstrap/app.php

// Make sure to create a "config/services.php" file and add the config from the above step.
$app->configure('services');

# Register the notification service providers.
$app->register(Illuminate\Notifications\NotificationServiceProvider::class);
$app->register(NotificationChannels\Telegram\TelegramServiceProvider::class);
```

Proxy or Bridge Support
-----------------------

[](#proxy-or-bridge-support)

You may not be able to send notifications directly if the Telegram Bot API is blocked in your region. In that case, you can either configure a proxy by following the Guzzle instructions [here](http://docs.guzzlephp.org/en/stable/quickstart.html#environment-variables) or point the package at a bridge or self-hosted Bot API server by setting the `base_uri` config shown above.

You can also set `HTTPS_PROXY` in your `.env` file.

Usage
-----

[](#usage)

You can now return the channel from your notification's `via()` method.

### Text Notification

[](#text-notification)

```
use NotificationChannels\Telegram\TelegramMessage;
use Illuminate\Notifications\Notification;

class InvoicePaid extends Notification
{
    public function via($notifiable)
    {
        return ['telegram'];
    }

    public function toTelegram($notifiable)
    {
        $url = url('/invoice/' . $notifiable->invoice->id);
        $user = $notifiable->name;

        return TelegramMessage::create()
            ->to($notifiable->telegram_user_id)
            ->content('Hello there!')
            ->line('Your invoice has been *PAID*')
            ->lineIf($notifiable->amount > 0, "Amount paid: {$notifiable->amount}")
            ->line('Thank you, '.TelegramMessage::escapeMarkdown($user).'!')
            // ->view('notification', ['url' => $url])
            ->button('View Invoice', $url)
            ->button('Download Invoice', $url);

        // Other fluent helpers are also available:
        // ->businessConnectionId('business-connection-id')
        // ->messageThreadId(42)
        // ->protectContent()
        // ->directMessagesTopicId(1001)
        // ->allowPaidBroadcast()
        // ->messageEffectId('5104841245755180586')
        // ->replyParameters(['message_id' => 123])
        // ->suggestedPostParameters(['price' => ['amount' => 10, 'currency' => 'XTR']])
        // ->entities([...])
        // ->linkPreviewOptions(['is_disabled' => true])
        // ->sendWhen($notifiable->amount > 0)
        // ->buttonWithWebApp('Open Web App', $url)
        // ->buttonWithCallback('Confirm', 'confirm_invoice '.$this->invoice->id)
    }
}
```

Here's a screenshot preview of the above notification on Telegram Messenger:

[![Laravel Telegram Notification Example](https://user-images.githubusercontent.com/1915268/66616627-39be6180-ebef-11e9-92cc-f2da81da047a.jpg)](https://user-images.githubusercontent.com/1915268/66616627-39be6180-ebef-11e9-92cc-f2da81da047a.jpg)

### Send with Keyboard

[](#send-with-keyboard)

```
public function toTelegram($notifiable)
{
    return TelegramMessage::create()
        ->to($notifiable->telegram_user_id)
        ->content('Choose an option:')
        ->keyboard('Button 1')
        ->keyboard('Button 2');
}
```

Preview:

[![Laravel Telegram Notification Keyboard](https://private-user-images.githubusercontent.com/1915268/566461626-e7552bb3-4655-489d-9cf4-107b94bb5a21.jpg?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyNjY4NjgsIm5iZiI6MTc3NTI2NjU2OCwicGF0aCI6Ii8xOTE1MjY4LzU2NjQ2MTYyNi1lNzU1MmJiMy00NjU1LTQ4OWQtOWNmNC0xMDdiOTRiYjVhMjEuanBnP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQU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U)

You can also request structured input from the keyboard:

```
TelegramMessage::create()
    ->content('Please share your phone number or location')
    ->keyboard('Send your number', requestContact: true)
    ->keyboard('Send your location', requestLocation: true);
```

Preview:

[![Laravel Telegram Notification Keyboard Request Number and Location](https://private-user-images.githubusercontent.com/1915268/566461629-f934fc8c-36ec-402f-9179-4dcccc06242f.jpg?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyNjY4NjgsIm5iZiI6MTc3NTI2NjU2OCwicGF0aCI6Ii8xOTE1MjY4LzU2NjQ2MTYyOS1mOTM0ZmM4Yy0zNmVjLTQwMmYtOTE3OS00ZGNjY2MwNjI0MmYuanBnP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDQwNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA0MDRUMDEzNjA4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZTI4Y2I3ZmNlMWFhYTlkNjIxNDFlZGIxYmQ0NzAyZDQzYjFhMGYwODE1NDdkYWM2OGE4MjFmNDQ2MmM4YTVlNiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.R8bXvIJcBhcet07snQW2D5jPEMK2NiDnVHmPiUNd0tE)](https://private-user-images.githubusercontent.com/1915268/566461629-f934fc8c-36ec-402f-9179-4dcccc06242f.jpg?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyNjY4NjgsIm5iZiI6MTc3NTI2NjU2OCwicGF0aCI6Ii8xOTE1MjY4LzU2NjQ2MTYyOS1mOTM0ZmM4Yy0zNmVjLTQwMmYtOTE3OS00ZGNjY2MwNjI0MmYuanBnP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDQwNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA0MDRUMDEzNjA4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZTI4Y2I3ZmNlMWFhYTlkNjIxNDFlZGIxYmQ0NzAyZDQzYjFhMGYwODE1NDdkYWM2OGE4MjFmNDQ2MmM4YTVlNiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.R8bXvIJcBhcet07snQW2D5jPEMK2NiDnVHmPiUNd0tE)

### Send a Dice

[](#send-a-dice)

```
use NotificationChannels\Telegram\TelegramDice;

public function toTelegram($notifiable)
{
    return TelegramDice::create()
        ->to($notifiable->telegram_user_id)
        ->emoji('🎯');
}
```

Preview:

[![Laravel Telegram Dice Notification](https://private-user-images.githubusercontent.com/1915268/566464780-237d5eba-0f65-470b-ad1b-0f447dd70ab9.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyNjY4NjgsIm5iZiI6MTc3NTI2NjU2OCwicGF0aCI6Ii8xOTE1MjY4LzU2NjQ2NDc4MC0yMzdkNWViYS0wZjY1LTQ3MGItYWQxYi0wZjQ0N2RkNzBhYjkucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QU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bSWy_Y)

### Send a Poll

[](#send-a-poll)

```
public function toTelegram($notifiable)
{
    return TelegramPoll::create()
        ->to($notifiable->telegram_user_id)
        ->question('Which is your favorite Laravel Notification Channel?')
        ->choices(['Telegram', 'Facebook', 'Slack']);
}
```

Preview:

[![Laravel Telegram Poll Example](https://private-user-images.githubusercontent.com/1915268/416896784-7324ccc5-9370-414a-9337-10c4e7446f5c.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyNjY4NjgsIm5iZiI6MTc3NTI2NjU2OCwicGF0aCI6Ii8xOTE1MjY4LzQxNjg5Njc4NC03MzI0Y2NjNS05MzcwLTQxNGEtOTMzNy0xMGM0ZTc0NDZmNWMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDQwNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA0MDRUMDEzNjA4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YTFiODA1NzVlOGU2YzUyNjEzOGM1NmM0OTgzODM2YmM5YWI5YzEwZDJiODM1OWNmOWUyOGNmOGUyYjYyM2M1OCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.uWRSNCn1rrcoylyc1I__cvmkPOApmMA-dGa1PmX9Zwg)](https://private-user-images.githubusercontent.com/1915268/416896784-7324ccc5-9370-414a-9337-10c4e7446f5c.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyNjY4NjgsIm5iZiI6MTc3NTI2NjU2OCwicGF0aCI6Ii8xOTE1MjY4LzQxNjg5Njc4NC03MzI0Y2NjNS05MzcwLTQxNGEtOTMzNy0xMGM0ZTc0NDZmNWMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDQwNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA0MDRUMDEzNjA4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YTFiODA1NzVlOGU2YzUyNjEzOGM1NmM0OTgzODM2YmM5YWI5YzEwZDJiODM1OWNmOWUyOGNmOGUyYjYyM2M1OCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.uWRSNCn1rrcoylyc1I__cvmkPOApmMA-dGa1PmX9Zwg)

### Attach a Contact

[](#attach-a-contact)

```
public function toTelegram($notifiable)
{
    return TelegramContact::create()
        ->to($notifiable->telegram_user_id) // Optional
        ->firstName('John')
        ->lastName('Doe') // Optional
        ->phoneNumber('00000000');
}
```

Preview:

[![Laravel Telegram Contact Example](https://private-user-images.githubusercontent.com/1915268/416895884-24f6e1c9-3ed6-4839-b9da-64ce09d09663.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyNjY4NjgsIm5iZiI6MTc3NTI2NjU2OCwicGF0aCI6Ii8xOTE1MjY4LzQxNjg5NTg4NC0yNGY2ZTFjOS0zZWQ2LTQ4MzktYjlkYS02NGNlMDlkMDk2NjMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2Jlg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_scL1lRaltSOggOCEn0kXGU00)

### Attach an Audio

[](#attach-an-audio)

```
public function toTelegram($notifiable)
{
    return TelegramFile::create()
        ->to($notifiable->telegram_user_id) // Optional
        ->content('Audio') // Optional caption
        ->captionEntities([
            ['offset' => 0, 'length' => 5, 'type' => 'bold'],
        ])
        ->audio('/path/to/audio.mp3');
}
```

Preview:

[![Laravel Telegram Audio Notification Example](https://user-images.githubusercontent.com/60013703/143334174-4d796910-185f-46e2-89ad-5ec7a1a438c9.png)](https://user-images.githubusercontent.com/60013703/143334174-4d796910-185f-46e2-89ad-5ec7a1a438c9.png)

### Attach a Photo

[](#attach-a-photo)

```
public function toTelegram($notifiable)
{
    return TelegramFile::create()
        ->to($notifiable->telegram_user_id) // Optional
        ->content('Awesome *bold* text and [inline URL](http://www.example.com/)')
        ->showCaptionAboveMedia()
        ->file('/storage/archive/6029014.jpg', 'photo'); // local photo
}
```

You can also use a helper method with a remote file or Telegram file ID:

```
TelegramFile::create()
    ->photo('https://samples-files.com/samples/images/jpg/1280-720-sample.jpg');
```

Preview:

[![Laravel Telegram Photo Notification Example](https://user-images.githubusercontent.com/1915268/66616792-daad1c80-ebef-11e9-9bdf-c0bc484cf037.jpg)](https://user-images.githubusercontent.com/1915268/66616792-daad1c80-ebef-11e9-9bdf-c0bc484cf037.jpg)

### Attach a Document

[](#attach-a-document)

```
public function toTelegram($notifiable)
{
    return TelegramFile::create()
        ->to($notifiable->telegram_user_id) // Optional
        ->content('Here is your PDF document')
        ->document('https://samples-files.com/samples/documents/pdf/sample-1-small-size.pdf');
}
```

Preview:

[![Laravel Telegram Document Notification Example](https://private-user-images.githubusercontent.com/1915268/566437103-06be6dff-4321-4336-896c-d0f73610bd40.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyNjY4Njg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ei1TaWduYXR1cmU9NGVkY2Q1ZWJkODU2MTE2NTNlMzBiZDEwZTcxMWE5MzhlMWI2MDhhYTZhZThiZjNjNzEwZTBiOWNiODkxZDY2OCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.F8B5SxKnwgzzkVOJzf2CcvG_qXJzjzmi2xx8VI-zHZw)

If you want to control the filename, you need to upload the actual file contents instead of passing the remote URL directly:

```
$contents = file_get_contents('https://samples-files.com/samples/documents/pdf/sample-1-small-size.pdf');

TelegramFile::create()
    ->content('Did you know we can set a custom filename too?')
    ->document($contents, 'sample.pdf');
```

Preview:

[![Laravel Telegram Document Notification Example with Custom Filename](https://private-user-images.githubusercontent.com/1915268/566437104-24d82d61-7f77-420c-b9c5-3bce92b77616.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyNjY4NjgsIm5iZiI6MTc3NTI2NjU2OCwicGF0aCI6Ii8xOTE1MjY4LzU2NjQzNzEwNC0yNGQ4MmQ2MS03Zjc3LTQyMGMtYjljNS0zYmNlOTJiNzc2MTYucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDQwNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA0MDRUMDEzNjA4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NDgxM2E3MWYyOWVlMGQ0YzdjN2JlMThhZGNiMGFjMTc0M2FhZDViNjk1ZDgyNDgwNDUzOWY2MjM0MjdiZjJkOCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.bll5HKvloIEsV3JglsnofZf69cz4GNDa61meUK8Nswo)](https://private-user-images.githubusercontent.com/1915268/566437104-24d82d61-7f77-420c-b9c5-3bce92b77616.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyNjY4NjgsIm5iZiI6MTc3NTI2NjU2OCwicGF0aCI6Ii8xOTE1MjY4LzU2NjQzNzEwNC0yNGQ4MmQ2MS03Zjc3LTQyMGMtYjljNS0zYmNlOTJiNzc2MTYucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDQwNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA0MDRUMDEzNjA4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NDgxM2E3MWYyOWVlMGQ0YzdjN2JlMThhZGNiMGFjMTc0M2FhZDViNjk1ZDgyNDgwNDUzOWY2MjM0MjdiZjJkOCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.bll5HKvloIEsV3JglsnofZf69cz4GNDa61meUK8Nswo)

Raw file contents are also supported when you provide a filename:

```
TelegramFile::create()
    ->document('Hello Text Document Content', 'hello.txt');
```

Preview:

[![Laravel Telegram Document On Fly](https://private-user-images.githubusercontent.com/1915268/566438900-944dbd40-039c-42ab-86ab-4840cf09d320.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyNjY4NjgsIm5iZiI6MTc3NTI2NjU2OCwicGF0aCI6Ii8xOT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3YjJlMDUyZjE1MTU2ZTI1NDA2YTI3YjVkOTA3MzU2MDA3ZThhMDVmNSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.3sf4ble4aBv8jFyvs-X3C8Yop68H9n1Uy07FQ_855rw)

### Attach a Location

[](#attach-a-location)

```
public function toTelegram($notifiable)
{
    return TelegramLocation::create()
        ->to($notifiable->telegram_user_id)
        ->latitude('40.6892494')
        ->longitude('-74.0466891');
}
```

Preview:

[![Laravel Telegram Location Notification Example](https://private-user-images.githubusercontent.com/1915268/566442377-d47e65f2-aeeb-4c76-a953-c044186f4ed2.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyNjY4NjgsIm5iZiI6MTc3NTI2NjU2OCwicGF0aCI6Ii8xOTE1MjY4LzU2NjQ0MjM3Ny1kNDdlNjVmMi1hZWViLTRjNzYtYTk1My1jMDQ0MTg2ZjRlZDIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDQwNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA0MDRUMDEzNjA4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9Mjk3YTc1ZjRjMzE5NjcwMGJlYTNhZjRmODU4NzM1ZWI0MWUzMTYxMDkzNWFhYTA5NTNlZTRhNzExZDkwYzMxNiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.9Pk_5Pfc_qM_0sawV0lrGElWNsbnBa1-CxD_cqHljrg)](https://private-user-images.githubusercontent.com/1915268/566442377-d47e65f2-aeeb-4c76-a953-c044186f4ed2.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyNjY4NjgsIm5iZiI6MTc3NTI2NjU2OCwicGF0aCI6Ii8xOTE1MjY4LzU2NjQ0MjM3Ny1kNDdlNjVmMi1hZWViLTRjNzYtYTk1My1jMDQ0MTg2ZjRlZDIucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDQwNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA0MDRUMDEzNjA4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9Mjk3YTc1ZjRjMzE5NjcwMGJlYTNhZjRmODU4NzM1ZWI0MWUzMTYxMDkzNWFhYTA5NTNlZTRhNzExZDkwYzMxNiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.9Pk_5Pfc_qM_0sawV0lrGElWNsbnBa1-CxD_cqHljrg)

You can also send live location

```
public function toTelegram($notifiable)
{
    return TelegramLocation::create()
        ->to($notifiable->telegram_user_id)
        ->latitude('40.6892494')
        ->longitude('-74.0466891')
        ->horizontalAccuracy(25)
        ->livePeriod(300)
        ->heading(180)
        ->proximityAlertRadius(50);
}
```

Preview:

[![Laravel Telegram Live Location Notification Example](https://private-user-images.githubusercontent.com/1915268/566442378-f93387e9-177b-4241-bce5-8dc9d2d5737d.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyNjY4NjgsIm5iZiI6M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R1cmU9ODgwNzU3MDNiNjhjNjAzNTdhYTQzMDU1ZDVhOGRjODkxN2EzMThhNjZiNTdmODQzOGM0ZWRiNzJjM2QzNzhjYiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.U2gJreWntZbGzo1fboHiPb_O-eTRKKDF8lJdrPqOgMk)

### Attach a Venue

[](#attach-a-venue)

```
public function toTelegram($notifiable)
{
    return TelegramVenue::create()
        ->to($notifiable->telegram_user_id)
        ->latitude('38.8951')
        ->longitude('-77.0364')
        ->title('Grand Palace')
        ->address('Bangkok, Thailand');
}
```

Preview:

[![Laravel Telegram Venue Notification Example](https://private-user-images.githubusercontent.com/1915268/416894454-96e762a6-c4b5-4d8d-8c2d-9d32adb754d0.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyNjY4NjgsIm5iZiI6MTc3NTI2NjU2OCwicGF0aCI6Ii8xOTE1MjY4LzQxNjg5NDQ1NC05NmU3NjJhNi1jNGI1LTRkOGQtOGMyZC05ZDMyYWRiNzU0ZDAucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDQwNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA0MDRUMDEzNjA4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YmZjN2RlNmE3NzEzNDZmNGU3NjlhNTgwMDgzNDliMzhlN2FmMTIxOWFlYjNmNTYzOTUyMGM5ZTE1ZDZmYjYyZiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.MJDFLlh4qneYyUHfFwgU4gE7AtXcLh833GliEbnsZGk)](https://private-user-images.githubusercontent.com/1915268/416894454-96e762a6-c4b5-4d8d-8c2d-9d32adb754d0.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyNjY4NjgsIm5iZiI6MTc3NTI2NjU2OCwicGF0aCI6Ii8xOTE1MjY4LzQxNjg5NDQ1NC05NmU3NjJhNi1jNGI1LTRkOGQtOGMyZC05ZDMyYWRiNzU0ZDAucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDQwNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA0MDRUMDEzNjA4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YmZjN2RlNmE3NzEzNDZmNGU3NjlhNTgwMDgzNDliMzhlN2FmMTIxOWFlYjNmNTYzOTUyMGM5ZTE1ZDZmYjYyZiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.MJDFLlh4qneYyUHfFwgU4gE7AtXcLh833GliEbnsZGk)

### Attach a Video

[](#attach-a-video)

```
public function toTelegram($notifiable)
{
    return TelegramFile::create()
        ->to($notifiable->telegram_user_id)
        ->content('Sample *video* notification!')
        ->video('https://samples-files.com/samples/video/mp4/sample2-720x480.mp4');
}
```

Preview:

[![Laravel Telegram Video Notification Example](https://private-user-images.githubusercontent.com/1915268/566444174-25aafad0-7e85-4a52-a036-7e7ec5fb2db5.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImt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0MDRUMDEzNjA4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NzFjM2RjMmE0ZTc1ZmIwOGQ0ZjY4NWFhODc0MjM0MTYxMmE1OTk0Njc1YzkzZjU2YTBjY2M2NTFiNDdiMjFkZCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.fWtYFHU8zSnoNCSL8JHRGeqrfyZOjCgZXt9CA5QNMBg)

### Attach a GIF File

[](#attach-a-gif-file)

```
public function toTelegram($notifiable)
{
    return TelegramFile::create()
        ->to($notifiable->telegram_user_id)
        ->content('Woot! We can send animated gif notifications too!')
        ->animation('https://disk.sample.cat/samples/gif/sample-2.gif');
}
```

Local files work the same way:

```
TelegramFile::create()
    ->animation('/path/to/some/animated.gif');
```

Preview:

[![Laravel Telegram Gif Notification Example](https://private-user-images.githubusercontent.com/1915268/566446351-920b52bc-0b80-4050-a9b4-b45abdffa914.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyNjY4NjgsIm5iZiI6MTc3NTI2NjU2OCwicGF0aCI6Ii8xOTE1MjY4LzU2NjQ0NjM1MS05MjBiNTJiYy0wYjgwLTQwNTAtYTliNC1iNDVhYmRmZmE5MTQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDQwNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA0MDRUMDEzNjA4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9OTVhNjI2NmQyNzNhMTBjNmI3NGQ5MTFjNWQ0NTZiNTA0Y2Y0Y2JhNWZjMGZhYTQ0YTE5M2YwZmYyODgzNDJhOSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.OqU6JH95ZhqQ3sHONNCNjRTVXk60DwxkDa_iYEk9V3g)](https://private-user-images.githubusercontent.com/1915268/566446351-920b52bc-0b80-4050-a9b4-b45abdffa914.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyNjY4NjgsIm5iZiI6MTc3NTI2NjU2OCwicGF0aCI6Ii8xOTE1MjY4LzU2NjQ0NjM1MS05MjBiNTJiYy0wYjgwLTQwNTAtYTliNC1iNDVhYmRmZmE5MTQucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDQwNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA0MDRUMDEzNjA4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9OTVhNjI2NmQyNzNhMTBjNmI3NGQ5MTFjNWQ0NTZiNTA0Y2Y0Y2JhNWZjMGZhYTQ0YTE5M2YwZmYyODgzNDJhOSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.OqU6JH95ZhqQ3sHONNCNjRTVXk60DwxkDa_iYEk9V3g)

### Attach a Sticker

[](#attach-a-sticker)

```
public function toTelegram($notifiable)
{
    return TelegramFile::create()
        ->to($notifiable->telegram_user_id)
        ->sticker(storage_path('telegram/AnimatedSticker.tgs'));
}
```

Preview:

[![Laravel Telegram Sticker Notification Example](https://private-user-images.githubusercontent.com/1915268/416892711-5206aac7-022c-4288-ae26-3a117f117fe0.png?jwt=eyJ0eXAiOiJKV1QiLCJhb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DI2MDQwNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA0MDRUMDEzNjA4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MGMzNjgwOGE0MDYwNDk2NzQ3ZjdiMzU3MDlmYzBjNmFkMjUxYWQ3MGU1NjIxODA5YzE5NmVhNDRhZTAwMzI3MCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.g6ATIF-lCsCRBAZ76s8omtr7iaYWYHEBk82Q2MxmPk8)

### Send a Media Group

[](#send-a-media-group)

Use `TelegramMediaGroup` to send multiple items in a single group.

```
use NotificationChannels\Telegram\TelegramMediaGroup;

public function toTelegram($notifiable)
{
    return TelegramMediaGroup::create()
        ->to($notifiable->telegram_user_id)
        ->photo('https://example.com/one.jpg', 'First image')
        ->photo('https://example.com/two.jpg');
}
```

Uploaded files are also supported:

```
TelegramMediaGroup::create()
    ->photo(storage_path('app/telegram/one.jpg'), 'First image')
    ->video(storage_path('app/telegram/video.mp4'), 'Release demo');
```

Preview:

[![Laravel Telegram Media Group Notification Example](https://private-user-images.githubusercontent.com/1915268/566457092-a450ac69-48cf-4ffd-be07-40f9cdd16dc1.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyNjY4NjgsIm5iZiI6MTc3NTI2NjU2OCwicGF0aCI6Ii8xOTE1MjY4LzU2NjQ1NzA5Mi1hNDUwYWM2OS00OGNmLTRmZmQtYmUwNy00MGY5Y2RkMTZkYzEucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDQwNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA0MDRUMDEzNjA4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MThkNzhhN2U0Mjk5NDYzMjRiMWIxYjllZDExNjY2YmIxZWMxYWZlY2MzNTYzOTllNTQxYzlhNmNhODZlMjdlYiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.ZiY-NekIxGaf6igf7eRTXjgWhCaGMX-4s0MG_B_jsHg)](https://private-user-images.githubusercontent.com/1915268/566457092-a450ac69-48cf-4ffd-be07-40f9cdd16dc1.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyNjY4NjgsIm5iZiI6MTc3NTI2NjU2OCwicGF0aCI6Ii8xOTE1MjY4LzU2NjQ1NzA5Mi1hNDUwYWM2OS00OGNmLTRmZmQtYmUwNy00MGY5Y2RkMTZkYzEucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDQwNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA0MDRUMDEzNjA4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MThkNzhhN2U0Mjk5NDYzMjRiMWIxYjllZDExNjY2YmIxZWMxYWZlY2MzNTYzOTllNTQxYzlhNmNhODZlMjdlYiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.ZiY-NekIxGaf6igf7eRTXjgWhCaGMX-4s0MG_B_jsHg)

Documents are also supported, including dynamically generated content:

```
TelegramMediaGroup::create()
    ->document('Monthly report content on-the-fly', 'Monthly report caption', 'monthly.txt')
    ->document('/path/to/local/file.pdf', 'pdf file caption', 'annual-report.pdf');
```

Preview:

[![Laravel Telegram Media Group Documents Notification Example](https://private-user-images.githubusercontent.com/1915268/566455960-83febf55-b6ec-4e1f-94ed-b273891a2edc.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyNjY4NjgsIm5iZiI6MTc3NTI2NjU2OCwicGF0aCI6Ii8xOTE1MjY4LzU2NjQ1NTk2MC04M2ZlYmY1NS1iNmVjLTRlMWYtOTRlZC1iMjczODkxYTJlZGMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDQwNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA0MDRUMDEzNjA4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZTBmNGE5Y2FiYWZhZDViODAxNmQ2YjZjOTViN2I2NTFhNzFjYTZiOTRlY2RmNTdjMzBjNDJiOWU0Yjk1ZDAxNyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.1kA3VoJW1Mfp5PZJYFSdPm5yukGpkSH76l78eB1dI9s)](https://private-user-images.githubusercontent.com/1915268/566455960-83febf55-b6ec-4e1f-94ed-b273891a2edc.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzUyNjY4NjgsIm5iZiI6MTc3NTI2NjU2OCwicGF0aCI6Ii8xOTE1MjY4LzU2NjQ1NTk2MC04M2ZlYmY1NS1iNmVjLTRlMWYtOTRlZC1iMjczODkxYTJlZGMucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDQwNCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjA0MDRUMDEzNjA4WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9ZTBmNGE5Y2FiYWZhZDViODAxNmQ2YjZjOTViN2I2NTFhNzFjYTZiOTRlY2RmNTdjMzBjNDJiOWU0Yjk1ZDAxNyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.1kA3VoJW1Mfp5PZJYFSdPm5yukGpkSH76l78eB1dI9s)

#### Supported Input Types

[](#supported-input-types)

Each media item can be provided as:

- A Telegram file ID
- A remote URL
- A local file path
- A stream or resource
- Raw file contents (requires a filename)

When uploading local files or raw content, the package automatically handles multipart uploads.

Media groups support albums of `photo`, `video`, `audio`, and `document` items.

Note

Telegram does not allow mixing certain media types within a single group. Documents cannot be combined with photos or videos. However, photos and videos can be sent together in the same media group.

### Routing a Message

[](#routing-a-message)

You can either send a notification by setting the recipient explicitly with `to($chatId)` as shown above, or define `routeNotificationForTelegram()` on your notifiable model:

```
/**
 * Route notifications for the Telegram channel.
 *
 * @return int
 */
public function routeNotificationForTelegram()
{
    return $this->telegram_user_id;
}
```

### Handling Response

[](#handling-response)

You can use [notification events](https://laravel.com/docs/13.x/notifications#notification-events) to handle Telegram responses. On success, your listener receives a [Message](https://core.telegram.org/bots/api#message) object with fields appropriate to the notification type.

For the full list of response fields, refer to the Telegram Bot API [Message object](https://core.telegram.org/bots/api#message) docs.

### Exception Handling

[](#exception-handling)

For failures, the package provides two exception-handling hooks.

#### Using NotificationFailed Event

[](#using-notificationfailed-event)

> You can listen to `Illuminate\Notifications\Events\NotificationFailed`, which provides a `$data` array containing `to`, `request`, and `exception` keys.

Listener example:

```
use Illuminate\Notifications\Events\NotificationFailed;

class HandleNotificationFailure
{
    public function handle(NotificationFailed $event)
    {
        // $event->notification: The notification instance.
        // $event->notifiable: The notifiable entity who received the notification.
        // $event->channel: The channel name.
        // $event->data: The data needed to process this failure.

        if ($event->channel !== 'telegram') {
            return;
        }

        // Log the error / notify administrator or disable notification channel for the user, etc.
        \Log::error('Telegram notification failed', [
            'chat_id' => $event->data['to'],
            'error' => $event->data['exception']->getMessage(),
            'request' => $event->data['request']
        ]);
    }
}
```

#### Using onError Callback

[](#using-onerror-callback)

> You can handle exceptions for an individual notification by attaching an `onError` callback:

```
public function toTelegram($notifiable)
{
    return TelegramMessage::create()
        ->content('Hello!')
        ->onError(function ($data) {
            \Log::error('Failed to send Telegram notification', [
                'chat_id' => $data['to'],
                'error' => $data['exception']->getMessage()
            ]);
        });
}
```

In both methods, the `$data` array contains the following keys:

- `to`: The recipient's chat ID.
- `request`: The payload sent to the Telegram Bot API.
- `exception`: The exception object containing error details.

### On-Demand Notifications

[](#on-demand-notifications)

> Sometimes you may want to send a Telegram notification to someone who is not stored as a notifiable model. With `Notification::route`, you can provide ad-hoc routing information before dispatching the notification. For more details, see the [on-demand notifications](https://laravel.com/docs/13.x/notifications#on-demand-notifications) docs.

```
use Illuminate\Support\Facades\Notification;

Notification::route('telegram', 'TELEGRAM_CHAT_ID')
            ->notify(new InvoicePaid($invoice));
```

### Sending to Multiple Recipients

[](#sending-to-multiple-recipients)

Using the [notification facade](https://laravel.com/docs/13.x/notifications#using-the-notification-facade), you can send a notification to multiple recipients at once.

Warning

If you're sending bulk notifications to many users, the Telegram Bot API will not allow much more than 30 messages per second. Consider spreading out notifications over large intervals of 8—12 hours for best results.

Also note that your bot will not be able to send more than 20 messages per minute to the same group.

If you go over the limit, you'll start getting `429` errors. For more details, refer Telegram Bots [FAQ](https://core.telegram.org/bots/faq#broadcasting-to-users).

```
use Illuminate\Support\Facades\Notification;

// Recipients can be an array of chat IDs or collection of notifiable entities.
Notification::send($recipients, new InvoicePaid());
```

### Using the Telegram Client Directly

[](#using-the-telegram-client-directly)

If you need lower-level Bot API access, you can resolve the `Telegram` client directly from the container:

```
use NotificationChannels\Telegram\Telegram;

$telegram = app(Telegram::class);

$telegram->sendChatAction([
    'chat_id' => $chatId,
    'action' => 'typing',
]);

$telegram->editMessageText([
    'chat_id' => $chatId,
    'message_id' => $messageId,
    'text' => 'Updated message text',
]);

$telegram->deleteMessage([
    'chat_id' => $chatId,
    'message_id' => $messageId,
]);

$telegram->sendMediaGroup([
    'chat_id' => $chatId,
    'media' => json_encode([
        ['type' => 'photo', 'media' => 'https://example.com/one.jpg', 'caption' => 'First'],
        ['type' => 'photo', 'media' => 'https://example.com/two.jpg'],
    ], JSON_THROW_ON_ERROR),
]);

$telegram->stopPoll([
    'chat_id' => $chatId,
    'message_id' => $pollMessageId,
]);
```

Available direct client helpers currently include:

- `sendMessage(array $params)`
- `sendFile(array $params, string $type, bool $multipart = false)`
- `sendMediaGroup(array $params, bool $multipart = false)`
- `sendPoll(array $params)`
- `sendContact(array $params)`
- `sendLocation(array $params)`
- `sendVenue(array $params)`
- `sendDice(array $params)`
- `sendChatAction(array $params)`
- `editMessageText(array $params)`
- `editMessageCaption(array $params)`
- `editMessageMedia(array $params, bool $multipart = false)`
- `editMessageReplyMarkup(array $params)`
- `stopPoll(array $params)`
- `deleteMessage(array $params)`
- `deleteMessages(array $params)`
- `getUpdates(array $params)`

Available Methods
-----------------

[](#available-methods)

For more information on supported parameters, check out these [docs](https://core.telegram.org/bots/api#sendmessage).

### Common Methods

[](#common-methods)

> These methods are optional and common across all the API methods.

- `to(int|string $chatId)` - Set recipient's chat ID.
- `token(string $token)` - Override default bot token.
- `parseMode(enum ParseMode $mode)` - Set message parse mode (or `normal()` to unset). Default is `ParseMode::Markdown`.
- `keyboard(string $text, int $columns = 2, bool $requestContact = false, bool $requestLocation = false)` - Add regular keyboard. You can add as many as you want, and they'll be placed 2 in a row by default.
- `button(string $text, string $url, int $columns = 2)` - Add inline CTA button.
- `buttonWithCallback(string $text, string $callbackData, int $columns = 2)` - Add inline button with callback.
- `buttonWithWebApp(string $text, string $url, int $columns = 2)` - Add inline web app button.
- `disableNotification(bool $disableNotification = true)` - Send silently (notification without sound).
- `businessConnectionId(string $businessConnectionId)` - Send on behalf of a connected business account.
- `messageThreadId(int $messageThreadId)` - Send to a forum / topic thread.
- `directMessagesTopicId(int $directMessagesTopicId)` - Send to a channel direct message topic.
- `protectContent(bool $protect = true)` - Protect content from forwarding and saving.
- `allowPaidBroadcast(bool $allow = true)` - Allow paid high-throughput broadcasts.
- `messageEffectId(string $messageEffectId)` - Add a private-chat message effect.
- `replyParameters(array $replyParameters)` - Set structured reply parameters.
- `suggestedPostParameters(array $suggestedPostParameters)` - Set suggested post parameters for supported direct message topics.
- `options(array $options)` - Add/override payload parameters.
- `sendWhen(bool $condition)` - Set condition for sending. If the condition is true, the notification will be sent; otherwise, it will not.
- `onError(callable $callback)` - Set error handler (receives a data array with `to`, `request`, `exception` keys).
- `getPayloadValue(string $key)` - Get specific payload value.

### Telegram Message Methods

[](#telegram-message-methods)

> Telegram message notifications are used to send text messages to the user. Supports [Telegram formatting options](https://core.telegram.org/bots/api#formatting-options)

- `content(string $content, int $limit = null)` - Set message content with optional length limit. Supports markdown.
- `line(string $content)` - Add new line of content.
- `lineIf(bool $condition, string $content)` - Conditionally add new line.
- `escapedLine(string $content)` - Add escaped content line (for Markdown).
- `view(string $view, array $data = [], array $mergeData = [])` - Use Blade template with Telegram supported HTML or Markdown syntax content if you wish to use a view file instead of the `content()` method.
- `entities(array $entities)` - Set explicit message entities instead of using `parse_mode`.
- `linkPreviewOptions(array $linkPreviewOptions)` - Set Telegram link preview options.
- `chunk(int $limit = 4096)` - Split long messages (rate limited to 1/second).

Note

Chunked messages will be rate limited to one message per second to comply with rate limitation requirements from Telegram.

#### Helper Methods:

[](#helper-methods)

- `escapeMarkdown(string $content)` - Escape a string to make it safe for the `markdownv2` parse mode

### Telegram Location Methods

[](#telegram-location-methods)

> Telegram location messages are used to share a geographical location with the user.

- `latitude(float|string $latitude)` - Set location latitude.
- `longitude(float|string $longitude)` - Set location longitude.
- `horizontalAccuracy(float|int|string $horizontalAccuracy)` - Set the location accuracy radius in meters.
- `livePeriod(int $livePeriod)` - Set the live location period in seconds.
- `heading(int $heading)` - Set the movement direction in degrees.
- `proximityAlertRadius(int $proximityAlertRadius)` - Set the proximity alert radius in meters.

### Telegram Venue Methods

[](#telegram-venue-methods)

> Telegram venue messages are used to share a geographical location information about a venue.

- `latitude(float|string $latitude)` - Set venue latitude.
- `longitude(float|string $longitude)` - Set venue longitude.
- `title(string $title)` - Set venue name/title.
- `address(string $address)` - Set venue address.
- `foursquareId(string $foursquareId)` - (Optional) Set Foursquare identifier of the venue.
- `foursquareType(string $foursquareType)` - (Optional) Set Foursquare type of the venue, if known.
- `googlePlaceId(string $googlePlaceId)` - (Optional) Set Google Places identifier of the venue.
- `googlePlaceType(string $googlePlaceType)` - (Optional) Set Google Places type of the venue.

### Telegram File Methods

[](#telegram-file-methods)

> Telegram file messages are used to share various types of files with the user.

- `content(string $content)` - Set file caption. Supports markdown.
- `view(string $view, array $data = [], array $mergeData = [])` - Use Blade template for caption.
- `captionEntities(array $captionEntities)` - Set explicit caption entities.
- `showCaptionAboveMedia(bool $show = true)` - Show caption above supported media types.
- `file(string|resource|StreamInterface $file, FileType|string $type, string $filename = null)` - Attach a local path, remote URL, Telegram file ID, stream/resource, or raw file contents. Types: `photo`, `audio`, `document`, `video`, `animation`, `voice`, `video_note`, `sticker` (use `Enums\FileType`). Pass a filename when the string represents raw file contents.

#### Helper Methods:

[](#helper-methods-1)

- `photo(string $file)` - Send photo.
- `audio(string $file)` - Send audio (MP3).
- `document(string $file, string $filename = null)` - Send document or any file as document.
- `video(string $file)` - Send video.
- `animation(string $file)` - Send animated GIF.
- `voice(string $file)` - Send voice note (OGG/OPUS).
- `videoNote(string $file)` - Send video note (≤1min, rounded square video).
- `sticker(string $file)` - Send sticker (static PNG/WEBP, animated .TGS, or video .WEBM stickers).

### Telegram Media Group Methods

[](#telegram-media-group-methods)

> Telegram media groups are albums of `photo`, `video`, `audio`, or `document` items sent as a single notification.

- `photo(string|resource|StreamInterface $media, string $caption = null, string $filename = null)` - Add a photo to the group.
- `video(string|resource|StreamInterface $media, string $caption = null, string $filename = null)` - Add a video to the group.
- `audio(string|resource|StreamInterface $media, string $caption = null, string $filename = null)` - Add an audio file to the group.
- `document(string|resource|StreamInterface $media, string $caption = null, string $filename = null)` - Add a document to the group.
- `hasAttachments()` - Determine if the group contains uploaded files and requires multipart transport.

Each media item may be a Telegram file ID, a URL, a local path, a stream/resource, or raw file contents when paired with a filename.

### Telegram Contact Methods

[](#telegram-contact-methods)

> Telegram contact messages are used to share contact information with the user.

- `phoneNumber(string $phone)` - Set contact phone.
- `firstName(string $name)` - Set contact first name.
- `lastName(string $name)` - Set contact last name (optional).
- `vCard(string $vcard)` - Set contact vCard (optional).

### Telegram Dice Methods

[](#telegram-dice-methods)

> Telegram dice messages are interactive emoji dice / darts / slots / bowling style messages.

- `emoji(string $emoji)` - Set the dice emoji (`🎲`, `🎯`, `🎳`, `🏀`, `⚽`, `🎰`, etc.).

### Telegram Poll Methods

[](#telegram-poll-methods)

> Telegram polls are a type of interactive message that allows users to vote on a question. Polls can be used to gather feedback, make decisions, or even run contests.

- `question(string $question)` - Set poll question.
- `choices(array $choices)` - Set poll choices.

Alternatives
------------

[](#alternatives)

For advanced usage, please consider using [telegram-bot-sdk](https://github.com/irazasyed/telegram-bot-sdk) instead.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for details about recent changes.

Testing
-------

[](#testing)

```
$ composer test
```

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Irfaq Syed](https://github.com/irazasyed)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

76

—

ExcellentBetter than 100% of packages

Maintenance88

Actively maintained with recent releases

Popularity68

Solid adoption and visibility

Community46

Growing community involvement

Maturity89

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 74.9% 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 ~109 days

Recently: every ~184 days

Total

33

Last Release

60d ago

Major Versions

2.x-dev → 3.0.02022-10-15

3.x-dev → 4.0.02023-02-14

4.x-dev → 5.0.02024-03-12

5.x-dev → 6.0.02025-02-25

6.x-dev → 7.0.02026-03-19

PHP version history (11 changes)0.0.1PHP &gt;=5.6.4

0.0.6PHP ^7.2

0.1.1PHP ^7.1

0.4.0PHP &gt;=7.1

0.5.1PHP ^7.1 || ^8.0

0.7.0PHP ^7.2 || ^8.0

2.0.0PHP ^7.4 || ^8.0

3.0.0PHP ^8.0

4.0.0PHP ^8.1

6.0.0PHP ^8.2

7.0.0PHP ^8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/20937037?v=4)[Laravel Notification Channels](/maintainers/laravel-notification-channels)[@laravel-notification-channels](https://github.com/laravel-notification-channels)

---

Top Contributors

[![irazasyed](https://avatars.githubusercontent.com/u/1915268?v=4)](https://github.com/irazasyed "irazasyed (197 commits)")[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (18 commits)")[![faissaloux](https://avatars.githubusercontent.com/u/60013703?v=4)](https://github.com/faissaloux "faissaloux (7 commits)")[![abbasudo](https://avatars.githubusercontent.com/u/86796762?v=4)](https://github.com/abbasudo "abbasudo (4 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (3 commits)")[![irajtaghlidi](https://avatars.githubusercontent.com/u/785830?v=4)](https://github.com/irajtaghlidi "irajtaghlidi (3 commits)")[![atymic](https://avatars.githubusercontent.com/u/50683531?v=4)](https://github.com/atymic "atymic (3 commits)")[![alexsoft](https://avatars.githubusercontent.com/u/1451894?v=4)](https://github.com/alexsoft "alexsoft (3 commits)")[![bmitch](https://avatars.githubusercontent.com/u/4009957?v=4)](https://github.com/bmitch "bmitch (2 commits)")[![themsaid](https://avatars.githubusercontent.com/u/4332182?v=4)](https://github.com/themsaid "themsaid (2 commits)")[![putera](https://avatars.githubusercontent.com/u/314314?v=4)](https://github.com/putera "putera (2 commits)")[![MammutAlex](https://avatars.githubusercontent.com/u/10599196?v=4)](https://github.com/MammutAlex "MammutAlex (1 commits)")[![mpociot](https://avatars.githubusercontent.com/u/804684?v=4)](https://github.com/mpociot "mpociot (1 commits)")[![Muetze42](https://avatars.githubusercontent.com/u/26193232?v=4)](https://github.com/Muetze42 "Muetze42 (1 commits)")[![okaufmann](https://avatars.githubusercontent.com/u/4414498?v=4)](https://github.com/okaufmann "okaufmann (1 commits)")[![oyed](https://avatars.githubusercontent.com/u/172114265?v=4)](https://github.com/oyed "oyed (1 commits)")[![peregraum](https://avatars.githubusercontent.com/u/6589559?v=4)](https://github.com/peregraum "peregraum (1 commits)")[![rubendl](https://avatars.githubusercontent.com/u/16331702?v=4)](https://github.com/rubendl "rubendl (1 commits)")[![4irik](https://avatars.githubusercontent.com/u/2486299?v=4)](https://github.com/4irik "4irik (1 commits)")[![VladimirRebilly](https://avatars.githubusercontent.com/u/144002104?v=4)](https://github.com/VladimirRebilly "VladimirRebilly (1 commits)")

---

Tags

bot-apihacktoberfestlaravellaravel-12-packagelaravel-notification-channelslaravel-notificationslaravel-packagelaravel-telegramphpphp-packagephp-packagestelegramtelegram-bottelegram-bot-apitelegram-notificationlaravelnotificationtelegramtelegram notificationtelegram notifications channel

###  Code Quality

TestsPest

Static AnalysisPHPStan

### Embed Badge

![Health badge](/badges/laravel-notification-channels-telegram/health.svg)

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

###  Alternatives

[laravel-notification-channels/discord

Laravel notification driver for Discord.

2371.3M11](/packages/laravel-notification-channels-discord)[mckenziearts/laravel-notify

Flexible flash notifications for Laravel

1.7k1.1M5](/packages/mckenziearts-laravel-notify)[s-ichikawa/laravel-sendgrid-driver

This library adds a 'sendgrid' mail driver to Laravel.

4139.3M1](/packages/s-ichikawa-laravel-sendgrid-driver)[laravel-notification-channels/twilio

Provides Twilio notification channel for Laravel

2587.7M12](/packages/laravel-notification-channels-twilio)[laravel-notification-channels/expo

Expo Notifications Channel for Laravel

64426.3k1](/packages/laravel-notification-channels-expo)[gr8shivam/laravel-sms-api

A modern, flexible Laravel package for integrating any SMS gateway with REST API support

10138.4k](/packages/gr8shivam-laravel-sms-api)

PHPackages © 2026

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