Telegram Bot Integration

Connect your FileBrain project with Telegram to provide instant access to your documents through chat.

Integration Options

Quick Setup

Use our built-in Telegram bot functionality for instant deployment. No coding required.

Recommended

Custom Bot

Build your own bot using our API for complete customization control.

Advanced

Quick Setup Guide

  1. 1

    Go to Project Settings

    Navigate to your project settings and find the "Telegram Integration" section.

  2. 2

    Enable Telegram Bot

    Click "Enable Telegram Bot" and follow the setup wizard. You'll receive a unique bot token.

  3. 3

    Start Using Your Bot

    Click the provided Telegram link or search for your bot's username in Telegram to start chatting.

Custom Implementation

For developers who want to create their own Telegram bot implementation, here's a Python example using our API:

Python Example
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
import requests

# Initialize bot with your tokens
def init_bot(telegram_token, filebrain_api_key, project_id):
    updater = Updater(token=telegram_token, use_context=True)
    dispatcher = updater.dispatcher

    # Handle /start command
    def start(update, context):
        update.message.reply_text('Hi! Send me a message to search your documents.')

    # Handle messages
    def handle_message(update, context):
        query = update.message.text
        
        # Call FileBrain API
        response = requests.post(
            'https://filebrain.pro/api/chat/v1/',
            headers={'Authorization': f'Bearer {filebrain_api_key}'},
            json={
                'message': query,
                'project_id': project_id
            }
        )
        
        if response.status_code == 200:
            answer = response.json()['answer']
            update.message.reply_text(answer)
        else:
            update.message.reply_text('Sorry, I encountered an error.')

    # Register handlers
    dispatcher.add_handler(CommandHandler("start", start))
    dispatcher.add_handler(MessageHandler(Filters.text, handle_message))

    return updater

# Start the bot
if __name__ == '__main__':
    updater = init_bot(
        'YOUR_TELEGRAM_TOKEN',
        'YOUR_FILEBRAIN_API_KEY',
        'YOUR_PROJECT_ID'
    )
    updater.start_polling()
    updater.idle()

Requirements

  • Python 3.7 or higher
  • python-telegram-bot library
  • requests library
  • FileBrain API key
  • Telegram Bot token (from @BotFather)

Need Help?

Having trouble setting up your Telegram bot? Our support team is here to help: