{
  "name": "Valkiria: daily spend digest to Slack",
  "flow": [
    {
      "id": 1,
      "module": "http:ActionSendData",
      "version": 3,
      "parameters": { "handleErrors": true, "useNewZLibDeCompress": true },
      "mapper": {
        "url": "https://valkiria.pro/api/v1/analytics/spend",
        "method": "get",
        "headers": [{ "name": "Authorization", "value": "Bearer vk_live_REPLACE_WITH_YOUR_KEY" }],
        "qs": [{ "name": "period", "value": "7d" }, { "name": "group_by", "value": "day" }],
        "bodyType": "",
        "parseResponse": true,
        "timeout": "",
        "shareCookies": false,
        "rejectUnauthorized": true,
        "followRedirect": true,
        "useQuerystring": false,
        "gzip": true,
        "useMtls": false,
        "followAllRedirects": false
      },
      "metadata": { "designer": { "x": 0, "y": 0, "name": "Valkiria spend, 7 days" } }
    },
    {
      "id": 2,
      "module": "http:ActionSendData",
      "version": 3,
      "parameters": { "handleErrors": true, "useNewZLibDeCompress": true },
      "filter": { "name": "Got a response", "conditions": [[{ "a": "{{1.statusCode}}", "b": "200", "o": "number:equal" }]] },
      "mapper": {
        "url": "https://hooks.slack.com/services/REPLACE/WITH/YOUR_WEBHOOK",
        "method": "post",
        "headers": [],
        "qs": [],
        "bodyType": "raw",
        "contentType": "application/json",
        "data": "{\"text\": \"Ad spend, last 7 days: {{ifempty(1.data.totalSpend; \"several currencies, see byCurrency\")}} {{1.data.currency}}. Latest day {{substring(last(map(1.data.timeline; \"period_start\")); 0; 10)}}: {{last(map(1.data.timeline; \"spend\"))}} {{1.data.currency}}.\"}",
        "parseResponse": false,
        "timeout": "",
        "shareCookies": false,
        "rejectUnauthorized": true,
        "followRedirect": true,
        "useQuerystring": false,
        "gzip": true,
        "useMtls": false,
        "followAllRedirects": false
      },
      "metadata": { "designer": { "x": 300, "y": 0, "name": "Post to Slack" } }
    }
  ],
  "metadata": {
    "instant": false,
    "version": 1,
    "scenario": { "roundtrips": 1, "maxErrors": 3, "autoCommit": true, "autoCommitTriggerLast": true, "sequential": false, "confidential": false, "dataloss": false, "dlq": false, "freshVariables": false },
    "designer": { "orphans": [] },
    "zone": "eu1.make.com"
  }
}
