claude-home/productivity/n8n/workflows/claude-agent-done.json
Cal Corum 0726d0337b feat: add SubagentStop → Discord notification via n8n (#4)
- Add SubagentStop HTTP hook to .claude/settings.json pointing at n8n
- Add importable n8n workflow (claude-agent-done.json): webhook trigger →
  extract agent name → POST to Discord
- Add setup guide (claude-agent-notifications.md) with payload reference,
  test curl command, and future extension notes
- Update n8n CONTEXT.md and workflows/README.md with new workflow entry

Discord webhook URL is stored as n8n variable DISCORD_CLAUDE_ALERTS_WEBHOOK
to keep it out of local config files.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-09 14:30:43 +00:00

85 lines
2.0 KiB
JSON

{
"name": "Claude Agent Done → Discord",
"nodes": [
{
"parameters": {
"path": "claude-agent-done",
"responseMode": "immediatelyReturnWith200",
"options": {}
},
"id": "webhook-trigger",
"name": "Claude Agent Done",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [0, 0],
"webhookId": "claude-agent-done"
},
{
"parameters": {
"jsCode": "const data = $input.first().json;\nconst sessionId = data.session_id || '';\nconst agentName = data.subagent_name || (sessionId ? sessionId.substring(0, 8) : 'a subagent');\nreturn [{\n json: {\n content: `🏁 Claude agent **${agentName}** has finished.`\n }\n}];"
},
"id": "build-message",
"name": "Build Discord Message",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [220, 0]
},
{
"parameters": {
"method": "POST",
"url": "={{ $vars.DISCORD_CLAUDE_ALERTS_WEBHOOK }}",
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={{ JSON.stringify({ content: $json.content }) }}",
"options": {}
},
"id": "discord-post",
"name": "Post to Discord",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [440, 0]
}
],
"connections": {
"Claude Agent Done": {
"main": [
[
{
"node": "Build Discord Message",
"type": "main",
"index": 0
}
]
]
},
"Build Discord Message": {
"main": [
[
{
"node": "Post to Discord",
"type": "main",
"index": 0
}
]
]
}
},
"settings": {
"executionOrder": "v1"
},
"staticData": null,
"tags": [
{
"name": "claude-code"
},
{
"name": "notifications"
},
{
"name": "discord"
}
],
"triggerCount": 1,
"pinData": {}
}