This project demonstrates an end-to-end integration of Glean Agents with Google Calendar API, showcasing how to build custom actions, agents, and integrate them via a CLI tool.
What this does:
- Takes natural language input from command line (e.g., "Schedule a meeting tomorrow at 2pm")
- Calls Glean Agent API to process the request
- Agent triggers custom Google Calendar action
- Creates actual calendar event in Google Calendar
- Returns confirmation to user
.
βββ README.md # This file
βββ IMPLEMENTATION_GUIDE.md # Detailed step-by-step guide
βββ requirements.txt # Python dependencies
βββ calendar-action-spec.yaml # OpenAPI spec for the custom action
βββ middleware_server.py # Bridge between Glean and Google Calendar
βββ glean_calendar_cli.py # CLI client for invoking the agent
pip install -r requirements.txt- Go to Google Cloud Console
- Create a project and enable Google Calendar API
- Create OAuth 2.0 credentials
- Download credentials as
credentials.json
- Log in to Glean: https://glean-sandbox.cloud.glean.com
- User:
pmmi@glean-sandbox.com
- User:
- Create the custom action (Admin Console > Platform > Actions)
- Create the agent (Admin Console > Platform > Agents)
- Get your API key (Admin Console > Platform > API Keys)
python3 middleware_server.pyThen expose it with ngrok:
ngrok http 5000Edit glean_calendar_cli.py and add your credentials:
GLEAN_API_KEY = "your-api-key"
AGENT_ID = "your-agent-id"Run:
python3 glean_calendar_cli.py "Schedule a team meeting tomorrow at 2pm"For detailed implementation instructions, see IMPLEMENTATION_GUIDE.md
βββββββββββββββββββ
β User Input β
β (CLI Command) β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Glean Agents β
β API β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Glean Agent β
β (NL Processing) β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Custom Action β
β (Middleware) β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Google Calendar β
β API β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β Event Created β β
βββββββββββββββββββ
Defines the interface for the custom action that Glean will call.
Key features:
- Simple, flat parameter structure (no nested objects)
- All fields are primitives (string, number, boolean)
- Required vs. optional fields clearly marked
- ISO 8601 datetime format for dates
Flask server that translates between Glean's simple format and Google Calendar's complex API.
Why middleware?
- Handles format translation
- Manages OAuth tokens
- Provides better error handling
- Easier to debug and log
Python script that invokes the Glean Agent via API and displays results.
Features:
- Command-line argument support
- Interactive mode
- Formatted output
- Error handling
export GLEAN_API_KEY="your-api-key"
export GLEAN_AGENT_ID="your-agent-id"
export GOOGLE_OAUTH_TOKEN="your-google-token"Trigger Conditions:
Creates calendar events in Google Calendar. Use when user wants to:
- Schedule a meeting
- Create a calendar event
- Book time on calendar
- Add an appointment
Example Queries:
- "Schedule a team meeting tomorrow at 2pm"
- "Create a calendar event for project review next Tuesday"
- "Book 30 minutes on my calendar for Friday at 10am"
# Start server
python3 middleware_server.py
# Test health endpoint
curl http://localhost:5000/health# With inline message
python3 glean_calendar_cli.py "Schedule a meeting tomorrow at 2pm"
# Interactive mode
python3 glean_calendar_cli.py- Go to https://calendar.google.com
- Log in with
pmmi@glean-sandbox.com - Check for the created event
$ python3 glean_calendar_cli.py "Create a calendar event called 'Product Demo' tomorrow at 3pm for 45 minutes"
============================================================
π
Glean Calendar Agent CLI
============================================================
π€ Sending request to Glean Agent...
π Message: Create a calendar event called 'Product Demo' tomorrow at 3pm for 45 minutes
β
Agent Response:
I've created the calendar event "Product Demo" for tomorrow at 3:00 PM,
lasting 45 minutes. The event has been added to your calendar successfully.
============================================================"Missing or invalid Authorization header"
- Check your Google OAuth token is valid
- Tokens expire after 1 hour by default
"Agent not found"
- Verify AGENT_ID in CLI script
- Ensure agent is deployed for API access
"Action not triggered"
- Review trigger conditions
- Use more explicit queries like "Create a calendar event..."
"Middleware not reachable"
- Check ngrok is running
- Verify server URL in OpenAPI spec
See IMPLEMENTATION_GUIDE.md for more details.
- Custom Action Creation: Building actions with OpenAPI specs
- Agent Configuration: Setting up agents with proper triggers
- Third-Party Integration: Using Glean Agents API from external code
- OAuth Authentication: Handling Google OAuth flow
- Natural Language Processing: Converting user intent to structured data
- API Design: Creating clean, simple API interfaces
- Add support for recurring events
- Handle event updates and deletions
- Add location and attendees support
- Implement retry logic
- Add comprehensive logging
- Move secrets to environment variables
- Add rate limiting
- Implement error recovery
- Add unit and integration tests
- Deploy middleware to cloud platform
Created for Glean Solutions Architect interview assignment.
Contact: pmmi@glean-sandbox.com
This project is for demonstration purposes as part of the Glean interview process.
Need help? See the detailed IMPLEMENTATION_GUIDE.md or reach out with questions.