3.2 KiB
Configure Webhook
Note
If you want to use webhook, please bind
KVfirst and configure theworkervariableENABLE_WEBHOOK = trueIf you want webhook to have stronger email parsing capabilities, refer to Configure worker to use wasm for email parsing
Prerequisites
You need to set up your own webhook service or use a third-party platform. This service needs to be able to receive POST requests and parse json data.
This project uses songquanpeng/message-pusher as an example webhook service.
- You can use the service provided by msgpusher.com
- You can also self-host the
message-pusherservice, refer to songquanpeng/message-pusher
Admin Configure Global Webhook
Admin Allow Email to Use Webhook
Configure Webhook for a Specific Email
Webhook Template Examples
Telegram Bot Push
Push email notifications by calling the Telegram Bot API directly via webhook. Suitable for scenarios where you don't want to deploy the full Telegram Bot integration or need a custom push format.
- URL:
https://api.telegram.org/bot<YOUR_BOT_TOKEN>/sendMessage - Method:
POST - Headers:
{
"Content-Type": "application/json"
}
- Body:
{
"chat_id": "YOUR_CHAT_ID",
"text": "New Email\nFrom: ${from}\nTo: ${to}\nSubject: ${subject}\nURL: ${url}"
}
Tip
To get your
chat_id: send a message to the Bot, then visithttps://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdatesand look for thechat.idfield in the response
WeChat Work Bot Push
- URL:
https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=YOUR_KEY - Method:
POST - Headers:
{
"Content-Type": "application/json"
}
- Body:
{
"msgtype": "text",
"text": {
"content": "New Email\nFrom: ${from}\nTo: ${to}\nSubject: ${subject}\nURL: ${url}"
}
}
Discord Webhook Push
- URL:
https://discord.com/api/webhooks/YOUR_WEBHOOK_ID/YOUR_WEBHOOK_TOKEN - Method:
POST - Headers:
{
"Content-Type": "application/json"
}
- Body:
{
"content": "**New Email**\nFrom: ${from}\nTo: ${to}\nSubject: ${subject}\nURL: ${url}"
}
Webhook Data Format
To get the url, you need to configure the worker's FRONTEND_URL to your frontend address, or you can construct the url yourself using id = ${FRONTEND_URL}?mail_id=${id}
{
"id": "${id}",
"url": "${url}",
"from": "${from}",
"to": "${to}",
"subject": "${subject}",
"raw": "${raw}",
"parsedText": "${parsedText}",
"parsedHtml": "${parsedHtml}",
"aiExtractType": "${aiExtractType}",
"aiExtractResult": "${aiExtractResult}",
"aiExtractResultText": "${aiExtractResultText}",
}
When AI email extraction is enabled, webhook templates can use the aiExtractType, aiExtractResult, and aiExtractResultText placeholders. They are empty strings when no extraction result is available.


