BuildShip Logo
BuildShip Community

Telegram Chatbot

An easy-to-deploy text-only Telegram chatbot using OpenAI's Assistant. It signals typing, retrieves chat history if needed, processes the conversation, and sends responses.

315

Report this template

Select the reason for reporting

Describe the issue in detail

Share template

Link to template

https://templates.buildship.com/template/6u5sENaO8M3a/

No examples available for this flow.

Read me

Telegram Chatbot

Here's a simple template that demonstrates how you can easily utilize BuildShip to build an AI Telegram Chatbot with the OpenAI Assistant node. The template also uses the BuildShip Database to maintain the chat sessions for each channel.

✅ Prerequisites

1. Telegram Bot Setup and API Key (through @Botfather)

  • Go to your Telegram Account and search for @Botfather in the search tab.
  • Click "start" to activate the BotFather bot.
  • Choose or type the /newbot command.
  • Choose a name and username for your bot. The username must be unique and end with word bot. The bot would be available to add in groups or chat via the search bar using its unique username.
  • To enable your bot to respond to group messages, send the command /setprivacy and follow the prompts. Disabling group privacy will allow your bot to receive and respond to all messages that people send to groups. Keeping enabled will allow your bot to receive messages that mention the bot by username or start with the / symbol.
  • Once you're done, you'd receive a message containing your bot's API Key and a link leading to your bot, eg: t.me/[bot_username].
  • Copy this API Key and add it to your Telegram Bot Trigger in the template.

🌟 Refer to the entire documentation on setting up the Telegram Bot Trigger here.

2. OpenAI API Key

This template uses the OpenAI Assistant. You can get your OpenAI API Key from the OpenAI Developer Dashboard. Add this key to the OpenAI Assistant node.

Create an OpenAI Assistant on the OpenAI Developer Dashboard > Assistants, and copy the Assistant ID and add it to your Assistant node.

💡QUICK NOTE: When getting the Assistant ID from the OpenAI Dashboard, it's best to select 'text' as the Response Format.

⚙️ Customization

You can customize this chatbot for your use case by:

  • adjusting the instructions in the OpenAI Assistant node, or by
  • adding nodes to the OpenAI Assistant node’s toolkit

🧪 Testing

Once all the set up is complete and the API Keys are added, click on the "Ship" button to deploy the workflow. This would automatically connect to your Telegram Bot you just created.

Test out the workflow by directly messaging your bot, for example, saying "Quiz me!". The bot should reply with a history MCQ quiz. You can directly respond with the answer option, as it now maintains the chat history and would have the context of the previous conversation.

In case of any issues, check out the logging panel at the bottom for a better debugging experience.

🔗 Resources

  • Check out the dedicated documentation for the Assistant Variants: here
  • How to set up an OpenAI Assistant: here