# I want use scrpit in email action, but the param not working

**URL:** <https://discuss.elastic.co/t/i-want-use-scrpit-in-email-action-but-the-param-not-working/125888>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [March 28, 2018, 8:25am UTC](https://discuss.elastic.co/t/i-want-use-scrpit-in-email-action-but-the-param-not-working/125888 "2018-03-28T08:25:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Feng\_Mi](https://avatars.discourse-cdn.com/v4/letter/f/54ee81/32.png) [@Feng\_Mi](https://discuss.elastic.co/u/Feng_Mi)\
**Post date:** [March 28, 2018, 8:25am UTC](https://discuss.elastic.co/t/i-want-use-scrpit-in-email-action-but-the-param-not-working/125888/1 "2018-03-28T08:25:59Z")

</div>

> {  
> "actions" : {  
> "email\_notification" : {  
> "email" : {  
> "subject" : {  
> "inline" : "{{color}} alert",  
> "params" : {  
> "color" : "red"  
> }  
> }  
> }  
> }  
> }  
> }

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [March 28, 2018, 11:52am UTC](https://discuss.elastic.co/t/i-want-use-scrpit-in-email-action-but-the-param-not-working/125888/2 "2018-03-28T11:52:38Z")

</div>

Hey,

I'm sorry, but just pasting a snippet without any context whatsoever will not get you any help.

Please supply the full watch, the output of the execute watch API, a full description what you are trying to achieve and what you think is not working as expected.

Please take a moment to read our [help guidelines](https://www.elastic.co/help)

Thanks.

--Alex

---

<div class="post-metadata">

**Author:** ![Feng\_Mi](https://avatars.discourse-cdn.com/v4/letter/f/54ee81/32.png) [@Feng\_Mi](https://discuss.elastic.co/u/Feng_Mi)\
**Post date:** [March 28, 2018, 12:08pm UTC](https://discuss.elastic.co/t/i-want-use-scrpit-in-email-action-but-the-param-not-working/125888/3 "2018-03-28T12:08:41Z")

</div>

```
{
  "trigger": {
    "schedule": {
      "interval": "60m"
    }
  },
  "input": {
    "chain": {
      "inputs": [
        {
          "today": {
            "search": {
              "request": {
                "search_type": "query_then_fetch",
                "indices": [
                  "newstart-ad_info-cookingjoy-*"
                ],
                "types": [],
                "body": {
                  "size": 0,
                  "query": {
                    "range": {
                      "json._serverDate": {
                        "gte": "now-60m/m",
                        "lt": "now/m"
                      }
                    }
                  }
                }
              }
            }
          }
        },
        {
          "yesterday": {
            "search": {
              "request": {
                "search_type": "query_then_fetch",
                "indices": [
                  "newstart-ad_info-cookingjoy-*"
                ],
                "types": [],
                "body": {
                  "size": 0,
                  "query": {
                    "range": {
                      "json._serverDate": {
                        "gte": "now-1500m/m",
                        "lt": "now-1440m/m"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      ]
    }
  },
  "condition": {
    "script": {
      "source": "return (ctx.payload.yesterday.hits.total > 0 && (ctx.payload.today.hits.total*100.00 / (ctx.payload.yesterday.hits.total*100.00) < 0.8 || ctx.payload.today.hits.total*100.00 / (ctx.payload.yesterday.hits.total*100.00) > 1.5))",
      "lang": "painless"
    }
  },
  "actions": {
    "email_admin": {
      "email": {
        "profile": "standard",
        "attachments": {
          "yesterday_log_count-today_log_count": {
            "data": {
              "format": "json"
            }
          }
        },
        "priority": "high",
        "to": [
          "feng.mi@zenjoy.net",
          "yue.liu@zenjoy.net"
        ],
        "subject":{
            "inline":"{{color}} cookingjoyad_infoalarm! current ratio is less than 0.8 or over 1.5",
            "params" : {
            "color" : "red"
            }
        },
        "body": {
          "text": "current ({{ctx.trigger.scheduled_time}}) 60min ad_info value {{ctx.payload.today.hits.total}} \nYesterday 60min ad_info value {{ctx.payload.yesterday.hits.total}}, ratio is less than 0.8 or over 1.5"
        }
      }
    }
  }
}

* List item
```

---

<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:** [April 25, 2018, 12:08pm UTC](https://discuss.elastic.co/t/i-want-use-scrpit-in-email-action-but-the-param-not-working/125888/4 "2018-04-25T12:08:48Z")

</div>

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