{
  "schema": "mailguard-integration-template/v1",
  "platform": "make",
  "title": "Weekly DMARC digest → Microsoft Teams",
  "description": "Every Monday at 8 a.m., pull the previous week's DMARC pass-rate per domain and post a digest to your Teams channel.",
  "author": "MailGuard team",
  "license": "MIT",
  "documentation_url": "https://themailguard.ai/integrations/make-dmarc-digest-to-teams",
  "mailguard_api_version": "v1",
  "scenario": {
    "name": "MailGuard — Weekly DMARC Digest",
    "scheduling": {
      "type": "indefinitely",
      "interval": "weekly",
      "day_of_week": "monday",
      "time": "08:00"
    },
    "modules": [
      {
        "id": 1,
        "module": "schedule",
        "label": "Every Monday at 08:00",
        "config": {
          "type": "weekly",
          "day": "monday",
          "time": "08:00"
        }
      },
      {
        "id": 2,
        "module": "http:ActionSendData",
        "label": "GET /v1/dmarc-reports — last 7 days",
        "config": {
          "url": "https://api.themailguard.ai/v1/dmarc-reports",
          "method": "GET",
          "qs": [
            { "name": "window_days", "value": "7" },
            { "name": "limit", "value": "100" }
          ],
          "headers": [
            {
              "name": "Authorization",
              "value": "Bearer {{MAILGUARD_API_KEY}}"
            }
          ],
          "parseResponse": true
        }
      },
      {
        "id": 3,
        "module": "builtin:BasicAggregator",
        "label": "Aggregate per-domain pass-rate",
        "config": {
          "feeder": 2,
          "fields": ["domain.name", "metrics.pass_rate"]
        }
      },
      {
        "id": 4,
        "module": "tools:setVariable",
        "label": "Build Markdown table",
        "config": {
          "name": "digest_body",
          "value": "**MailGuard — DMARC pass-rate, last 7 days**\n\n| Domain | Pass-rate | Trend |\n| --- | --- | --- |\n{{rows}}"
        }
      },
      {
        "id": 5,
        "module": "microsoft-teams:CreateMessageAdaptiveCard",
        "label": "Post Adaptive Card to Teams",
        "config": {
          "team": "{{TEAMS_TEAM_ID}}",
          "channel": "{{TEAMS_CHANNEL_ID}}",
          "card": {
            "type": "AdaptiveCard",
            "version": "1.4",
            "body": [
              {
                "type": "TextBlock",
                "text": "{{digest_body}}",
                "wrap": true,
                "size": "Default"
              }
            ]
          }
        }
      }
    ]
  },
  "setup_steps": [
    "Create a MailGuard API key at Settings → API Keys with the dmarc-reports:read scope.",
    "In Make, create a new scenario and import this JSON via Add Module → Import.",
    "Open the HTTP module and replace {{MAILGUARD_API_KEY}} with your real API key (use a Make connection variable, do not paste it inline in the URL).",
    "Open the Microsoft Teams module and choose the team / channel where the digest should post.",
    "Save and run once to confirm the message lands.",
    "Activate the scenario."
  ]
}
