discord_bot/IGDB_SETUP.md

124 lines
3.9 KiB
Markdown

# IGDB Integration Setup Guide
The bot now supports real-time video game information through IGDB (Internet Game Database) API integration. This allows the AI to provide accurate, up-to-date information about games when users ask gaming-related questions.
## Features
- **Game Search**: Find games by name with fuzzy matching
- **Game Details**: Get comprehensive information including ratings, platforms, developers, genres, and summaries
- **AI Integration**: Seamless function calling - the AI automatically decides when to fetch game information
- **Smart Formatting**: Game data is formatted in a user-friendly way for the AI to present
## Setup Instructions
### 1. Get IGDB API Credentials
1. Go to [Twitch Developer Console](https://dev.twitch.tv/console)
2. Create a new application:
- **Name**: Your bot name (e.g., "Fjerkroa Discord Bot")
- **OAuth Redirect URLs**: `http://localhost` (not used but required)
- **Category**: Select appropriate category
3. Note down your **Client ID**
4. Generate a **Client Secret**
5. Get an access token using this curl command:
```bash
curl -X POST 'https://id.twitch.tv/oauth2/token' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'client_id=YOUR_CLIENT_ID&client_secret=YOUR_CLIENT_SECRET&grant_type=client_credentials'
```
6. Save the `access_token` from the response
### 2. Configure the Bot
Update your `config.toml` file:
```toml
# IGDB Configuration for game information
igdb-client-id = "your_actual_client_id_here"
igdb-access-token = "your_actual_access_token_here"
enable-game-info = true
```
### 3. Update System Prompt (Optional)
The system prompt has been updated to inform the AI about its gaming capabilities:
```toml
system = "You are a smart AI assistant with access to real-time video game information through IGDB. When users ask about games, game recommendations, release dates, platforms, or any gaming-related questions, you can search for accurate and up-to-date information."
```
## Usage Examples
Once configured, users can ask gaming questions naturally:
- "Tell me about Elden Ring"
- "What are some good RPG games released in 2023?"
- "Is Cyberpunk 2077 available on PlayStation?"
- "Who developed The Witcher 3?"
- "What's the rating of Baldur's Gate 3?"
The AI will automatically:
1. Detect gaming-related queries
2. Call IGDB API functions to get real data
3. Format and present the information naturally
## Technical Details
### Available Functions
The integration provides two OpenAI functions:
1. **search_games**
- Parameters: `query` (string), `limit` (optional integer, max 10)
- Returns: List of games matching the query
2. **get_game_details**
- Parameters: `game_id` (integer from search results)
- Returns: Detailed information about a specific game
### Game Information Included
- **Basic Info**: Name, summary, rating (critic and user)
- **Release Info**: Release date/year
- **Technical**: Platforms, developers, publishers
- **Classification**: Genres, themes, game modes
- **Extended** (detailed view): Storyline, similar games, screenshots
### Error Handling
- Graceful degradation if IGDB is unavailable
- Fallback to regular AI responses if API fails
- Proper error logging for debugging
## Troubleshooting
### Common Issues
1. **"IGDB integration disabled"** in logs
- Check that `enable-game-info = true`
- Verify client ID and access token are set
2. **Authentication errors**
- Regenerate access token (they expire)
- Verify client ID matches your Twitch app
3. **No game results**
- IGDB may not have the game in their database
- Try alternative spellings or official game names
### Rate Limits
- IGDB allows 4 requests per second
- The integration includes automatic retry logic
- Large queries are automatically limited to prevent timeouts
## Disabling IGDB
To disable IGDB integration:
```toml
enable-game-info = false
```
The bot will continue working normally without game information features.