Skip to main content

Installation

info

If you want to use this bot with Laravel, skip to the Laravel Integration page.

This package can be installed via composer:

composer require telepath/telepath

Configuration

To be able to interact with Telegram servers you need to create an instance and pass your Telegram Bot API Token:

$bot = new \Telepath\Bot('your api token');

You can also use the BotBuilder class to obtain an instance of the Bot class.

$bot = \Telepath\Facades\BotBuilder::token('your api token')->build();

That's already enough to send messages and other media.

Custom Telegram Bot API Server

If you're using a custom Telegram Bot API Server, you need to pass the URL as an additional parameter to the constructor of Bot.

$bot = new \Telepath\Bot('your api token', apiServerUrl: 'http://127.0.0.1:8081');

When using the BotBuilder class, pass the URL as follows:

$bot = \Telepath\Facades\BotBuilder::token('your api token')
->apiServerUrl('http://127.0.0.1:8081')
->build();
Important

Please read carefully how to move a bot to a local server in the documentation.