by Lazy Sloth
Emoji Financial News Bot
import logging
import requests
from telegram import Update, Bot
from telegram.ext import (
Updater,
CommandHandler,
MessageHandler,
filters,
CallbackContext,
)
from abilities import apply_llm_prompt_to_every_item
from bs4 import BeautifulSoup
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)
TELEGRAM_API_TOKEN = None
RSS_FEED_URL = "https://news.google.com/rss/search?q=when:24h+allinurl:bloomberg.com&hl=en-US&gl=US&ceid=US:en"
def fetch_financial_news_titles() -> list[str]:
logger.info("Fetching financial news titles")
response = requests.get(RSS_FEED_URL)
soup = BeautifulSoup(response.content, "lxml-xml")
Emoji Financial News Bot
Created: | Last Updated:
Introduction to Emoji Financial News Bot Template
Welcome to the Emoji Financial News Bot template! This template allows you to create a Telegram bot that fetches the latest financial news from Bloomberg's RSS feed, analyzes the news titles using an LLM ability, and shares it with users in the form of emoji representations. This article will guide you through the steps to set up and use this template on the Lazy platform.
To get started, click on "Start with this Template" on the Lazy platform. This will pre-populate the code in the Lazy Builder interface, so you won't need to copy, paste, or delete any code manually.
Setting Environment Secrets
Before you can use the Emoji Financial News Bot, you need to set an environment secret for the Telegram API token. This token is necessary for your bot to authenticate and interact with the Telegram API.
- Go to the Environment Secrets tab within the Lazy Builder.
- Click on "Add Secret" and enter the key as
TELEGRAM_API_TOKEN
. - For the value, enter your actual Telegram bot API token that you obtained from the BotFather on Telegram.
- Save the secret.
External Integrations
No external integrations are required for this template beyond obtaining a Telegram bot API token from the BotFather on Telegram. If you haven't already created a bot and obtained a token, please follow these steps:
- Search for the "BotFather" on Telegram and start a conversation.
- Use the
/newbot
command to create a new bot. - Follow the instructions provided by BotFather to set up your bot and receive your API token.
Using the Test Button
Once you have set your environment secret, you can use the Test button to begin the deployment of the app. The Lazy CLI will launch, and you will be prompted for any required user input only after using the Test button.
When you press the Test button, the app will start, and you will be asked to enter your Telegram API token through the Lazy CLI. This is the same token you saved earlier as an environment secret.
Interacting with Your Telegram Bot
After the deployment is complete, you can interact with your Telegram bot. Here's how:
- Open Telegram and search for your bot by the username you gave it during the setup with BotFather.
- Start a conversation with your bot by sending the
/start
command. - Your bot will welcome you and provide instructions to type
/news
to get the latest financial news in emojis. - When you send the
/news
command, the bot will fetch and analyze the latest financial news titles and send them back to you in emoji form.
That's it! You now have a working Telegram bot that provides financial news updates in a fun and engaging emoji format. Enjoy your new Emoji Financial News Bot, and don't hesitate to reach out for support if you encounter any issues.
Technologies
![Python](https://i.pinimg.com/originals/2f/9c/11/2f9c11f9e55efbf1791f12c06d60729b.jpg)
![Telegram](https://storage.googleapis.com/lazy-apps-images-bucket/technologies/52dffc834291988d8797782043116064_telegram.1024x1024.png)