Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Miladjfr's avatar

Probelm Creating Post Routes for Telegram Webhook

Hello, I'm new to PHP/Laravel and so please bear with me solving my problem . I'm Trying to set a Telegram bot webhook , so this is my route in web.php :

Route::post('{token}/webhook', function () { $updates = Telegram::getWebhookUpdate(); return 'ok'; });

but i receive error on this route : " The GET method is not supported for route /bot-token/webhook. Supported methods: POST " ( I used post method but the error is not clear and say Get method is not supported !! )

And i have this situation on my Telegram webhook :

{"ok":true,"result":{"url":"https://siteurl.site/token/webhook","has_custom_certificate":false,"pending_update_count":58,"last_error_date":1698503113,"last_error_message":"Wrong response from the webhook: 500 Internal Server Error","max_connections":40,"ip_address":"IP"}}

I Tested another post routes and found out all the Post routes face this type of error .

So i feel stuck up . Any Recommendation will be appreciated .

Laravel Ver 10

0 likes
6 replies
Snapey's avatar

do you have documentation that states that telegram will use POST request?

Miladjfr's avatar

@Snapey I use Telegram-Bot-SDK package and on its documentation Pointed to use Post Route : This is The Link : https://telegram-bot-sdk.com/docs/guides/webhook-updates?language=laravel

and this is The example on Docs : " Whenever there is an update for the bot, Telegram will send an HTTPS POST request to the specified url, containing an Update object. In case of an unsuccessful request, Telegram will give up after a reasonable amount of attempts."

Route::post('/token/webhook', function () { $updates = Telegram::getWebhookUpdate();

return 'ok';

});

Snapey's avatar

@Miladjfr the intention in that bad code example is that you replace <token> with your actual token. Did you do that?

Miladjfr's avatar

@Snapey yes i did , I thinks as you mentioned their documentations are poor . I struggling few days to run this package with no success but i did setup Botman in minutes and also the webhook is working well . Do you know what is the main different between this package ( telegram-bot-sdk ) and Botman ? Can i use Botman instead of this package ?

Miladjfr's avatar

@Snapey Thanks for the Reply , but the Error still exist . and i used the same code if you look at my first post . I got that code from documentation . If i change Post with Get or use somthing like Route::match(['get', 'post']) the error disappear and Controller do the Action, but lt looks like the webhook not working well as i got receive error msg from telegram getWebhookInfo . and also i don't know how to get webhook data for further processing because this example from doc : $updates = Telegram::getWebhookUpdate(); pass me nothing

Please or to participate in this conversation.