Telegram

Installation & Setup

First you need to pull in the Telegram Driver.

composer require botman/driver-telegram

Then load the driver before creating the BotMan instance (only when you don't use BotMan Studio):

DriverManager::loadDriver(\BotMan\Drivers\Telegram\TelegramDriver::class);

// Create BotMan instance
BotManFactory::create($config);

Or if you use BotMan Studio:

php artisan botman:install-driver telegram

This driver requires a valid and secure URL in order to set up webhooks and receive events and information from the chat users. This means your application should be accessible through an HTTPS URL.

{callout-info} ngrok is a great tool to create such a public HTTPS URL for your local application. If you use Laravel Valet, you can create it with "valet share" as well.

To connect BotMan with your Telegram Bot, you first need to follow the official guide to create your Telegram Bot and an access token.

Once you have obtained the access token, place it in your BotMan configuration. If you use BotMan Studio, you can find the configuration file located under config/botman/telegram.php.

'botman' => [
    'telegram' => [
    	'token' => 'YOUR-TELEGRAM-TOKEN-HERE',
    ]
],

Supported Features

This is a list of features that the this driver supports. If a driver does not support a specific action, it is in most cases a limitation from the messaging service - not BotMan.

Feature Supported?
Question-Buttons
Image Attachment
Video Attachment
Audio Attachment
Location Attachment

Register Your Webhook

To let your Telegram Bot know, how it can communicate with your BotMan bot, you have to register the URL where BotMan is running at, with Telegram.

You can do this by sending a POST request to this URL:

https://api.telegram.org/bot<YOUR-TELEGRAM-TOKEN-HERE>/setWebhook

This POST request needs only one parameter called url with the URL that points to your BotMan logic / controller. If you use BotMan Studio it will be: https://yourapp.domain/botman. HTTPS is a must, because of security reasons.