# Email body - Mustache template with conditions

**URL:** <https://discuss.elastic.co/t/email-body-mustache-template-with-conditions/130215>\
**Category:** Elasticsearch\
**Created:** [May 2, 2018, 9:35am UTC](https://discuss.elastic.co/t/email-body-mustache-template-with-conditions/130215 "2018-05-02T09:35:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hamza\_BENNANI](https://avatars.discourse-cdn.com/v4/letter/h/bc8723/32.png) [@Hamza\_BENNANI](https://discuss.elastic.co/u/Hamza_BENNANI)\
**Post date:** [May 2, 2018, 9:35am UTC](https://discuss.elastic.co/t/email-body-mustache-template-with-conditions/130215/1 "2018-05-02T09:35:25Z")

</div>

I need to adapt the content of my watcher email based on a variable. In other words, I need to do a 'IF ELSE" statement in the email template. Is-it possible ?

The definition of the watcher :

> {  
> ...  
> "trigger": {  
> "schedule": {  
> "interval": "1m"  
> }  
> },  
> "input": {  
> ...  
> },  
> "transform": {  
> "script": {  
> "lang": "groovy",  
> "stored": "my\_stored\_script"  
> }  
> },  
> "actions": {  
> "notify": {  
> "condition": {  
> "compare": {  
> "ctx.payload.notify": {  
> "eq": true  
> }  
> }  
> },  
> "email": {  
> "profile": "outlook",  
> "account": "exchange\_account",  
> "to": "{{ctx.payload.destinataire}}",  
> "subject": "Subject",  
> "body": {  
> "html": "{{#ctx.payload.endOfProblem}}End of problem{{/ctx.payload.endOfProblem}} {{#ctx.payload.newProblem}}New problem has been detected{{/ctx.payload.newProblem}}"  
> },  
> "priority": "high"  
> }  
> }  
> }  
> }

Version of Elasticsearch : 5.1.2

---

<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:** [May 30, 2018, 9:35am UTC](https://discuss.elastic.co/t/email-body-mustache-template-with-conditions/130215/2 "2018-05-30T09:35:29Z")

</div>

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