A webhook handler service that processes events from different sources (GitHub, Trello, etc.) and posts formatted notifications to appropriate Slack channels.
This service is designed to run as an AWS Lambda function that:
- Receives webhook events from various sources (GitHub, Trello)
- Uses OpenAI GPT-4o to generate formatted Slack messages based on event content
- Determines the appropriate Slack channel based on event content
- Posts the formatted message to the selected Slack channel using Block Kit
pasley-assist/
├── agents.mjs # Agent definitions for OpenAI interactions
├── design_docs/ # Project design documentation
│ ├── v1_design.md # Version 1 design specifications
│ └── v2_design.md # Version 2 design specifications
├── index.mjs # Main Lambda handler function
├── logger.mjs # Logging utility
├── openai.mjs # OpenAI API integration
├── package.json # Project dependencies
├── slack-block-kit-docs.md # Slack Block Kit documentation
├── slackRouter.mjs # Slack message routing logic
├── template.yml # SAM template for Lambda deployment
├── test/ # Test event data
│ ├── github.json # Sample GitHub webhook payload
│ └── trello.json # Sample Trello webhook payload
├── trello.mjs # Trello webhook handling and API integration
└── zip_lambda.sh # Script to create a zip package for Lambda deployment
- Clone the repository
- Install dependencies:
npm install
- Copy
env.sample.json
toenv.json
and fill in your API keys and webhook URLs:cp env.sample.json env.json
The following environment variables are required:
OPENAI_API_KEY
: Your OpenAI API keyREDLINE_CHANNEL_WEBHOOK
: Slack webhook URL for the Redline channelLYMPHAPRESS_CHANNEL_WEBHOOK
: Slack webhook URL for the Lymphapress channelBOT_TEST_CHANNEL_WEBHOOK
: Slack webhook URL for testingENVIRONMENT
: Deployment environment (e.g., local, dev, prod)TRELLO_KEY
: Your Trello API keyTRELLO_TOKEN
: Your Trello API tokenTRELLO_BOARD_ID
: ID of the Trello board to monitorTRELLO_CALLBACK_URL
: URL for Trello callbacks (your Lambda URL)TESTING
: When set to "true", all notifications are routed to the BOT_TEST_CHANNEL regardless of content
Run the provided backup script to create a zip file for Lambda deployment:
./zip_lambda.sh
This script creates a timestamped zip file containing all necessary code files while excluding:
node_modules/
directory (Lambda requires dependencies to be included in the zip).git/
directory.env
file (environment variables should be configured in Lambda)- Other unnecessary files
-
Dependencies: Before creating the deployment zip, ensure all dependencies are installed:
npm install
-
Lambda Configuration:
- Runtime: Node.js 22.x or later
- Handler: index.handler
- Memory: 256 MB (minimum recommended)
- Timeout: 30 seconds (adjust based on needs)
- URL Configuration: Enable function URL (for webhook endpoints)
- Response Streaming: Enable (this Lambda uses streamified responses)
-
Environment Variables: Configure all required environment variables in the Lambda console
Deploy to Lambda:
aws lambda update-function-code --function-name "alertSystem" --zip-file "fileb://pasley-assist_lambda_20250505_105222.zip" --region us-east-1 --profile vahelp`
Monitor Lambda logs:
aws logs tail /aws/lambda/alertSystem --profile vahelp --region us-east-1 --follow
REQUIRES AWS SAM CLI INSTALLED
The project includes sample event data in the test/
directory for both GitHub and Trello webhooks.
sam local invoke MyFunction --event test/trello.json --env-vars env.json
sam local invoke MyFunction --event test/github.json --env-vars env.json
For Trello, the service includes functionality to create and manage webhooks for multiple Trello boards. The trello.mjs
file contains functions to:
- Create webhooks for specific Trello boards
- Fetch board information
- Process webhook events from Trello
- Create a feature branch
- Make your changes
- Submit a pull request