Assurance watcher (csv only) - Working

PHOTO EMBED

Mon Oct 11 2021 14:00:49 GMT+0000 (UTC)

Saved by @Amoro

{
  "trigger": {
    "schedule": {
      "weekly": [
        {
          "on": [
            "SUN",
            "MON",
            "TUE",
            "WED",
            "THU",
            "FRI",
            "SAT"
          ],
          "at": [
            "16:00"
          ]
        }
      ]
    }
  },
  "input": {
    "search": {
      "request": {
        "search_type": "query_then_fetch",
        "indices": [
          "leads"
        ],
        "rest_total_hits_as_int": true
      },
      "extract": [
        "isSoldLead : true"
      ]
    }
  },
  "condition": {
    "always": {}
  },
  "actions": {
    "email_admin": {
      "email": {
        "profile": "standard",
        "attachments": {
          "Assurance_Lead_Report.csv": {
            "reporting": {
              "url": "https://f86c263cfafb4998b8f4c51edcb5521f.us-east-1.aws.found.io:9243/api/reporting/generate/csv_searchsource?jobParams=%28browserTimezone%3AUS%2FEastern%2Ccolumns%3A%21%28created%2CmpVendorCampaignName%2Cregion%2CpostalCode%2Cincome%2Cage%2Cgender%2CvendorSource%2CvendorSubID%2CleadResult%2CbuyerPrice%2CcrmLastResultcode%2CleadID%29%2CobjectType%3Asearch%2CsearchSource%3A%28fields%3A%21%28%28field%3A%27%2A%27%2Cinclude_unmapped%3Atrue%29%29%2Cfilter%3A%21%28%28meta%3A%28index%3Adf8f3cd0-c48d-11e9-8998-95877d221b7b%2Cparams%3A%28%29%29%2Crange%3A%28created%3A%28format%3Astrict_date_optional_time%2Cgte%3A%272021-10-07T00%3A18%3A54.349Z%27%2Clte%3A%272021-10-08T00%3A18%3A54.349Z%27%29%29%29%29%2Cindex%3Adf8f3cd0-c48d-11e9-8998-95877d221b7b%2Cparent%3A%28filter%3A%21%28%28%27%24state%27%3A%28store%3AappState%29%2Cmeta%3A%28alias%3A%21n%2Cdisabled%3A%21f%2Cindex%3Adf8f3cd0-c48d-11e9-8998-95877d221b7b%2Ckey%3AvendorID.keyword%2Cnegate%3A%21f%2Cparams%3A%28query%3Aassurance%29%2Ctype%3Aphrase%29%2Cquery%3A%28match_phrase%3A%28vendorID.keyword%3Aassurance%29%29%29%2C%28%27%24state%27%3A%28store%3AappState%29%2Cmeta%3A%28alias%3A%21n%2Cdisabled%3A%21f%2Cindex%3Adf8f3cd0-c48d-11e9-8998-95877d221b7b%2Ckey%3Acompany.keyword%2Cnegate%3A%21f%2Cparams%3A%28query%3Ausha_george%29%2Ctype%3Aphrase%29%2Cquery%3A%28match_phrase%3A%28company.keyword%3Ausha_george%29%29%29%2C%28%27%24state%27%3A%28store%3AappState%29%2Cmeta%3A%28alias%3A%21n%2Cdisabled%3A%21f%2Cfield%3AleadResult%2Cindex%3Adf8f3cd0-c48d-11e9-8998-95877d221b7b%2Ckey%3AleadResult%2Cnegate%3A%21f%2Cparams%3A%28query%3AAccepted%29%2Ctype%3Aphrase%29%2Cscript%3A%28script%3A%28lang%3Apainless%2Cparams%3A%28value%3AAccepted%29%2Csource%3A%27boolean%20compare%28Supplier%20s%2C%20def%20v%29%20%7Breturn%20s.get%28%29%20%3D%3D%20v%3B%7Dcompare%28%28%29%20-%3E%20%7B%20if%20%28doc%5B%21%27passDNC%21%27%5D.size%28%29%20%3E%200%29%20%7B%20if%20%28doc%5B%21%27passDNC%21%27%5D.value%20%3D%3D%20false%29%20%7B%20return%20%21%27Blacklisted%21%27%20%7D%20%7D%20%0A%0Aif%20%28doc%5B%21%27emailOnly%21%27%5D.length%20%3E%200%29%20%7B%20if%20%28doc%5B%21%27emailOnly%21%27%5D.value%20%3D%3D%20%21%27true%21%27%29%20%7B%20return%20%21%27Disconnected%21%27%20%7D%20%7D%20%0A%0Aif%20%28doc%5B%21%27isDuplicate%21%27%5D.length%20%3E%200%29%20%7B%20if%20%28doc%5B%21%27isDuplicate%21%27%5D.value%20%3D%3D%20%21%27true%21%27%29%20%7B%20return%20%21%27Duplicate%21%27%20%7D%20%7D%20%0A%0Aif%20%28doc%5B%21%27passQuality%21%27%5D.size%28%29%20%3E%200%29%20%7B%20if%20%28doc%5B%21%27passQuality%21%27%5D.value%20%3D%3D%20false%29%20%7B%20return%20%21%27Filtered%21%27%20%7D%20%7D%20%0A%0Areturn%20%21%27Accepted%21%27%0A%20%7D%2C%20params.value%29%3B%27%29%29%29%29%2Cindex%3Adf8f3cd0-c48d-11e9-8998-95877d221b7b%2Cquery%3A%28language%3Akuery%2Cquery%3A%27%27%29%29%2Csort%3A%21%28%28created%3Adesc%29%29%2CtrackTotalHits%3A%21t%2Cversion%3A%21t%29%2Ctitle%3A%27usha_george-Assurance%20_Report%27%29",
              "retries": 40,
              "interval": "15s",
              "auth": {
                "basic": {
                  "username": "austin@sonicwebdev.com",
                  "password": "::es_redacted::"
                }
              }
            }
          }
        },
        "to": [
          "austin@sonicwebdev.com",
          "braxton@sonicwebdev.com",
          "cngo@assurance.com",
          "sneumiller@assurance.com"
        ],
        "subject": "Assurance Lead Report",
        "body": {
          "html": "Good afternoon! Open the attached CSV to see the lead results from yesterday, have a good rest of the day. <br><br> As a reference, here are the most favorable result codes: <br><br> <b>HOT LEADS:</b><br>SOLD <br>APPT <br>Callback <br><b>WARM LEADS:</b> <br>Retry 1Hr <br>Retry_1Hr <br>Retry 2Hrs <br>Retry_2Hrs <br>Retry 3Hrs <br>Retry_3Hrs <br>Retry 4Hrs <br>Retry_4Hrs"
        }
      }
    }
  }
}
content_copyCOPY