# Custom webhook for microsoft teams

**URL:** <https://forum.opensearch.org/t/custom-webhook-for-microsoft-teams/2346>\
**Category:** Alerting\
**Created:** [March 5, 2020, 12:26am UTC](https://forum.opensearch.org/t/custom-webhook-for-microsoft-teams/2346 "2020-03-05T00:26:10Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![moonsyim](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@moonsyim](https://forum.opensearch.org/u/moonsyim)\
**Post date:** [March 5, 2020, 12:26am UTC](https://forum.opensearch.org/t/custom-webhook-for-microsoft-teams/2346/1 "2020-03-05T00:26:11Z")

</div>

Hello  
I’m doing Opendisto alert integration with Microsoft teams through custom webhook.  
How to create destination

1. specified full teams webhook URL in ‘Define endpoint by URL’  
 → then alert doesn’t work
2. specify below items in ‘Define endpoint by custom attributes URL’ such as  
type : HTTPS  
Port 443  
Path webhook/0ea528-blablabla…  
Parameter : no parameter  
Header : contents-Type application/json  
 → it still doesn’t work  
so wondering how to specify all custom attributes to make work with teams webhook

teams webhook itself is working by curl command  
such as curl -H “Content-Type: application/json” -d “{"text": "Hello World"}” [https://outlook.office.com/webhook/0ea528-blablabla](https://outlook.office.com/webhook/0ea528-blablabla)…  
Then I can see “Hello World” in teams channel.

Would you please share your experience on it?

Thank you.

---

<div class="post-metadata">

**Author:** ![ejohns81](https://avatars.discourse-cdn.com/v4/letter/e/c67d28/32.png) [@ejohns81](https://forum.opensearch.org/u/ejohns81)\
**Post date:** [March 5, 2020, 6:07pm UTC](https://forum.opensearch.org/t/custom-webhook-for-microsoft-teams/2346/2 "2020-03-05T18:07:39Z")

</div>

you need format the message to match the what teams expects in the “actions” section of the trigger. For example flowdock requires the `"event": "message"` and `"content":"your text here"` values in it’s API request:

```auto
{ "event": "message" , "content": "{{ctx.monitor.name}} has detected an error 
- Trigger: {{ctx.trigger.name}}
- Severity: {{ctx.trigger.severity}}
- Period start: {{ctx.periodStart}}
- Alert URL: url" }

```

it looks like teams expects “text” so try

```auto
{"text": "your alert here"}

```

---

<div class="post-metadata">

**Author:** ![moonsyim](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@moonsyim](https://forum.opensearch.org/u/moonsyim)\
**Post date:** [March 5, 2020, 6:22pm UTC](https://forum.opensearch.org/t/custom-webhook-for-microsoft-teams/2346/3 "2020-03-05T18:22:35Z")

</div>

Hello ejohns81, thanks a lot for response.  
But wondering how to configure all your suggestions in OpenDistro Destination page.  
for example  
event, content, Trigger, Severity,… text should be parameterized in ‘Add parameter’ ?

 ![opendistro_destination](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/1X/3d80884da0e27bb791804144014932a7ea5df123.jpeg)

---

<div class="post-metadata">

**Author:** ![dmmutch](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@dmmutch](https://forum.opensearch.org/u/dmmutch)\
**Post date:** [March 6, 2020, 11:21am UTC](https://forum.opensearch.org/t/custom-webhook-for-microsoft-teams/2346/4 "2020-03-06T11:21:44Z")

</div>

![image](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/1X/5112ca0ffc38b23aebe3b4348b235c1f060bb158.png)

Just put it in the ‘message’ field, under ‘Edit trigger’ → ‘Configure actions’

---

<div class="post-metadata">

**Author:** ![moonsyim](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@moonsyim](https://forum.opensearch.org/u/moonsyim)\
**Post date:** [March 6, 2020, 5:00pm UTC](https://forum.opensearch.org/t/custom-webhook-for-microsoft-teams/2346/5 "2020-03-06T17:00:43Z")

</div>

Hello dmmutch  
Thanks a lot for your response.  
What you’re saying is ‘how to configure actions in Alert’ with Destination (Errors - webhook)  
What I need to know is ‘how to configure Destination with Microsoft team webhook’  
Screen capture that I upload is for that.

---

<div class="post-metadata">

**Author:** ![dbbaughe](https://avatars.discourse-cdn.com/v4/letter/d/bbe5ce/32.png) [@dbbaughe](https://forum.opensearch.org/u/dbbaughe)\
**Post date:** [March 7, 2020, 12:58am UTC](https://forum.opensearch.org/t/custom-webhook-for-microsoft-teams/2346/6 "2020-03-07T00:58:57Z")

</div>

Hi @moonsyim,

You have a destination pointing to your Microsoft team webhook.  
This webhook expects your message to be formatted a certain way otherwise it’ll reject it.  
To do the formatting of the body POSTed to the webhook, you need to modify the action message as dmmutch has pointed out.

So after you create your destination. Head over to your monitor → trigger → alert and you can use dmmutch example above.

---

<div class="post-metadata">

**Author:** ![moonsyim](https://avatars.discourse-cdn.com/v4/letter/m/848f3c/32.png) [@moonsyim](https://forum.opensearch.org/u/moonsyim)\
**Post date:** [March 7, 2020, 1:14am UTC](https://forum.opensearch.org/t/custom-webhook-for-microsoft-teams/2346/7 "2020-03-07T01:14:02Z")

</div>

Hello dbbaughe  
Thanks a lot for your suggestion.

Yes, my microsoft webhook get alert from curl commands such as  
curl -H “Content-Type: application/json” -d “{“text”: “Hello World”}” [https://outlook.office.com/webhook/0ea528-blablabla…](https://outlook.office.com/webhook/0ea528-blablabla%E2%80%A6)

so my question is how to configure OpenDistro destination just like above curl command.  
OpenDistro configuration screen capture is

 ![opendistro_destination](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/1X/3d80884da0e27bb791804144014932a7ea5df123.jpeg)

---

<div class="post-metadata">

**Author:** ![dbbaughe](https://avatars.discourse-cdn.com/v4/letter/d/bbe5ce/32.png) [@dbbaughe](https://forum.opensearch.org/u/dbbaughe)\
**Post date:** [March 7, 2020, 1:21am UTC](https://forum.opensearch.org/t/custom-webhook-for-microsoft-teams/2346/8 "2020-03-07T01:21:46Z")

</div>

If you take a look at your curl example you have:

- Headers
- URL
- Data

The headers and URL go into the destination which is the image you posted.

The data goes into Alerting → Monitors → Triggers → Action → Message.  
You can reference dmmutch’s image to see what that place looks like.

---

<div class="post-metadata">

**Author:** ![ags](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.opensearch.org/ags/32/553_2.png) [@ags](https://forum.opensearch.org/u/ags)\
**Post date:** [March 23, 2020, 10:55am UTC](https://forum.opensearch.org/t/custom-webhook-for-microsoft-teams/2346/9 "2020-03-23T10:55:12Z")

</div>

you must set message template like:

> {  
> “_text_”: "  
> Monitor {{ctx.monitor.name}} just entered alert status. Please investigate the issue.  
> - Trigger: {{ctx.trigger.name}}  
> - Severity: {{ctx.trigger.severity}}  
> - Period start: {{ctx.periodStart}}  
> - Period end: {{ctx.periodEnd}}  
> "}

---

<div class="post-metadata">

**Author:** ![bbKhamar](https://avatars.discourse-cdn.com/v4/letter/b/3bc359/32.png) [@bbKhamar](https://forum.opensearch.org/u/bbKhamar)\
**Post date:** [June 3, 2021, 8:12pm UTC](https://forum.opensearch.org/t/custom-webhook-for-microsoft-teams/2346/10 "2021-06-03T20:12:38Z")

</div>

Hey dear, I too have the same issue. curl command send messages perfectly but kibana custom webhook not able to send any messages.  
Let me know if you manage to find solution

---

<div class="post-metadata">

**Author:** ![shaimoh](https://avatars.discourse-cdn.com/v4/letter/s/4da419/32.png) [@shaimoh](https://forum.opensearch.org/u/shaimoh)\
**Post date:** [June 30, 2021, 4:11pm UTC](https://forum.opensearch.org/t/custom-webhook-for-microsoft-teams/2346/11 "2021-06-30T16:11:30Z")

</div>

Hi,

Can you let me know where you’re entering the Curl command to see test the results ?

---

<div class="post-metadata">

**Author:** ![bbKhamar](https://avatars.discourse-cdn.com/v4/letter/b/3bc359/32.png) [@bbKhamar](https://forum.opensearch.org/u/bbKhamar)\
**Post date:** [July 1, 2021, 3:16pm UTC](https://forum.opensearch.org/t/custom-webhook-for-microsoft-teams/2346/12 "2021-07-01T15:16:49Z")

</div>

Its resolved for me, actually the teams webhook was getting blocked by my internal network.
