Skip to content

Update detectProvider and AdaptativeCards to handle new Teams Webhook relying on Power Automate #2

@lucaswitvoet

Description

@lucaswitvoet

Description:
The detectProvider function is currently unable to detect Power Automate URLs for Microsoft Teams, as it doesn't include URLs from the Power Platform. A new change to webhooks relying on "Workflows", this has introduced URLs with the domain environment.api.powerplatform.com for Power Automate services.

This change results in the function not correctly identifying these URLs, and they are categorized under generic, when they should instead be detected as teams.

Current Code:

function detectProvider(webhook) {
    const url = webhook.toLowerCase();
    if (url.includes('discord.com/api/webhooks') || url.includes('discordapp.com/api/webhooks')) {
        return 'discord';
    } else if (url.includes('hooks.slack.com')) {
        return 'slack';
    } else if (url.includes('webhook.office.com') || url.includes('.webhook.office.com')) {
        return 'teams';
    }
    return 'generic';
}

Suggested Change:

To correctly identify Power Automate webhooks, modify the condition for Teams to also check for environment.api.powerplatform.com. Here’s the updated code snippet:

function detectProvider(webhook) {
    const url = webhook.toLowerCase();
    if (url.includes('discord.com/api/webhooks') || url.includes('discordapp.com/api/webhooks')) {
        return 'discord';
    } else if (url.includes('hooks.slack.com')) {
        return 'slack';
    } else if (url.includes('webhook.office.com') || url.includes('.webhook.office.com') || url.includes('environment.api.powerplatform.com')) {
        return 'teams';
    }
    return 'generic';
}

Impact:

This fix will ensure that URLs from Power Automate are correctly recognized as Teams webhooks, avoiding the misclassification as generic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions