# Install dependencies
npm install
# Update environment variables (secrets)
npx supabase secrets set --env-file ./supabase/functions/.env# Deploy a specific function
supabase functions deploy today-channels-summary
supabase functions deploy reminder-cron
supabase functions deploy slash-reminder-mentors
# Deploy all functions
supabase functions deploy# Start Supabase locally
supabase start
# Stop Supabase
supabase stop
# Serve functions locally
supabase functions serve
# Check function logs
supabase functions logs today-channels-summary# Test endpoints locally (examples from main.http)
# Yesterday's text summary
curl "https://ybayntmemramsitrtlem.supabase.co/functions/v1/today-channels-summary"
# Today's text summary in debug mode
curl "https://ybayntmemramsitrtlem.supabase.co/functions/v1/today-channels-summary?forToday=true&debug=true"
# Audio summary (Japanese - default)
curl "https://ybayntmemramsitrtlem.supabase.co/functions/v1/today-channels-summary?type=audio"
# Audio summary (English)
curl "https://ybayntmemramsitrtlem.supabase.co/functions/v1/today-channels-summary?type=audio&lang=en-US"
# Audio summary with debug
curl "https://ybayntmemramsitrtlem.supabase.co/functions/v1/today-channels-summary?forToday=false&debug=true&type=audio&lang=en-US"supabase-function/
├── supabase/
│ ├── config.toml # Supabase configuration
│ └── functions/
│ ├── _shared/ # Shared modules
│ │ ├── cors.ts # CORS headers utility
│ │ ├── mattermost.ts # Mattermost API client
│ │ ├── supabaseAdmin.ts # Supabase admin client
│ │ └── supabaseClient.ts # Supabase client
│ ├── import_map.json # Deno import mappings
│ ├── reminder-cron/ # Reminder cron function
│ │ └── index.ts
│ ├── slash-reminder-mentors/ # Slash command handler
│ │ └── index.ts
│ └── today-channels-summary/ # Daily summary function
│ ├── index.ts
│ └── tsconfig.json
└── main.http # HTTP test requests
- Runtime: Deno (Edge Functions)
- Framework: Supabase Edge Functions
- Language: TypeScript
- External Services:
- Mattermost (team communication)
- OpenAI API (GPT-4 for summaries)
- Google Cloud TTS (audio generation)
- Database: Supabase (PostgreSQL)
Main function that generates daily channel summaries from Mattermost.
Features:
- Fetches public channel posts from previous day (or today)
- Filters channels by activity and restrictions (🈲/🚫 emojis)
- Generates summaries using OpenAI GPT-4
- Supports both text and audio output formats
- Posts summaries back to Mattermost
Query Parameters:
forToday: boolean - Generate today's summary instead of yesterday'stype: "text" | "audio" - Output format (default: "text")debug: boolean - Debug mode (no Mattermost posting)lang: "ja-JP" | "en-US" - Language for audio generation (default: "ja-JP", only used when type="audio")
Key Components:
- Time range calculation (JST timezone handling)
- Channel filtering (excludes notification channels)
- Post aggregation with user mentions and reactions
- OpenAI integration for text summarization
- Audio generation via external API with SSE monitoring
- Multi-language support (Japanese and English) for audio output
- Random voice selection from 30 available TTS voices
Automated reminder system for tracking task completion.
Features:
- Monitors reminders stored in database
- Checks for "done" reactions on Mattermost posts
- Sends reminders at strategic intervals (7, 5, 3, 2, 1 days before deadline)
- Continues daily reminders after deadline until completed
- Mentions specific mentors who haven't completed tasks
Handler for Mattermost slash commands (functionality not visible in provided files).
Mattermost API client providing:
getMentors(): Fetch mentor group membersgetReactions(): Get post reactionspostReply(): Post thread repliescreatePost(): Create new posts
Required environment variables:
MATTERMOST_URL: Mattermost instance URLMATTERMOST_BOT_TOKEN: Bot authentication tokenMATTERMOST_MAIN_TEAM: Team IDMATTERMOST_SUMMARY_CHANNEL: Channel ID for summariesOPENAI_API_KEY: OpenAI API key
- Time Zone Handling: All time calculations properly handle JST timezone conversion
- Privacy Controls: Channels/threads marked with 🈲 or 🚫 are automatically excluded
- Debug Mode: All functions support debug mode for testing without side effects
- Error Handling: Comprehensive error logging and graceful failure handling
- Caching: User name caching to minimize API calls
- Modular Architecture: Shared utilities in
_shared/directory
- JWT verification is disabled for
today-channels-summaryfunction (see config.toml) - Functions use Deno's native modules and ESM imports
- TypeScript configured with strict mode for type safety
- Edge Runtime configured with "oneshot" policy for hot reload during development