This Slack Bot integrates Google Gemini's AI technology into Slack, offering a smart, responsive assistant that enhances productivity. Follow these steps to set up and deploy your bot.
For a detailed step-by-step guide on building this digital assistant, visit Building a Digital Assistant in Slack with Google Gemini: A Step-by-Step Guide.
- Google Gemini API Key
- Slack App with OAuth & Permissions configured
- Python environment with necessary libraries
Before running the project, you need to set up your environment variables. A sample environment file .env.sample
is provided in the project. Copy this file to a new file named .env
and update the variables with your own values.
The .env.sample
file contains the following structure:
GOOGLE_API_KEY=your_google_api_key_here
SLACK_BOT_TOKEN=your_slack_bot_token_here
BOT_USER_ID=your_bot_user_id_here
FLASK_APP=your_entry_point_script_here # e.g., "app.py"
- Copy the
.env.sample
file to a new file named.env
in the root directory of the project. - Replace
your_google_api_key_here
,your_slack_bot_token_here
,your_bot_user_id_here
, andyour_entry_point_script_here
with your actual configuration values.
Note: Never commit your .env
file or any sensitive credentials to version control. The .env
file is included in the .gitignore
to prevent accidental upload.
- Obtain Google Gemini API Key: Visit Google AI Studio and generate an API key for the Gemini API.
- Generate Slack App: Create a new app in Slack and configure basic information, including OAuth scopes required for the bot to function.
- Setup Event Subscriptions: Subscribe to bot events in your Slack app settings to listen for and respond to messages.
- Install Your App: Add your app to your workspace with the necessary permissions.
- Development Environment:
- Use Visual Studio Code or your preferred IDE.
- Create a Python virtual environment and activate it.
- Install necessary Python libraries including Flask, Slack SDK, and Google Gemini libraries.
- Implement Your Slack Bot: Use Flask for handling Slack events and Google Gemini for generating responses.
- Deploy Your Application: Choose between local testing with ngrok or deploying to Google Cloud App Engine for production.
- Configure Slack Event Subscriptions: Update your Slack app's event subscriptions with your deployment's request URL.
- Access Your Slack Bot: Test your bot via direct message or by mentioning it in a channel.
Ensure your project has all the necessary dependencies by installing the required libraries which include Flask, various Google and Slack SDKs, and other utility libraries.
Flask
google-ai-generativelanguage
google-api-core
google-auth
google-generativeai
googleapis-common-protos
gunicorn
requests
slack_sdk
colorama
python-dotenv
To install the required dependencies for this project, follow the steps below:
Run the following command to install the dependencies listed in requirements.txt
:
pip install -r requirements.txt
Detailed steps for deploying with ngrok for local testing and Google Cloud App Engine for production, including setting environment variables and configuring app.yaml for GCP. (refer the resource section)
Invite contributions by providing guidelines for submitting pull requests to your project.
This project is licensed under the MIT License - see the LICENSE file for details.