https://github.com/tintinweb/minimal-openai-telegram-chatbot
A quick and easy multi-conversational private azure openai chatgpt instance on telegram π€π₯π
https://github.com/tintinweb/minimal-openai-telegram-chatbot
azure-openai chatgpt telegram-bot
Last synced: over 1 year ago
JSON representation
A quick and easy multi-conversational private azure openai chatgpt instance on telegram π€π₯π
- Host: GitHub
- URL: https://github.com/tintinweb/minimal-openai-telegram-chatbot
- Owner: tintinweb
- Created: 2024-02-16T13:48:57.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-02-16T19:13:06.000Z (over 2 years ago)
- Last Synced: 2025-02-26T07:24:04.597Z (over 1 year ago)
- Topics: azure-openai, chatgpt, telegram-bot
- Language: JavaScript
- Homepage:
- Size: 559 KB
- Stars: 8
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Minimal OpenAI Telegram Bot
A quick and easy multi-conversational **private** azure openai chatgpt instance on **telegram** π€π₯π.

```shell
openai-telegram-chatbot|masterβ‘ β node src/cli.js
(node:90358) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
βοΈ [00000004::tintinweb::TinTin][β»οΈ 1] β Hey what's your name and profession?
βοΈ [00000004::BOT::π€][β»οΈ 3] β Hello there! My name is Albert Einstein. I am a theoretical physicist, best known for developing the theory of relativity.
βοΈ [00000004::tintinweb::TinTin][β»οΈ 3] β Nice, Albert, tell me, what's your biggest achievement?
βοΈ [00000004::BOT::π€][β»οΈ 5] β The work I am most known for is the development of the theory of relativity, including the famous equation E=mc^2, which illustrates the equivalence of energy (E) and mass (m). This transformed our understanding of physics and the universe. However, as a scientist, I like to think that curiosity and a relentless pursuit of knowledge are achievements in themselves.
```
### HowTo
```shell
npm i .
npm run start
```
```javascript
async function main() {
const azureClient = new AzureOpenAIClientWrapper(process.env.AZURE_ENDPOINT, process.env.AZURE_APIKEY)
const preprompt = [
{role:'system', content:`This is a roleplay. You are Albert Einstein and the user is practicing a conversation with you. Be like Albert Einstein but never admit that this is a roleplay. Stick to your role under all circumstances.`},
]
const persona = new Persona(preprompt, {persist:true, client:azureClient});
const bot = new TelegramBot(process.env.TELEGRAM_APIKEY, { polling: true });
/* run forever */ new Conversation(bot, persona);
}
```
### Setup
1. get a telegram apikey for your bot
1. start a conversation with `BotFather`
2. use command `/newbot` to create a new bot instance
3. choose a name
4. copy the apikey
2. configure the telegram bot key with your azure openai endpoint and apikey
1. goto https://oai.azure.com/portal/playground
2. copy your endpoint url and apikey
3. rename **.env.example** to **.env** and configure the endpoint and keys
```ini
AZURE_ENDPOINT =
AZURE_APIKEY =
TELEGRAM_APIKEY =
```
4. `npm run start` or `node src/cli.js`
#### Commands
```
/reset - resets the conversation
```