Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Unable to use MS Teams Workflow webhook url in Channels #942

Open
sharathganga opened this issue Aug 7, 2024 · 8 comments
Open

[BUG] Unable to use MS Teams Workflow webhook url in Channels #942

sharathganga opened this issue Aug 7, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@sharathganga
Copy link

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 sharathganga added bug Something isn't working untriaged labels Aug 7, 2024
@Hailong-am
Copy link
Collaborator

@sharathganga as a workaround you can select slack and input the workflows URL for teams

@sharathganga
Copy link
Author

@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
Copy link
Collaborator

@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.

@Hailong-am
Copy link
Collaborator

@opensearch-project/admin please transfer this to notification repo

@cwperks cwperks transferred this issue from opensearch-project/OpenSearch-Dashboards Aug 8, 2024
@Nils-543
Copy link

Hi,
I have the same issue, do you already have something new regarding this issue?

@dcopestake
Copy link

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.

@GerardMorgan
Copy link

GerardMorgan commented Aug 19, 2024

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

@dblock dblock removed the untriaged label Aug 26, 2024
@dblock
Copy link
Member

dblock commented Aug 26, 2024

[Catch All Triage - 1, 2, 3, 4, 5]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants