Download the PHP package codewiser/telegram-subscriber without Composer
On this page you can find all versions of the php package codewiser/telegram-subscriber. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download codewiser/telegram-subscriber
More information about codewiser/telegram-subscriber
Files in codewiser/telegram-subscriber
Package telegram-subscriber
Short Description Telegram Subscriber for Laravel
License MIT
Informations about the package telegram-subscriber
Telegram Subscriber for Laravel
The package provides a solution for retrieving chat ID.
Installation and setup
Package uses irazasyed/telegram-bot-sdk
. So above all follow
Telegram Bot SDK
instructions
and set up your first Telegram Bot. Most likely you need to run:
php artisan vendor:publish --tag="telegram-config"
In config/telegram.php
configuration file add bot name
parameter and
register DeeplinkCommand
. You may not define webhook_url
as it will be
reconfigured on a fly.
Retrieving chat ID
Implement \Codewiser\Telegram\Contracts\TelegramNotifiable
to a
User
model. You might need to write a migration...
Now, create service to implement
\Codewiser\Telegram\Contracts\TelegramNotifiableProvider
. This is an
example of implementation, your may implement it however you like.
At last, register this service in AppServiceProvider
of your application
We are ready to go.
Getting updates
Register webhook
If you are properly configure bot in config/telegram.php
this is enough
to use telegram:webhook
command provided by Telegram Bot SDK
package. We recommend to read help:
php artisan help telegram:webhook
This package provides webhook controller to deal with incoming messages.
For example DeeplinkCommand
, that was
mentioned above, used to handle /start
command with deeplink token.
You are free to add any other command handlers to config/telegram.php
.
Read more about Bot Commands.
Long polling
This package brings telegram:poll
command to get updates without
registering webhook. Just call a command.
Usage
Subscribe user
First, we need to issue a deeplink for a user.
User follows deeplink, opens telegram client and presses Start button.
Codewiser\Telegram\Commands\DeeplinkCommand
handles incoming update,
resolves deeplink token and update User
with chat_id
.
For now, this user has telegram route and may be notified via Telegram.