# Send mustach tag in Weebhook call without having it interpreted?

**URL:** <https://discuss.elastic.co/t/send-mustach-tag-in-weebhook-call-without-having-it-interpreted/320165>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting, painless\
**Created:** [November 30, 2022, 2:29pm UTC](https://discuss.elastic.co/t/send-mustach-tag-in-weebhook-call-without-having-it-interpreted/320165 "2022-11-30T14:29:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JohnJ\_M](https://avatars.discourse-cdn.com/v4/letter/j/a88e4f/32.png) [@JohnJ\_M](https://discuss.elastic.co/u/JohnJ_M)\
**Post date:** [November 30, 2022, 2:29pm UTC](https://discuss.elastic.co/t/send-mustach-tag-in-weebhook-call-without-having-it-interpreted/320165/1 "2022-11-30T14:29:56Z")

</div>

Hi the community,

I am looking a way to send via webhook mustach tab (like {{ctx.payload.total\_assets.hits.total}} that should not be interpreted.

The reason:  
The main watcher create new watchers using the webhook. The new created watchers will have to perform their own search and send mail with resultats of the research. I am blocked since I need in the webhook payload to have mustach tag that needs to be interpreted (to create the new watcher) and some that should not be interpred since they will be use by the new watcher itself. Can't find a way so far to do it.

Exemple of code of main watcher:

```auto
{
  "trigger": {
    "schedule": {
      "interval": "1h"
    }
  },
  "input": {
    "chain": {
      "inputs": [
        {
          "deployments_list" : {
            "search" : {
              "request": {
                "search_type": "query_then_fetch",
                "indices" : [
                  "scopetest"
                ],
                "rest_total_hits_as_int": true,
                "body": {
                  "size": 1000,
                  "query": {
                    "bool": {
                      "must": [],
                      "filter": [
                        {
                          "match_phrase": {
                            "type": "Generic"
                          }
                        }
                      ],
                      "should": [],
                      "must_not": []
                    }
                  }
                }
              }
            }
          }
        },
        {
          "deployment_watchers": {
            "search": {
              "request": {
                "search_type": "query_then_fetch",
                "indices": [
                  ".watches"
                ],
                "rest_total_hits_as_int": true,
                "body": {
                  "size": 1000,
                  "query": {
                    "match": {
                      "metadata.type.keyword": "test-deployment-watcher"
                    }
                  },
                  "_source": "metadata"
                }
              }
            }
          }
        }
      ]
    }
  },
  "condition": {
    "always": {}
  },
  "actions": {
    "create-action": {
      "condition": {
        "script": {
          "source": "return !ctx.payload.to_be_created.isEmpty();",
          "lang": "painless"
        }
      },
      "foreach": "ctx.payload.to_be_created",
      "max_iterations": 60,
      "webhook": {
        "scheme": "https",
        "host": "xxxx",
        "port": xxx,
        "method": "put",
        "path": "_watcher/watch/{{ctx.payload._source.watchername}}",
        "body": """{"trigger": {"schedule": {"weekly" : { ""at" : "{{ctx.payload._source.scheduletime}}"}}},"input": {"chain": {"inputs": [{"Total_Assets": {"search":{"request": {"search_type": "query_then_fetch","indices": ["team_report_assets"],"rest_total_hits_as_int": true,"body": {"query": {"bool": {"filter": [{"match_phrase": {"Scope": "Team"}},{"range": {"DateScan": {"gte": "now-6d/d","lte": "now/d","format": "strict_date_optional_time"}}}]}}}}}}}]}},"condition": {"always": {}},"actions": {"email_1": {"email": {"profile": "standard","to": ["{{ctx.payload._source.emailto}}"],"subject": "[Test] Weekly Test Audit","body": {"html": "total number of asset per team: {{ctx.payload.Total_Assets"}}}}}"""
      }
    }
  },
  "transform": {
   ...
  }
}

```

The result expected is

```auto
{
	"trigger": {
		"schedule": {
			"weekly" : { 
				"on" : "{{ctx.payload._source.scheduleday}}",
				"at" : "{{ctx.payload._source.scheduletime}}"
			}
		}
	},
	"input": {
		"chain": {
			"inputs": [
				{
					"Total_Assets": {
						"search": {
							"request": {
								"search_type": "query_then_fetch",
								"indices": ["team_report_assets"],
								"rest_total_hits_as_int": true,
								"body": {
									"query": {
										"bool": {
											"filter": [
												{
													"match_phrase": {"Scope": "Team"}
												},
												{
													"range": {
														"DateScan": {
															"gte": "now-6d/d",
															"lte": "now/d",
															"format": "strict_date_optional_time"
														}
													}
												}
											]
										}
									}
								}
							}
						}
					}
				}
			]
		}
	},
	"condition": {"always": {}},
	"actions": {
		"email_1": {"
			email": {
				"profile": "standard",
				"to": ["{{ctx.payload._source.emailto}}"],
				"subject": "[Test] Weekly Test Audit",
				"body": {"html": "total number of asset per team: {{ctx.payload.Total_Assets"}}}
			}
		}
	}
}

```

but the Body of the created watcher is in fact  
"body": {"html": "total number of asset per team: }  
which is logical since {{ctx.payload.Total\_Assets"}} is interpreted during the execution of the main watcher.

---

<div class="post-metadata">

**Author:** ![JohnJ\_M](https://avatars.discourse-cdn.com/v4/letter/j/a88e4f/32.png) [@JohnJ\_M](https://discuss.elastic.co/u/JohnJ_M)\
**Post date:** [December 14, 2022, 9:34am UTC](https://discuss.elastic.co/t/send-mustach-tag-in-weebhook-call-without-having-it-interpreted/320165/2 "2022-12-14T09:34:31Z")

</div>

A friend find me the answer.  
For those who might be interested it's in the chapter "delimiter" here: [mustache(5) - Logic-less templates.](https://mustache.github.io/mustache.5.html)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 11, 2023, 9:35am UTC](https://discuss.elastic.co/t/send-mustach-tag-in-weebhook-call-without-having-it-interpreted/320165/3 "2023-01-11T09:35:33Z")

</div>

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