Register Webhooks
In order to receive Telegram updates through a webhook, it has to be registered to a specific bot. This can be accomplished both programmatically and through an artisan command
artisan command
You can register a webhook calling the telegraph:set-webhook
artisan command:
php artisan telegraph:set-webhook
some options are available in order to customize the webhook settings, refer to bots documentation for more info:
php artisan telegraph:set-webhook --drop-pending-updates --max-connections=100 --secret=super_secret_token
programmatically
if you are implementing a custom bot management logic, you can register a webhok using the TelegraphBot
model:
/** @var DefStudio\Telegraph\Models\TelegraphBot $telegraphBot */ $telegraphBot->registerWebhook()->send();
some options are available in order to customize the webhook settings, refer to bots documentation for more info:
WarningManual updates polling is not available if a webhook is set up for the bot. Webhook should be remove first using its unregisterWebhook method
Routes
Telegraph register a route to handle webhook messages. By default, the URL is: https://<server_domain>/telegraph/{token}/webhook
, but it can be customized in telegraph.php config file (webhook.url
) or entirely disabled (by setting its value to null
)