Skip to content

Coden-inja/Slack-scheduler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Local AI Scheduler Bot πŸ€–πŸ“…

Watch demo - Video

A privacy-focused scheduling agent that runs 100% locally on your machine.

Most AI tools send your chat logs to the cloud (OpenAI, Anthropic, etc.). This bot uses Ollama to run the AI model (Llama 3.2) on your own laptop. It listens to Slack via Socket Mode (no port forwarding needed) and updates your Google Calendar via a simple Apps Script.

The Logic: Slack (Chat) ➑️ Python (Local AI Analysis) ➑️ Google Apps Script (Calendar API)


Prerequisites

Before running the code, you need these installed on your machine:

  1. Python 3.10+
  2. Ollama (to run the AI model)
  3. A Google Account (for Calendar)
  4. A Slack Workspace (where you have admin rights to add apps)

Step 1: Set up "The Brain" (Ollama)

We use the Llama 3.2 model because it's lightweight (3B parameters) and runs fast even on laptops with 8GB RAM.

  1. Download Ollama from ollama.com.
  2. Open your terminal/command prompt.
  3. Run this command to download and start the model:
    ollama run llama3.2
    (Note: If your laptop is very old, try ollama run llama3.2:1b for a faster, smaller version.)
  4. Type "Hello" to check if it's working. If it replies, close the terminal.

Step 2: Set up "The Hands" (Google Calendar)

We use Google Apps Script so we don't have to deal with complex Google Cloud OAuth setups.

  1. Go to script.google.com.
  2. Click New Project.
  3. Open the file apps_script_backend.js from this repo, copy the code, and paste it into the editor (replace the default function).
  4. Deploy it:
    • Click the blue Deploy button > New deployment.
    • Select type: Web app.
    • Description: "Scheduler Backend".
    • Execute as: Me (your email).
    • Who has access: Anyone (Important: This allows the Python script to talk to it).
  5. Click Deploy.
  6. Copy the Web App URL (It ends with /exec). You will need this later.

Step 3: Set up "The Ears" (Slack App)

We use Socket Mode so you don't need ngrok or public IPs.

  1. Go to api.slack.com/apps and click Create New App > From Scratch. Name it "SchedulerBot".
  2. Enable Socket Mode:
    • Click Socket Mode in the sidebar.
    • Toggle it ON.
    • Create an App-Level Token. Name it sock_token.
    • Copy the xapp-... token.
  3. Add Permissions:
    • Click OAuth & Permissions.
    • Scroll to Bot Token Scopes and add these three:
      • app_mentions:read
      • chat:write
      • reactions:write
    • Scroll up and click Install to Workspace.
    • Copy the xoxb-... token.
  4. Enable Events:
    • Click Event Subscriptions in the sidebar.
    • Toggle it ON.
    • Open "Subscribe to bot events" and add app_mention.
    • Click Save Changes.

Step 4: Configure the Python Agent

  1. Clone this repo or download the agent.py file.
  2. Install the required libraries:
    pip install slack_sdk ollama requests
  3. Open agent.py in a text editor (VS Code, Notepad, etc.).
  4. Fill in your keys at the top of the file:
    SLACK_APP_TOKEN = "xapp-..."  # From Step 3
    SLACK_BOT_TOKEN = "xoxb-..."  # From Step 3
    APPS_SCRIPT_URL = "https://..." # From Step 2

Step 5: Run It

  1. Open your terminal.
  2. Navigate to the folder containing the script.
  3. Run the agent:
    python agent.py
  4. You should see: πŸ”΄ Agent is Online...

How to use: Go to your Slack workspace, invite the bot to a channel (/invite @SchedulerBot), and say:

"@SchedulerBot Schedule a meeting with Dave tomorrow at 10am"

The bot will react with πŸ‘€, think for a few seconds, and then confirm the booking.


Troubleshooting

  • Bot doesn't reply? Check if ollama is running in the background.
  • "Error connecting to Calendar"? Check if your Apps Script URL is correct and deployed as "Anyone".
  • Hallucinating dates? Small models (3B) sometimes struggle with math. If it gets the date wrong, try being more specific (e.g., "next Friday") or check the prompt logic in agent.py.

License

Free to use. Built for learning purposes.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published