Webhook
配置 Webhook
yaml
automation:
webhook:
enabled: true
port: 8080
path: /api/webhook
secret: ${WEBHOOK_SECRET}
cors:
enabled: true
origins:
- https://example.com接收消息
javascript
// Express.js 示例
app.post('/api/webhook', async (req, res) => {
const { message, channel } = req.body;
// 处理消息
await moltbot.send({
to: channel,
message: `收到: ${message}`
});
res.send('OK');
});事件类型
| 事件 | 说明 |
|---|---|
message.received | 收到新消息 |
message.sent | 消息已发送 |
task.completed | 任务完成 |
task.failed | 任务失败 |
error | 发生错误 |
安全
- 使用 HTTPS
- 验证请求签名
- 限制 IP 访问