Forum Discussion

vivek_7383's avatar
vivek_7383
Copper Contributor
Feb 22, 2025

How can I install my bot via link with adding custom params to link?

I want to install a Teams bot using a deep link while passing custom parameters. Additionally, I need these parameters to be retrieved in the installation callback. How can I achieve this?

I believe this deep link I can use https://teams.microsoft.com/l/app/%3Cyour-app-id%3E, but let me know about custom parameters

Thanks

1 Reply

  • You're correct about using the deep link format https://teams.microsoft.com/l/app/ for Teams app installation. Here's how to handle custom parameters:
    https://teams.microsoft.com/l/app/{appId}?context={contextParameters}

    Where:

    • {appId} is your Teams app ID
    • {contextParameters} is a URL-encoded JSON object containing your custom values example - context=%7B%22subEntityId%22%3A%22customValue%22%7D

    Unfortunately, there's a limitation: the bot installation callback (onInstallationUpdateAdd event) does not automatically receive the custom parameters passed via deep link.

    Workarounds:

    1. Tab-based solution: If your app includes a tab, the tab can receive these parameters through the Teams JavaScript SDK

    microsoftTeams.getContext((context) => {
      // Access custom parameters here
      console.log(context.subEntityId);
    });

    The tab can then communicate these parameters to your bot.
    2. State parameter approach: Generate a unique state ID, store it with your parameters in your backend, and include it in the deep link. When your bot receives the installation event, have it query your backend with the user/tenant ID to retrieve the associated parameters.

    The most reliable approach is to combine your bot with a tab component, as tabs can directly access the context parameters from deep links, while bots cannot.

Resources