Spread the love

When using BotMan in laravel framework, you set webhook for your telegram bot. After that when you send message using your bot you may get an error 405 Method Not Allowed .

You can solve this problem in different ways.

Solution 1

First of all when you register a webhook for botman using the default configuration you don’t just past the URL. Rather you must append /botman to the end of your public URL.

Lets say you are using ngrok. In my case the public URL of my bot is this.


So when you register your webhook the full URL should look like as follows:


Solution 2

Using a webhook means Telegram will POST json messages to Laravel. Laravel’s POST needs a CSRF token and since Telegram does not send a CSRF token. So you need to add the webhook url to the CSRF exclusion list. If you add your public URL to CSRF exclusion list you need to consider making the URL long enough inorder to be impossible to guess for external users. You can use browserling to generate random string for URL.

To add yourURL to CSRF exclusion list Open App\Http\Middleware\VerifyCsrfToken.php and add your URL.

    protected $except = [

Categories: Web


Leave a Reply

Your email address will not be published. Required fields are marked *