← Autosys

Clients/Autosys/Shared Calendar System.md

manual
Source
4
Chunks
13
Entities
Doc
Type

Content

# Shared Calendar System **Deployed:** 2026-03-09 **Status:** Live and operational **Plan Document:** ~/Desktop/autosys-shared-calendar-plan.html ## Overview Shared scheduling system for Mason and Kevin, integrated into AutoBot (Slack bot) and backed by a Microsoft 365 shared mailbox calendar. Events are created three ways: smart detection (passive monitoring of Slack conversations), direct schedule commands (DM to AutoBot), and automatic task due date syncing from the vault task tracker. The calendar is visible in Outlook (web, desktop, mobile) for both users with full color-coded categories. ## Architecture ``` Slack channels ──► AutoBot (slack_bot.py) ──► Microsoft Graph API ──► Outlook │ │ │ │ smart detection │ schedule commands │ shared mailbox │ (passive NLP) │ confirmation flow │ schedule@autosysnet.com │ │ │ └── channel context │ task due date sync ◄── vault PostgreSQL (site mapping) │ (hourly) │ ├── morning briefing (7 AM DM) └── EOD check-in (4:30 PM DM) ``` ## Microsoft 365 Setup ### Shared Mailbox - **Email:** schedule@autosysnet.com - **Type:** Exchange Online shared mailbox (free, no license) - **Members:** Mason Radke, Kevin Seifert (full access + send as) - **Calendar name:** Calendar (default, displayed as "Schedule" in Outlook) ### Azure AD App Registration - **App name:** Autosys AutoBot - **Client ID:** 5eb0402b-0966-471c-bc60-f4b580385f06 - **Tenant ID:** 64e25c85-4504-46ed-bf26-07b275bce1db - **Client secret:** Stored at `/opt/vault/config/ms365_app.env` (expires March 2028) - **Auth type:** Application (client_credentials grant, no user login required) - **Token endpoint:** `https://login.microsoftonline.com/64e25c85-4504-46ed-bf26-07b275bce1db/oauth2/v2.0/token` - **Scope:** `https://graph.microsoft.com/.default` ### API Permissions (Application, admin-consented) | Permission | Purpose | |---|---| | Calendars.ReadWrite | Create, read, update, delete calendar events | | User.Read.All | Look up user profiles and display names | | Directory.Read.All | Enumerate tenant users and groups | | Files.Read.All | Read OneDrive storage (used for tenant audit) | | MailboxSettings.Read | Read mailbox configuration | ### Calendar Permissions | User | Role | |---|---| | mason@autosysnet.com | Write | | kevin@autosysnet.com | Write | | Default (everyone) | Free/Busy read | ## Deployed Files All files on datavault (100.113.209.23 / 89.167.102.34): | File | Size | Purpose | |---|---|---| | `/opt/vault/scripts/calendar_module.py` | ~11 KB | Graph API calendar client — OAuth2 auth with token caching, auto-creates calendar on shared mailbox, CRUD operations, category tagging, event listing | | `/opt/vault/scripts/smart_detection.py` | ~12 KB | NLP scheduling detection — site directory (20+ sites), scheduling/anti-pattern regex, confidence scoring, time range parsing, event extraction | | `/opt/vault/scripts/slack_bot.py` | ~39 KB | AutoBot main entry point — extended with calendar integration, smart detection, confirmation flow, daily automations, task sync | | `/opt/vault/config/ms365_app.env` | 0.3 KB | Azure AD app credentials (permissions 600, vault:vault) | | `/opt/vault/config/calendar_id.txt` | ~0.1 KB | Cached calendar ID (auto-generated on first run) | ### Service - **systemd unit:** vault-slack-bot.service (enabled, auto-restart) - **Process:** `/opt/vault/.venv/bin/python /opt/vault/scripts/slack_bot.py` - **Logs:** `/opt/vault/logs/slack_bot.log` ## Features ### 1. Smart Detection (Passive Monitoring) AutoBot monitors all Slack channels for scheduling language and DMs the user to confirm — never posting in the original channel. **How it works:** 1. Every channel message from Mason or Kevin is scored for scheduling intent 2. Pattern matching checks three signals: site name, time expression, scheduling keywords 3. Anti-patterns filter out past tense, questions, hypotheticals 4. Channel context provides the client/site when not mentioned explicitly (e.g., posting in #buellton implies Buellton) 5. If confidence >= 0.6, the bot DMs the user with a proposed event 6. User confirms (yes/thumbs up), modifies (e.g., "make it 8-12"), or dismisses (no/skip/etc.) **Scheduling patterns detected:** - Site visits: "heading to," "going to," "onsite," "I'll be at," "I will be at," "swing by," "coming out," "showing up," "stopping by," "I'll be here/there" - Availability: "out of town," "remote," "wfh," "offline," "unavailable," "day off," "pto" - Appointments: "dentist," "doctor," "vet," "meeting," "call," "appointment" **Anti-patterns (ignored):** - Past tense: "was at," "went to," "already handled," "last week," "yesterday" - Hypothetical: "should probably," "sometime," "maybe we" - Questions: "are you at...?", "what's the IP for...?", messages ending with "?" **Channel context mapping:** Messages in client-specific channels (e.g., #buellton, #laguna, #ccsd-water-ignition) automatically inherit the client name from `/opt/vault/config/slack_channels.yaml`, even when the message doesn't mention the site by name. ### 2. Schedule Commands DM AutoBot with any of these: | Command | Example | |---|---| | `schedule <event>` | `schedule tomorrow Laguna sludge pump work` | | `schedule <time range>` | `schedule friday 8am-12pm Buellton PLC maintenance` | | `schedule remote <dates>` | `schedule remote next week` | | `schedule off <date>` | `schedule off tuesday` | | `schedule list` | Show this week's events | | `schedule today` | Show today's events | | `schedule sync` | Force task due date sync now | The `/schedule` slash command handler is also in the code but requires registration in the Slack app (api.slack.com → Slash Commands → add `/schedule`). ### 3. Task Due Date Sync Automatically pulls incomplete tasks with due dates from the vault task tracker (Slack Lists API) and creates all-day "Due: ..." events on the shared calendar. - **Frequency:** Every hour (automatic), or on-demand via `schedule sync` - **Scope:** Tasks due within the next 30 days - **Cleanup:** Completed or rescheduled tasks are automatically removed from the calendar - **Category:** "Task Due" (Red) ### 4. Daily Automations | Time | Automation | Description | |---|---|---| | 7:00 AM PT | Morning briefing | DMs both users with today's calendar events and tasks due today | | 4:30 PM PT | EOD check-in | DMs both users asking if anything needs to be added for tomorrow | ### 5. Event Confirmation Flow When smart detection triggers or a schedule command is used: 1. Bot proposes the event with subject, date, and time 2. User can respond: - **Confirm:** "yes," "y," "sure," "ok," thumbs-up reaction - **Modify:** provide a time range (e.g., "make it 8-12") — auto-confirms after modification - **Dismiss:** "no thanks," "nah," "skip," "cancel," "pass," "not now" 3. On confirmation, the other user (Mason or Kevin) gets a notification DM 4. Pending confirmations expire after 5 minutes ## Color-Coded Categories | Color | Category | Used For | |---|---|---| | Red | Task Due | Auto-synced task due dates | | Dark Red | Unavailable | Off / OOO / PTO | | Blue | Site Visit | On-site client work | | Green | Remote | Working remotely | | Purple | Personal | Dentist, doctor, vet, etc. | | Teal | Meeting | Calls, meetings, syncs | Categories are configured on all three accounts (schedule@, mason@, kevin@) so colors display correctly regardless of which account is viewing. ## Event Subject Formats | Type | Format | Example | |---|---|---| | Site visit | `On Site: {location} — {description}` | On Site: City of Buellton — PLC maintenance | | Remote | `{name} — Remote (available)` | Mason — Remote (available) | | Unavailable | `{name} — Off / Unavailable` | Kevin — Off / Unavailable | | Personal | `{name} — Personal ({detail})` | Mason — Personal (dentist) | | Meeting | `{name} — Meeting` | Kevin — Meeting | | Task due | `Due: {task name} [{client}]` | Due: SCADA Server Replacement [SSLOCSD] | ## Site Directory Smart detection recognizes these site names (including hyphenated variants like "south-county"): | Short Name | Display Name | |---|---| | laguna | Laguna County Sanitation | | buellton | City of Buellton | | solvang | City of Solvang | | ccsd, carpinteria | CCSD | | sslocsd, south county | SSLOCSD | | nino, nino well | Nino Well | | amwc | AMWC | | tough | Tough | | syrwcd | SYRWCD | | rancho ynecita | Rancho Ynecita | | topaz, topaz solar | Topaz Solar | | arroyo grande | Arroyo Grande | | country club | Laguna Country Club | | paso | Paso Robles | | culligan | Culligan | | ocsd | OCSD | | sycsd | SYCSD | | waterworx | Waterworx | | tsi | TSI | | 3 corners, three corners | 3 Corners Ranch | ## Changes Made ### Slack Bot (slack_bot.py) - Added calendar module and smart detection imports with graceful fallback - Added `schedule` intent detection in `classify_intent()` - Added `/schedule` command handler and `handle_schedule_command()` - Added smart detection in `on_message()` for non-DM, non-mention channel messages - Added channel-to-client context mapping from `slack_channels.yaml` - Added pending event confirmation flow (in-memory dict with 5-minute timeout) - Added thumbs-up reaction handler for event confirmation - Added background scheduler thread (morning briefing, EOD check-in, task sync) - Added `sync_task_due_dates()` for automatic task-to-calendar sync - Updated help text to include calendar commands - Flexible negative response matching (startsWith instead of exact match) ### New Files - `calendar_module.py` — Microsoft Graph API calendar client - `smart_detection.py` — NLP-based scheduling event detection ### Microsoft 365 Tenant - Registered Azure AD app "Autosys AutoBot" with 5 application permissions - Created shared mailbox `schedule@autosysnet.com` (Exchange admin center) - Added Mason and Kevin as shared mailbox members - Set calendar sharing permissions (write) for both users - Created 6 color-coded Outlook categories on all 3 accounts ## Dependencies No new Python packages were added. The calendar module uses `requests` (already installed) for Graph API calls with raw OAuth2 token requests — no `msal` dependency. Existing packages used: `requests`, `dateparser`, `rapidfuzz`, `slack_bolt`, `yaml`, `psycopg`, `dotenv`. ## Future Improvements - Register `/schedule` slash command in Slack app - Add Ollama LLM fallback for borderline confidence cases - Add dismissal learning (track ignored prompts to lower sensitivity per pattern) - Convert accounting@ and email@ to shared mailboxes to free 2 E1 seats (~$16/mo) - Investigate whether kseifert@autosys.co duplicate account is needed

Extracted Entities

TypeKeyValueConfidenceEvidence
contact Shared Mailbox Email schedule@autosysnet.com 100% **Email:** schedule@autosysnet.com
contact User Emails with Calendar Write Access {mason@autosysnet.com,kevin@autosysnet.com} 100% | mason@autosysnet.com | Write | | kevin@autosysnet.com | Write |
contact Shared Mailbox Members Mason Radke, Kevin Seifert 100% **Members:** Mason Radke, Kevin Seifert (full access + send as)
credential Azure AD App Client ID 5eb0402b-0966-471c-bc60-f4b580385f06 100% **Client ID:** 5eb0402b-0966-471c-bc60-f4b580385f06
credential Azure AD App Tenant ID 64e25c85-4504-46ed-bf26-07b275bce1db 100% **Tenant ID:** 64e25c85-4504-46ed-bf26-07b275bce1db
credential Azure AD App Client Secret Location /opt/vault/config/ms365_app.env 90% **Client secret:** Stored at `/opt/vault/config/ms365_app.env`
server Datavault IP Addresses {100.113.209.23,89.167.102.34} 100% All files on datavault (100.113.209.23 / 89.167.102.34)
server Microsoft OAuth2 Token Endpoint https://login.microsoftonline.com/64e25c85-4504-46ed-bf26-07b275bce1db/oauth2/v2.0/token 100% **Token endpoint:** `https://login.microsoftonline.com/64e25c85-4504-46ed-bf26-07b275bce1db/oauth2/v2.0/token`
server Slack Bot Process /opt/vault/.venv/bin/python /opt/vault/scripts/slack_bot.py 100% **Process:** `/opt/vault/.venv/bin/python /opt/vault/scripts/slack_bot.py`
site Site Directory {"Laguna County Sanitation","City of Buellton","City of Solvang",CCSD,SSLOCSD,"Nino Well",AMWC,Tough,SYRWCD,"Rancho Ynecita","Topaz Solar","Arroyo Grande","Laguna Country Club","Paso Robles",Culligan,OCSD,SYCSD,Waterworx,TSI,"3 Corners Ranch"} 100% Smart detection recognizes these site names (including hyphenated variants like "south-county")
system Microsoft 365 Exchange Online Exchange Online shared mailbox 100% Exchange Online shared mailbox (free, no license)
system System Name AutoBot 100% integrated into AutoBot (Slack bot) and backed by a Microsoft 365 shared mailbox calendar
task Daily Automations {"7:00 AM PT - Morning briefing DMs today's events and tasks","4:30 PM PT - EOD check-in DMs users for next day additions"} 100% | 7:00 AM PT | Morning briefing | DMs both users with today's calendar events and tasks due today |
File: Clients/Autosys/Shared Calendar System.md
Updated: 2026-03-09 23:26:27.923385