![]() ![]() You will find it at t.me/YOUR_BOT_USERNAME. By the end of the interaction, you will get some of informations like this:ĭone! Congratulations on your new bot. After that, type /newbot and follow all of the instruction provided. Start a conversation with BotFather, by tapping Start. Your application should run at localhost:8000. To make sure everything is going as planned, go inside blog directory and run php artisan serve. Now, your should have blog folder containing Laravel project. Open your terminal and in your local directory simply run composer create-project -prefer-dist laravel/laravel blog For further information to create a Laravel project, check out instructions in the official docs. You may install the project in any directory in your machine as you like. The finished project example is available on GitHub. Telegram account, and the Telegram apps installed in your device.Basic knowledge of PHP programming language.If you haven’t, go to the official Composer website and follow the instructions. Make sure you have Composer installed in your machine.Here are some requirements before getting started: Integrating our Telegram bot to the Laravel project.This tutorial will cover some topics such as: In this article we will try to make a simple chat bot for Telegram messaging platform. On the other side, Laravel is one of the most popular framework to build web applications written in PHP. And also, Bot has been supported by lots of instant messaging service provider such as Telegram, Line, Facebook, etc. Yeah, that’s all the code you need.“Telegram Messaging App” by Christian Wiediger on UnsplashĬhat bot’s popularity has been growing these past years because of it’s great functionality and reliability to handle some cases in business. Here you can find how to get the ID from a channel and here is how to get the ID from a group.Īnd that’s it. You need to change CHAT_ID to the ID of the group, the channel, or the conversation you want the bot to interact with. Open handler.py and change the contents to: import telegram import sys import os TOKEN = os.environ CHAT_ID = XXXXXXXX def send_message(event, context): bot = telegram.Bot(token=TOKEN) bot.sendMessage(chat_id = CHAT_ID, text = ‘Hey there!’) For now, let’s define the function to send a message. To do that, we’re going to install everything locally later. We need to import the libraries, but we’ll have a problem: python-telegram-bot is not part of the AWS standard, so we need to include all the necessary files in the package when deploying. ![]() Create a new file, requirements.txt, and write: python-telegram-bot=12.2.0 We’re going to use a wrapper to deal with the Telegram API: python-telegram-bot will do the trick. Note that AWS Lambda is free up to a certain limit, but be aware of the quotas in case you want to send lots of messages. So, to summarize: what are we going to do? ![]() You might want to publish to a Telegram channel on a daily basis, or maybe send a message every week with scraped info, or get an alert every five minutes about some event results all of those examples fit here. Obviously, that was my personal use case. So, following the philosophy of Al Sweigart ( automate the boring stuff!), I decided to automate that task. Even though that API allows filtering and has a mailing system, for whatever reason, it doesn’t allow to combine both.Įither I send me a large daily mail with all the info, or I manually filter the API every day. A few days ago I found myself checking, again, some random info from an API. ![]()
0 Comments
Leave a Reply. |