Advanced Watcher: Use key value in a mail webhook

Hello everybody!

So, basically I'm trying to get my 'key' value to print it into my mail body, but I'm not being able to do it. Once I get it, I will iterate over the buckets with a "foreach" before the webhook (within the "action" data).

This is the path (it works until I reach the key): {{ctx.payload.aggregations.service.buckets.key}}

I also used this way: {{ctx.payload.aggregations.service.buckets[0].key}}

And this is the "result" output (data is dynamic):

"result": {
    "execution_time": "2022-03-11T13:25:33.552Z",
    "execution_duration": 17,
    "input": {
      "type": "search",
      "status": "success",
      "payload": {
        "_shards": {
          "total": 30,
          "failed": 0,
          "successful": 30,
          "skipped": 28
        },
        "hits": {
          "hits": [],
          "total": 83,
          "max_score": null
        },
        "took": 14,
        "timed_out": false,
        "aggregations": {
          "service": {
            "doc_count_error_upper_bound": 0,
            "sum_other_doc_count": 0,
            "buckets": [
              {
                "doc_count": 50,
                "operation": {
                  "doc_count_error_upper_bound": 0,
                  "sum_other_doc_count": 0,
                  "buckets": [
                    {
                      "doc_count": 42,
                      "key": "createDocument"
                    },
                    {
                      "doc_count": 6,
                      "key": "createInvoiceDocument"
                    },
                    {
                      "doc_count": 2,
                      "key": "createClaimNotificationDocument"
                    }
                  ]
                },
                "key": "ClaimAPIPortType"
              },
              {
                "doc_count": 11,
                "operation": {
                  "doc_count_error_upper_bound": 0,
                  "sum_other_doc_count": 0,
                  "buckets": [
                    {
                      "doc_count": 4,
                      "key": "manageRoles"
                    },
                    {
                      "doc_count": 3,
                      "key": "getRolesToObject"
                    },
                    {
                      "doc_count": 2,
                      "key": "getInfoToParty"
                    },
                    {
                      "doc_count": 2,
                      "key": "manageAccounts"
                    }
                  ]
                },
                "key": "PartyInterface-v4_0"
              },
              {
                "doc_count": 7,
                "operation": {
                  "doc_count_error_upper_bound": 0,
                  "sum_other_doc_count": 0,
                  "buckets": [
                    {
                      "doc_count": 7,
                      "key": "updatePaymentStatus"
                    }
                  ]
                },
                "key": "SumexPaymentUpdateService"
              },
              {
                "doc_count": 6,
                "operation": {
                  "doc_count_error_upper_bound": 0,
                  "sum_other_doc_count": 0,
                  "buckets": [
                    {
                      "doc_count": 6,
                      "key": "invoiceDetails"
                    }
                  ]
                },
                "key": "InvoiceDetails"
              },
              {
                "doc_count": 6,
                "operation": {
                  "doc_count_error_upper_bound": 0,
                  "sum_other_doc_count": 0,
                  "buckets": [
                    {
                      "doc_count": 6,
                      "key": "geocode"
                    }
                  ]
                },
                "key": "MapsInterface-v1_0"
              },
              {
                "doc_count": 1,
                "operation": {
                  "doc_count_error_upper_bound": 0,
                  "sum_other_doc_count": 0,
                  "buckets": [
                    {
                      "doc_count": 1,
                      "key": "sendChat"
                    }
                  ]
                },
                "key": "AIDInterface-v1_0"
              },
              {
                "doc_count": 1,
                "operation": {
                  "doc_count_error_upper_bound": 0,
                  "sum_other_doc_count": 0,
                  "buckets": [
                    {
                      "doc_count": 1,
                      "key": "statusUpdate"
                    }
                  ]
                },
                "key": "ClaimPaymentService"
              },
              {
                "doc_count": 1,
                "operation": {
                  "doc_count_error_upper_bound": 0,
                  "sum_other_doc_count": 0,
                  "buckets": [
                    {
                      "doc_count": 1,
                      "key": "preview"
                    }
                  ]
                },
                "key": "CommunicationService-v1_0"
              }
            ]
          }
        }
      },

Could you please give a hand with this?

Thank you! :smiley:

The problem was solved by applying a segment as follows:
{{#ctx.your_segment_here}} {{key}} {{/ctx.your_segment_here}}

Awesome work finding it @Jonathan_Fernandez !

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.