Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BriefChief is an intelligent Telegram bot that analyzes your team's chat conversations and automatically identifies task agreements, deadlines, and action items. It seamlessly integrates with Jira to provide context-aware insights powered by AI.

License

Notifications You must be signed in to change notification settings

kepuvv/BriefChief

Β 
Β 

Repository files navigation

πŸ€– BriefChief

Python 3.10+ License: MIT Telegram Bot

BriefChief is an intelligent Telegram bot that analyzes your team's chat conversations and automatically identifies task agreements, deadlines, and action items. It seamlessly integrates with Jira to provide context-aware insights powered by AI.

✨ Features

  • πŸ” Smart Chat Analysis - Uses GPT-4o to analyze conversation history and extract task agreements
  • πŸ“‹ Jira Integration - OAuth 2.0 authentication with full Jira API access
  • 🌐 Multi-language Support - Built-in i18n support (English and Russian)
  • πŸ” Secure Authentication - Token encryption and secure credential management
  • πŸ› οΈ LangChain Agent - Intelligent agent with Jira tools for context-aware responses
  • πŸ“Š Task Tracking - Automatically suggests task updates and status changes
  • πŸ’¬ Natural Language Processing - Understands context and filters out casual conversations

πŸ’» How it looks like

Example of DriefChief usage

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Telegram Bot   │─────▢│  LLM Handler     │─────▢│    OpenAI       β”‚
β”‚  (bot.py)       β”‚      β”‚  (call_llm)      β”‚      β”‚    GPT-4o       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                        β”‚
         β”‚                        β”‚ Tools
         β”‚                        β–Ό
         β”‚               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚               β”‚  Jira Tools      β”‚
         β”‚               β”‚  (LangChain)     β”‚
         β”‚               β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                        β”‚
         β–Ό                        β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Jira Auth      │◀────▢│  Jira Cloud API  β”‚
β”‚  Server         β”‚      β”‚  (OAuth 2.0)     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“‹ Prerequisites

  • Python 3.10 or higher
  • Telegram Bot Token (from @BotFather)
  • Telegram API credentials (from my.telegram.org)
  • OpenAI API Key
  • Jira Cloud account with OAuth 2.0 app configured
  • PostgreSQL or file-based storage for tokens

πŸš€ Quick Start

1. Clone the Repository

git clone https://github.com/vladmiron85/BriefChief.git
cd briefchief

2. Install Dependencies

pip install -r requirements.txt

For the Jira Auth Server:

pip install -r jira_auth_server/requirements.txt

3. Configure Environment Variables

Create a .env file in the root directory:

# Telegram Bot Configuration
TELEGRAM_BOT_TOKEN=your_bot_token_here
TELEGRAM_API_ID=your_api_id
TELEGRAM_API_HASH=your_api_hash
TELEGRAM_SESSION_STRING=your_session_string

# OpenAI Configuration
OPENAI_API_KEY=your_openai_api_key

# Jira Auth Server URL
JIRA_AUTH_SERVER_URL=http://localhost:5000

# Internal API Key (for secure communication)
INTERNAL_API_KEY=your_generated_internal_api_key

4. Configure Jira Auth Server

Create .env file in jira_auth_server/ directory:

# Jira OAuth 2.0 Configuration
JIRA_CLIENT_ID=your_jira_client_id
JIRA_CLIENT_SECRET=your_jira_client_secret
JIRA_REDIRECT_URI=https://yourdomain.com/auth/callback
JIRA_BASE_URL=https://auth.atlassian.com

# Token Encryption
ENCRYPTION_KEY=your_fernet_encryption_key

# Internal API Key (must match bot's key)
INTERNAL_API_KEY=your_generated_internal_api_key

5. Generate Required Keys

Generate Telegram Session String:

python generate_session.py

Generate Encryption Key:

python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"

Generate Internal API Key:

python -c "import secrets; print(secrets.token_urlsafe(32))"

6. Set Up Jira OAuth App

  1. Go to Atlassian Developer Console
  2. Create a new OAuth 2.0 (3LO) app
  3. Set callback URL: http://localhost:5000/auth/callback (for local development)
  4. Add permissions: read:jira-work, read:jira-user, write:jira-work (the last one is dangerous. don't switch it on during experiments until you 100% sure that your AI agent is fine)
  5. Copy Client ID and Client Secret to your .env file

7. Start the Services

Terminal 1 - Start Jira Auth Server:

cd jira_auth_server
python jira_auth_server.py

Terminal 2 - Start Telegram Bot:

python bot.py

πŸ’‘ Usage

Bot Commands

  • /auth - Authenticate with Jira
  • /status - Check your Jira authentication status
  • /brief - Analyze recent chat messages and identify task agreements
  • /test - Test with pre-generated chat history

Example Workflow

  1. Authenticate with Jira:

    User: /auth
    Bot: πŸ‘‹ Please authorize with Jira...
    [User clicks button and completes OAuth flow]
    Bot: βœ… Authorization Successful!
    
  2. Analyze Chat:

    User: /brief
    Bot: Select LLM model:
    [User selects OpenAI]
    Bot: Getting chat messages...
    Bot: Processing messages with OpenAI...
    
    Found task agreements:
    
    Task: Update login page design
    State change: New status is In Progress
    Comment to add: Team agreed to use blue color scheme...
    Task link: PROJ-123
    

πŸ“ Project Structure

briefchief/
β”œβ”€β”€ bot.py                      # Main Telegram bot
β”œβ”€β”€ messages.py                 # i18n message definitions
β”œβ”€β”€ generate_session.py         # Telegram session generator
β”œβ”€β”€ requirements.txt            # Python dependencies
β”œβ”€β”€ .env.example               # Example environment variables
β”‚
β”œβ”€β”€ LLM/                       # LLM and AI logic
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ llm_handler.py        # LLM orchestration
β”‚   β”œβ”€β”€ jira_tools.py         # Jira LangChain tools
β”‚   β”œβ”€β”€ prompt_system.txt     # System prompt
β”‚   └── prompt_user.txt       # User prompt template
β”‚
└── jira_auth_server/         # Jira OAuth server
    β”œβ”€β”€ jira_auth_server.py   # Flask auth server
    β”œβ”€β”€ requirements.txt       # Auth server dependencies
    β”œβ”€β”€ .env.example          # Example auth server config
    β”œβ”€β”€ JIRA_AUTH_README.md   # Detailed auth docs
    └── auth_flow_diagram.md  # OAuth flow diagram

πŸ”§ Configuration

Customizing Prompts

Edit LLM/prompt_system.txt and LLM/prompt_user.txt to customize how the AI analyzes conversations:

# prompt_system.txt
You are an AI assistant specialized in analyzing chat conversations...

# prompt_user.txt
Your task is to:
1. Read through the provided chat history
2. Identify any agreements made on tasks
3. Summarize changes to be made
...

Adding New Languages

Edit messages.py to add new language support:

MESSAGES = {
    "ru": { ... },
    "en": { ... },
    "es": {  # Add Spanish
        "auth_button": "πŸ” Autorizar con Jira",
        ...
    }
}

πŸ› Troubleshooting

Bot doesn't respond

  • Check if both services are running (bot and auth server)
  • Verify TELEGRAM_BOT_TOKEN is correct
  • Check logs for errors

Jira authentication fails

  • Verify OAuth app configuration in Atlassian
  • Check JIRA_CLIENT_ID and JIRA_CLIENT_SECRET
  • Ensure callback URL matches exactly

LLM returns errors

  • Verify OPENAI_API_KEY is valid and has credits
  • Check OpenAI API status
  • Review prompt templates for syntax errors

"Could not connect to Telegram" error

  • Regenerate session string with generate_session.py
  • Verify TELEGRAM_API_ID and TELEGRAM_API_HASH

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

About

BriefChief is an intelligent Telegram bot that analyzes your team's chat conversations and automatically identifies task agreements, deadlines, and action items. It seamlessly integrates with Jira to provide context-aware insights powered by AI.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%