# How to include a field value in message body of EMAIL action in Rules and Connectors?

**URL:** https://discuss.elastic.co/t/how-to-include-a-field-value-in-message-body-of-email-action-in-rules-and-connectors/314209
**Category:** Kibana
**Tags:** elastic-stack-alerting
**Created:** [September 12, 2022, 5:11pm UTC](https://discuss.elastic.co/t/how-to-include-a-field-value-in-message-body-of-email-action-in-rules-and-connectors/314209 "2022-09-12T17:11:56Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![subash](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/subash/32/59912_2.png) [@subash](https://discuss.elastic.co/u/subash)
#### Post date: [September 12, 2022, 5:11pm UTC](https://discuss.elastic.co/t/how-to-include-a-field-value-in-message-body-of-email-action-in-rules-and-connectors/314209/1 "2022-09-12T17:11:57Z")

</div>

I want to include only specific fields in the message body of email action. When using the {{context.hits}} it is returning the whole document. But I want to include only specific fields from the document.

Thanks in advance

---

<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: [October 4, 2022, 1:38pm UTC](https://discuss.elastic.co/t/how-to-include-a-field-value-in-message-body-of-email-action-in-rules-and-connectors/314209/2 "2022-10-04T13:38:10Z")

</div>

I can give you an example:

Let's say in the input part of your watcher you've got that kind of selection:

```auto

  "input": {
{
   "Application": {
     "simple": {
       "name" : "TEST"
      }
   }
}

```

Then in your email body you can just refer to it as {{ctx.payload.Application.name}}

If what you get is a list of elements, let's say a list of name and phone number like this:  
testlist.name  
testlist.phone

and you want to dispatch all the values, you need to use the following sentences:

{{#ctx.payload.testlist.hits.hits}}{{#\_source}}{{name}}{{/\_source}}{{/ctx.payload.testlist.hits.hits}}

or you can expand:  
{{#ctx.payload.testlist.hits.hits}}{{#\_source}} whatever you want {{phone}} and other things like this{{name}} and that's it{{/\_source}}{{/ctx.payload.testlist.hits.hits}}

---

<div class="post-metadata">

### Author: ![subash](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/subash/32/59912_2.png) [@subash](https://discuss.elastic.co/u/subash)
#### Post date: [October 4, 2022, 1:44pm UTC](https://discuss.elastic.co/t/how-to-include-a-field-value-in-message-body-of-email-action-in-rules-and-connectors/314209/3 "2022-10-04T13:44:56Z")

</div>

Thank you John 🙂

---

<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: [November 1, 2022, 1:45pm UTC](https://discuss.elastic.co/t/how-to-include-a-field-value-in-message-body-of-email-action-in-rules-and-connectors/314209/4 "2022-11-01T13:45:48Z")

</div>

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