Initial Setup

Basic Setup Instructions

All the methods listed on Telegram Bot API page are fully supported by this SDK.

Standalone Setup

In order to use the library in your project, You need to install the SDK with Composer. Refer the Getting Started page for more details on how to install with Composer and autoload in your project.

Initialize Library

The first​ step is to initialize the library. Once you do that, You'll get access to all the available API Methods to make requests to Telegram.

use Telegram\Bot\Api;

$telegram = new Api('BOT TOKEN');

Laravel Setup

Open telegram.php the configuration file in config directory and set the bot_token with your Telegram's Bot Access Token or you could also set environment variable TELEGRAM_BOT_TOKEN with the appropriate value.
Refer the configuration file for other default configuration settings.

Config Overview

Open the config file for detailed comments for each option.

Set your Telegram Bot Access Token in bot_token key [REQUIRED]

'bot_token' => '1234:ABCD'

All other configs are optional, use as per your requirements.

Test Bot

A simple method for testing your bot's auth token.
Returns basic information about the bot in form of a User object.

See getMe docs for more details.

$response = $telegram->getMe();

$botId = $response->getId();
$firstName = $response->getFirstName();
$username = $response->getUsername();
$response = Telegram::getMe();

$botId = $response->getId();
$firstName = $response->getFirstName();
$username = $response->getUsername();