Laravel: Create Telegram Bot Application without Botman Studio

By | March 21, 2018

Installation

We are using Botman package, and Botman Telegram Driver.

Configure .env

Use Bot Father to create new bot and get the API Token for the bot, store it in .env.

TELEGRAM_TOKEN="your-bot-api-token"

Telegram End Point

Create a route & controller for your Telegram Bot to use after this (webhook).

In TelegramController, add the following:

Now you are done preparing for next part.

Webhook

For development purpose, you can use valet share to have a live server. For Windows / Linux, you can install ngrok.io to have a live server.

valet share is actually running a ngrok.

Run command valet share and and then register our app with Telegram using php artisan botman:telegram:register command.

CSRF Token

In App\Http\MiddlewareVerifyCsrfToken, disable CSRF token for /telegram route.

One you are done setting up the webhook, open up your Telegram, start talk with your bot, /hi. You should received response from your bot.

4 thoughts on “Laravel: Create Telegram Bot Application without Botman Studio

    1. nasrulhazim.m Post author

      takda kalau yg pakai botman, tak buat sbb tak flexible to my project. haha..

      ya, supposed webhook.

      Reply

Leave a Reply

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

20 + 16 =