Forum Discussion
How can I install my bot via link with adding custom params to link?
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.