Forum Discussion

AlexKozler's avatar
AlexKozler
Copper Contributor
Nov 06, 2023

Trying to understand MS Teams "Tab App"

Hoping someone here knows something about creating apps for Teams integration. There's a lot of documentation around it but some of the concepts are a bit muddy. I'm looking at making a "tabs" app to essentially host a miniature version of my website (essentially a business-to-customer chat app) using Blazor.

A few things not really clear to me:

  • It seems like tab apps are basically just iFrames at heart, and if you leave a tab app, it "closes" it, and returning to it would not save any sort of state- but instead be like a whole page refresh. Is there any way to preserve the state? Doesn't seem like cookies are a thing here.

  • Since my normal site sends/receives messages, is there any way to notify the Teams user of an incoming message? Since it seems like the tab apps are essentially closed like you X'd out of a browser tab, I'm not seeing how something like SignalR could persist to notify the user of anything... or to show some sort of toast notification or red bubble next to the app icon.

  • Is incorporating SSO with Microsoft required here, or would I be able to just let users log into my app the same way they would on my website, with their credentials or tokens persisting indefinitely?

4 Replies

  • AlexKozler - 

    1. State Preservation: Tabs in Teams are indeed similar to iFrames and do not inherently preserve state. However, you can implement state preservation in your app by storing state information in a database or other persistent storage and retrieving it when the tab is reloaded. This would require additional development work on your part.

    2. Notifications: Tabs themselves do not support notifications. However, you can use a bot in conjunction with your tab to send proactive messages to users. The bot can be triggered by events in your tab, such as incoming messages, and send notifications to the user. You can also use the bot to send messages to the user when the tab is not active.

    3. Authentication: Tabs do support Single Sign-On (SSO) with Azure Active Directory (Azure AD), which provides a seamless sign-in experience for users. However, SSO is not required. You can implement your own authentication mechanism, allowing users to sign in with their credentials as they would on your website. 

     

    Thanks, 

    Prasad Das

    ------------------------------------------------------------------------------------------ 

    If the response is helpful, please click "**Mark as Best Response**" and like it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate. 

    • SadPython's avatar
      SadPython
      Copper Contributor
      In the authentication case, is SSO enough to sign users into the app if they have an existing account? That is, if I request and validate an auth token via the SSO flow, can I then find the user in my main app's database and log them in securely?
    • AlexKozler's avatar
      AlexKozler
      Copper Contributor

      Prasad_Das-MSFT 

       

      - I understand I can preserve state in my own backend, but it's there any way to preserve any small bit of identifying info in a tab app itself? For example, you mentioned I could implement my own auth instead of using SSO. If there is no way to store state, though (like cookies or local storage APIs), how would I persist their auth or session token (client side) between "visits" to the tab? Even if it was just one simple token string identify them. I can't have them logging in repeatedly.

       

      - My goal with notifications is to have a toast notification pop up in the corner that they can click on to deep link them into the tab and into my app regardless of where they might be in Teams itself- in a meeting, in a totally unrelated chat, in another app's tab, etc. Do "bots" allow this, or is a bot something you have to add to a specific Teams conversation? Is a bot a while secondary/separate app or would it be part of the same tab app?

      • Prasad_Das-MSFT's avatar
        Prasad_Das-MSFT
        Icon for Microsoft rankMicrosoft

        AlexKozler - Yes, you can use the local storage APIs to store state, such as a session token or other identifying information, between visits to the tab. This can be done by using the localStorage or sessionStorage objects to store key-value pairs. These objects allow you to store data on the client side, and the data persists even after the browser is closed or the user navigates away from the page. This way, you can persist the user's authentication or session token between visits to the tab, without requiring them to log in repeatedly.

         

        For notifications, you can use a bot to send a message with a deep link to your tab. This method is preferred especially if the tab thread is targeted. A bot can be part of the same tab app and it's not a separate app. You can @mention specific users if needed.

Resources