# Watcher with external html template

**URL:** <https://discuss.elastic.co/t/watcher-with-external-html-template/168056>\
**Category:** Kibana\
**Created:** [February 12, 2019, 2:59pm UTC](https://discuss.elastic.co/t/watcher-with-external-html-template/168056 "2019-02-12T14:59:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gidmark](https://avatars.discourse-cdn.com/v4/letter/g/f19dbf/32.png) [@Gidmark](https://discuss.elastic.co/u/Gidmark)\
**Post date:** [February 12, 2019, 2:59pm UTC](https://discuss.elastic.co/t/watcher-with-external-html-template/168056/1 "2019-02-12T14:59:28Z")

</div>

I have a fairly basic question. I have a watcher, I load a html template using a http input. I want to use this template (which contains mustache syntax) in my action. Is it possible? At the moment I just get the html without the mustache functionality applied. Using Elasticsearch 5.6.

This is how the email action looks like below. My idea was that the params option would enable me to use {{#hits}}... in my external template but it didn't work.

```
"body": {
      "html": {
        "source": "{{ctx.payload.template._value}}",
        "lang": "mustache",
        "params": {
          "hits": "{{ctx.payload.query.hits.hits}}"
        }
      }
    }

```

But yea, feels like a step missing 🙂

---

<div class="post-metadata">

**Author:** ![jen-huang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jen-huang/32/74327_2.png) [@jen-huang](https://discuss.elastic.co/u/jen-huang)\
**Post date:** [February 12, 2019, 6:02pm UTC](https://discuss.elastic.co/t/watcher-with-external-html-template/168056/2 "2019-02-12T18:02:12Z")

</div>

Hi, I'm not sure if this is possible, since the mustache values will have to "unfold" twice. `params` isn't a valid option for email actions. Have you tried just doing:

```auto
"body": {
      "html": "{{ctx.payload.template._value}}"
    }
}

```

and make sure that the external template `ctx.payload.template._value` has mustache in it? For example, maybe the value of the external template is:

```auto
Hits over {{ctx.payload.query.hits.hits}}

```

I'm not certain this will work, since it still has to compile mustache twice. But worth a shot.

---

<div class="post-metadata">

**Author:** ![Gidmark](https://avatars.discourse-cdn.com/v4/letter/g/f19dbf/32.png) [@Gidmark](https://discuss.elastic.co/u/Gidmark)\
**Post date:** [February 13, 2019, 6:18am UTC](https://discuss.elastic.co/t/watcher-with-external-html-template/168056/3 "2019-02-13T06:18:21Z")

</div>

Yea that's what i tried the first time and the reason i tried the source and param thing. Sadly didn't work.

---

<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:** [March 13, 2019, 6:18am UTC](https://discuss.elastic.co/t/watcher-with-external-html-template/168056/4 "2019-03-13T06:18:22Z")

</div>

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