Skip to content

irfansofyana/telegram-openai-bot

Repository files navigation

MyTelegramAIBot

This README provides setup instructions for creating a Telegram Bot using Typescript, OpenAI API and Replit. Using these technologies, you can create a bot that can respond to user commands and execute functions programmed into the code.

Prerequisites

Before starting this project, make sure you have the following ready:

Setting up the project

Setup Replit Project

  1. Create a new project in Replit, making sure to select Typescript as your language when prompted. After the project is created, click on “Open in IDE” to open the project in an online editor or click on “Open in Terminal” to open it in a command line interface (CLI).
  2. In your CLI, run npm install --save @types/node @types/telegraf. This will install telegraf library package which supports Typescript.

Setup OpenAI API Key

  1. Create an OpenAI account and log in at https://openai.com/signup/.
  2. Click on your profile icon in the upper right corner of the page and select “API Keys” from the dropdown menu.
  3. On the API Keys page, click “Generate New Key” to generate a new API key for your account.
  4. The new API key will be displayed on the page – make sure to copy it down or save it somewhere safe as you won’t be able to see it again once you leave this page!
  5. Store the Open API Key as a secret in the Replit project.

Setup Telegram Bot

  1. Register a Telegram Bot: First, you will need to register your bot with the Telegram Bot Father. This can be done by sending a message to @BotFather (the official bot from Telegram). Once you do that, type in the command “/newbot” and follow the instructions provided by Bot Father. After completing the registration process, you will be provided with an access token which you will need later on.
  2. Save the access token as a secret in the Replit project.
  3. Setting up the bot commands by chatting /setcommands to @BotFather and set following command whoami, tldr, ama, code, explaincode, brainstorm.

Run the Bot

Just click Run on Replit the project and the bot ready to help you answering your questions!

Tips: to make it always available, you can use Always On feature on Replit.

Fun Fact

Almost 90% of this README content is generated by the help of this bot itself :)

About

telegram bot to help answer my questions. Powered by Open AI.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published