# Send Email Alerts to Different Recipients Based on Condition

**URL:** https://discuss.elastic.co/t/send-email-alerts-to-different-recipients-based-on-condition/164341
**Category:** Elasticsearch
**Tags:** elastic-stack-alerting
**Created:** [January 15, 2019, 4:21pm UTC](https://discuss.elastic.co/t/send-email-alerts-to-different-recipients-based-on-condition/164341 "2019-01-15T16:21:42Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![stevenmarrocco](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@stevenmarrocco](https://discuss.elastic.co/u/stevenmarrocco)
#### Post date: [January 15, 2019, 4:21pm UTC](https://discuss.elastic.co/t/send-email-alerts-to-different-recipients-based-on-condition/164341/1 "2019-01-15T16:21:42Z")

</div>

I’m wondering if it is possible to send an watcher event to a specific individual depending on a certain attribute/condition.

For example, if condition A is met from a watcher send alert to individual A. If conditon B is met send alert to individual B but not to A

---

<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: [January 18, 2019, 10:47am UTC](https://discuss.elastic.co/t/send-email-alerts-to-different-recipients-based-on-condition/164341/2 "2019-01-18T10:47:05Z")

</div>

Hey,

two ways to solve this:

First, you can use conditions within actions, so one easy way to build this, is just to add two email actions, each with a condition. Each condition contains a different recipient. This would however mean, that you have to copy the JSON that creates the email into both of these actions.

Alternatively you could also just put the recipient in a variable (i.e. with a script transform) and then use `"to": "{{recipient_variable}}"` in your single email action.

Hoep this helps.

--Alex

---

<div class="post-metadata">

### Author: ![stevenmarrocco](https://avatars.discourse-cdn.com/v4/letter/s/9d8465/32.png) [@stevenmarrocco](https://discuss.elastic.co/u/stevenmarrocco)
#### Post date: [January 18, 2019, 1:10pm UTC](https://discuss.elastic.co/t/send-email-alerts-to-different-recipients-based-on-condition/164341/3 "2019-01-18T13:10:16Z")

</div>

Hey Alex,

Appreciate the feedback! I wasn't able to find any conditions within action examples, so I started to think this wasn't possible. For the second way, I'm assuming the condition would update the variable?

I'll see if I can make it happen.

thanks!

---

<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: [January 18, 2019, 1:22pm UTC](https://discuss.elastic.co/t/send-email-alerts-to-different-recipients-based-on-condition/164341/4 "2019-01-18T13:22:47Z")

</div>

indeed. you can set own variables within the condition like `ctx.foo = 'bar'` or have an own `condition` section within the action.

--Alex

---

<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: [February 15, 2019, 1:26pm UTC](https://discuss.elastic.co/t/send-email-alerts-to-different-recipients-based-on-condition/164341/5 "2019-02-15T13:26:40Z")

</div>

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