{
  "name": "orboto: daily agent digest",
  "nodes": [
    {
      "id": "fd77cae9-b792-4cb9-8a04-07102cb05859",
      "name": "Every Day at 18:00",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.4,
      "position": [
        -260,
        0
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "days",
              "daysInterval": 1,
              "triggerAtHour": 18,
              "triggerAtMinute": 0
            }
          ]
        }
      }
    },
    {
      "id": "46492a54-8d6d-45cd-a237-061a7c59ff41",
      "name": "Query Tickets Agents Touched",
      "type": "n8n-nodes-orboto.orboto",
      "typeVersion": 1,
      "position": [
        -40,
        0
      ],
      "parameters": {
        "resource": "ticket",
        "operation": "query",
        "authType": "apiKey",
        "syntax": "oql",
        "oql": "<__PLACEHOLDER_VALUE__OQL for the digest. Default: updated >= -1d AND assignee IS NOT EMPTY__>",
        "returnAll": false,
        "limit": 50
      }
    },
    {
      "id": "b7070904-e996-43f0-ba02-9e62a9c65286",
      "name": "Format Digest",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        180,
        0
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "const tickets = $input.all().map(item => item.json).filter(t => t && (t.ticketKey || t.key || t.id));\nconst lines = tickets.map(t => \"- \" + (t.ticketKey || t.key || t.id) + \": \" + t.title + \" [\" + (t.statusName || t.statusCategory || \"unknown\") + \"]\");\nconst header = tickets.length === 0\n  ? \"Agent digest: nothing moved in the last day.\"\n  : \"Agent digest: \" + tickets.length + \" ticket(s) moved in the last day.\";\nreturn [{ json: { count: tickets.length, message: [header].concat(lines).join(\"\\n\") } }];"
      }
    },
    {
      "id": "b724ad4e-8101-4dfe-bd4e-9145e323324c",
      "name": "Post Digest to Discord",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.5,
      "position": [
        400,
        -80
      ],
      "parameters": {
        "method": "POST",
        "url": "<__PLACEHOLDER_VALUE__Discord webhook URL - Channel settings, Integrations, Webhooks__>",
        "sendBody": true,
        "contentType": "json",
        "specifyBody": "keypair",
        "bodyParameters": {
          "parameters": [
            {
              "name": "content",
              "value": "={{ $json.message }}"
            }
          ]
        }
      },
      "onError": "continueRegularOutput"
    },
    {
      "id": "8ea871ce-1065-4f04-9ae5-11576425ad14",
      "name": "Post Digest to Slack",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.5,
      "position": [
        400,
        100
      ],
      "parameters": {
        "method": "POST",
        "url": "<__PLACEHOLDER_VALUE__Slack incoming webhook URL - Slack app settings, Incoming Webhooks__>",
        "sendBody": true,
        "contentType": "json",
        "specifyBody": "keypair",
        "bodyParameters": {
          "parameters": [
            {
              "name": "text",
              "value": "={{ $json.message }}"
            }
          ]
        }
      },
      "onError": "continueRegularOutput"
    },
    {
      "id": "958d965a-8e61-4abe-9728-b962c9293b28",
      "name": "Sticky Note Daily Digest",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        100,
        300
      ],
      "parameters": {
        "content": "## Daily agent digest\n\nOne message a day listing what moved. Fill the OQL placeholder on \"Query Tickets Agents Touched\" and the two webhook URLs. On a day with no matches the query returns nothing and the run stops here - no empty message is sent.",
        "color": 4
      }
    }
  ],
  "connections": {
    "Every Day at 18:00": {
      "main": [
        [
          {
            "node": "Query Tickets Agents Touched",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Query Tickets Agents Touched": {
      "main": [
        [
          {
            "node": "Format Digest",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Digest": {
      "main": [
        [
          {
            "node": "Post Digest to Discord",
            "type": "main",
            "index": 0
          },
          {
            "node": "Post Digest to Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {}
}
