notifications
notifications copied to clipboard
[BUG] Unable to use MS Teams Workflow webhook url in Channels
What is the bug? Microsoft is deprecating the Office 365 connectors for Teams and we need to utilize the Workflows webhook URL to post messages to Teams channels. I've generated a webhook URL but am unable to use it in OpenSearch.
Refer: https://devblogs.microsoft.com/microsoft365dev/retirement-of-office-365-connectors-within-microsoft-teams/
How can one reproduce the bug?
Method 1:
Go to 'Notifications -> Channels -> Create Channel' Set a channel name Select Channel Type -> Microsoft Teams Webhook URL -> https://prod-XX.westeurope.logic.azure.com:443/workflows/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Click "Send Test Message"
Error:
[status_exception] Wrong Microsoft Teams url. Should contain "webhook.office.com"
Method 2:
Select Channel Type -> Custom webhook Method -> POST Webhook URL -> https://prod-XX.westeurope.logic.azure.com:443/workflows/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Click "Send Test Message"
Error:
[status_exception] {"event_status_list": [{"config_id":"666cK5EB6cKDPdC7sDsE","config_type":"webhook","config_name":"temp-MS Teams Workflow Test","email_recipient_status":[],"delivery_status":{"status_code":"500","status_text":"Failed to send webhook message Failed: {\"error\":{\"code\":\"InvalidRequestContent\",\"message\":\"The request content is not valid and could not be deserialized: 'Unexpected character encountered while parsing value: T. Path '', line 0, position 0.'.\"}}"}}]}
What is your host/environment?
AWS OpenSearch 2.11
@sharathganga as a workaround you can select slack and input the workflows URL for teams
@Hailong-am It still fails to send a test message when I use Slack Channel type but this time with a different error:
[status_exception] {"event_status_list": [{"config_id":"B6SLLJEBJpQT_mdoZxeG","config_type":"slack","config_name":"temp-Test","email_recipient_status":[],"delivery_status":{"status_code":"500","status_text":"Failed to send webhook message Failed: {\"error\":{\"code\":\"TriggerInputSchemaMismatch\",\"message\":\"The input body for trigger 'manual' of type 'Request' did not match its schema definition. Error details: 'Invalid type. Expected Object but got String.'.\"}}"}}]}
@Hailong-am It still fails to send a test message when I use Slack Channel type but this time with a different error:
[status_exception] {"event_status_list": [{"config_id":"B6SLLJEBJpQT_mdoZxeG","config_type":"slack","config_name":"temp-Test","email_recipient_status":[],"delivery_status":{"status_code":"500","status_text":"Failed to send webhook message Failed: {\"error\":{\"code\":\"TriggerInputSchemaMismatch\",\"message\":\"The input body for trigger 'manual' of type 'Request' did not match its schema definition. Error details: 'Invalid type. Expected Object but got String.'.\"}}"}}]}
@sharathganga can you share an example request for new webhook? i need this to check whether the schema has changed.
@opensearch-project/admin please transfer this to notification repo
Hi, I have the same issue, do you already have something new regarding this issue?
Unfortunately the issue here is that the suggested migration path for moving away from the "Incoming Webhook" Office 365 Connector is to use a Power Automate Workflow with the "When a Teams webhook request is received" as the trigger, however this does not support the same basic JSON schema that the original connector supported and instead will only accept Adaptive Card data instead.
It is possible to temporarily work around this issue by using the OpenSearch "Custom webhook" notification channel type instead. This will allow you to define any webhook URL you want, and then within the actual monitor action you can format the message to include the correct JSON. For example something like this:
{
"type": "message",
"attachments": [
{
"contentType": "application/vnd.microsoft.card.adaptive",
"content": {
"type": "AdaptiveCard",
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.3",
"body": [
{
"type": "TextBlock",
"size": "Medium",
"weight": "Bolder",
"text": "{{ctx.monitor.name}}"
},
{
"type": "TextBlock",
"text": "{{ctx.trigger.name}}"
}
]
}
}
]
}
Obviously replacing the Mustache template variables for whatever is appropriate for your situation.
It's possible to configure the Teams workflow(PowerAutomate) webhooks any way you want. You don't have to adopt the default adaptive-card schema. I've managed to get the custom webhook to trigger with the OpenSearch action message defined with a Mustache expression as:
{ "text": "{{#ctx.results.0.hits.hits.0}} {{_source.["k8s.event.reason"]}}<br> {{_source.body}} {{/ctx.results.0.hits.hits.0}}" }
But having trouble accessing the JSON attributes that have dotted names ie.: ["k8s.event.reason"]. Is there a syntax to escape those, so that they are parseable and get rendered in the message
Hi Team,
Has there been any newer developments regarding this Git? Is the configuration of MS Team integration on OpenSearch Dev still being worked on or was it completed already?
Thank you
Experiencing the same issue with OpenSearch 2.19. What's the current workaround?
Here's what I've done that works:
-
Configure your webhook in Teams the same as below
-
In OpenSearch create a Channel using the Custom Webhook option, use the POST method and Content-Type w/ application/json in the header. FYI this test button will not work!
-
When setting up the monitor in OpenSearch, under Triggers > Action > Message Field, input your text formatted in JSON. Example:
{ "text": ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\nMonitor {{ctx.monitor.name}} just entered alert status. Please investigate the issue.\n - Trigger: {{ctx.trigger.name}}\n - Severity: {{ctx.trigger.severity}}\n - No of Error hits : {{ctx.results.0.hits.total.value}}\n - Period start: {{ctx.periodStart}}\n - Period end: {{ctx.periodEnd}}\n\nKibana Link: https://example.com/_dashboards/goto/b9b1e0f87c5c806c6fca5?security_tenant=global \n\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" }
- If you use the test button located within the Action setup it should work if you did everything correctly, hope this helps!
I would like to use teams notifications within in snapshot policy. Any way workarounds for that?