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")

About this template

This app creates a Telegram bot that fetches the latest financial news from Bloomberg's RSS feed, analyzes the news titles using LLM ability, and shares it with users in the form of emoji representations. The user will be asked for their API token when they run the app.

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.

Category
Technology
Last published
July 20, 2024

More templates like this

MP3ify: Youtube to MP3 Converter

A web application that allows users to download YouTube videos from URLs and provides the option to convert them to MP3 format.

Python
Flask

Discord Moderation Bot

The Discord bot monitors all messages in the server. If a message contains profanity, the bot deletes it and sends a warning to the channel. The bot also notifies the host about the deletion via a direct message. Additionally, the bot outputs a helpful error message to a channel if there is a permissions error, guiding the server admin to enable the required permission in the Discord Developer portal.

Discord
Python
Flask

Backend Server

This skeleton is streamlined for creating backend services using FastAPI. It's an excellent choice for building microservices or APIs with minimal frontend requirements.

Fast API
Python
Home
/
Emoji Financial News Bot