A Hono-based webhook handler that receives POST requests from Notion and queries the Notion API to retrieve page properties.
Environment Variables: Set your Notion API key and team database ID as environment variables:
NOTION_API_KEY=your_notion_integration_token
EXTRANET_TEAM_DB=your_team_database_id
Notion Integration:
NOTION_API_KEY environment variableHandles incoming Notion webhooks, retrieves page properties, and updates the page icon from a related client page.
Workflow:
Request: Notion webhook payload (JSON) Response:
{ "success": true, "message": "Webhook processed successfully - icon updated from client page", "pageId": "original-page-id", "clientPageId": "client-page-id", "iconType": "external", "updatedPage": { /* updated page object */ } }
Handles incoming Notion webhooks, retrieves page properties, and updates the page title based on the name from a related client page.
Workflow:
Example: If the client page is named "Asdf", the original page title becomes "Asdf team page"
Request: Notion webhook payload (JSON) Response:
{ "success": true, "message": "Webhook processed successfully - title updated from client page", "pageId": "original-page-id", "clientPageId": "client-page-id", "clientName": "Asdf", "newTitle": "Asdf team page", "updatedPage": { /* updated page object */ } }
Handles incoming Notion webhooks and creates an "Inbox" child database on the specified page if one doesn't already exist.
Workflow:
EXTRANET_TEAM_DBDatabase Schema:
EXTRANET_TEAM_DBRequest: Notion webhook payload (JSON) Response (when created):
{ "success": true, "message": "Inbox database created successfully with template page", "pageId": "webhook-page-id", "databaseId": "new-database-id", "templatePageId": "template-page-id", "action": "created", "database": { /* created database object */ }, "templatePage": { /* created template page object */ } }
Response (when already exists):
{ "success": true, "message": "Inbox database already exists", "pageId": "webhook-page-id", "databaseId": "existing-database-id", "action": "skipped" }
Health check endpoint that returns a simple status message.
https://your-val-url.web.val.run/tasks/favicon (for icon updates)https://your-val-url.web.val.run/tasks/name (for title updates)https://your-val-url.web.val.run/tasks/inbox (for inbox database creation)/tasks/favicon: Check for a "Clients" relation property, fetch the first related client page, and copy the client page's icon to the original page/tasks/name: Check for a "Clients" relation property, fetch the first related client page, and update the original page's title to "{client_name} team page"/tasks/inbox: Check for existing "Inbox" databases in page children, and create a new one if none existsThe handler supports all Notion icon types:
The handler gracefully handles various scenarios:
All errors are logged to the console for debugging while maintaining webhook reliability.
The handler looks for the page ID in these locations within the webhook payload:
payload.data.idpayload.id