How can I enable Chat communication between external users and Microsoft Teams users through the Teams desktop app ?

Satish Bellare 0 Reputation points
2024-04-12T17:21:52.6666667+00:00

Hello Microsoft team,

I've successfully integrated Microsoft Teams calling into my web application using Azure Communication Services and Microsoft Graph. However, I'm encountering difficulties enabling chat communication between external users accessing my web application and internal users(Team user) who primarily use the Teams desktop app.

Currently, when an external user initiates a chat, a thread ID is generated, allowing them to communicate through the web application's Teams chat interface. However, internal users(Team user) within the organization cannot seamlessly reply or initiate messages through their Teams desktop app to the external users.

Is there a way to bridge this communication gap, allowing internal Teams users to message external users through their desktop app, while the external users continue to utilize the web application's chat interface?

Any guidance or insights on achieving this integration would be greatly appreciated. Thank you!

Azure Communication Services
Azure Communication Services
An Azure communication platform for deploying applications across devices and platforms.
680 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,613 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Ruslan Zdor 5 Reputation points Microsoft Employee
    2024-04-15T21:54:52.36+00:00

    Hi, Sathish

    To communication using chat between Azure Communication user and Teams user they both has to be connected to the same threadId.

    You can use options:

    1. Create a teams meeting using graph and then join it by Teams user and ACS user. In this case your web application can looks like: create meeting in graphAPI https://learn.microsoft.com/en-us/graph/api/onlinemeeting-get?view=graph-rest-1.0&tabs=http join meeting by link or meeting id https://learn.microsoft.com/en-us/azure/communication-services/how-tos/calling-sdk/teams-interoperability
         const callAgent = callClient.createTeamsCallAgent(tokenCredential)
         callAgent.join(meetingLocator: {meetingLink: "URL"})
         
         
      
    2. Create a threadid using chatClient https://learn.microsoft.com/en-us/azure/communication-services/quickstarts/chat/get-started?tabs=windows&pivots=programming-language-javascript make a call and provide threadId to Teams client (currently this method required to use BETA version of SDK because "threadId" parameter is available in BETA)
                 const call = callAgent.startCall( [ { microsoftTeamsUserId: callQueueId.value.trim() }], 
                 { videoOptions: videoOptions, threadId: thatThreadId.chatThread.id });
         
      
    1 person found this answer helpful.

  2. Ruslan Zdor 5 Reputation points Microsoft Employee
    2024-04-29T20:42:41.6466667+00:00

    Hello @Satish Bellare

    I've tested your idea and here is what i've got:

    First step you need to create a thread using ACS chat client and need to add Teams user to this thread:

    it can be done at create step or latter (see two examples below)

    Take a look on how Teams users are defined - they have there own type of Identifier - MicrosoftTeamsUserIdentifier https://learn.microsoft.com/en-us/javascript/api/@azure/communication-common/microsoftteamsuseridentifier?view=azure-node-latest

    You can find UUID for user in GraphAPI or in azure portal

      chatClient.createChatThread({ topic: "Test Chat", options: {
        participants: [
          { microsoftTeamsUserId : "USER OBJECT UUID"
        }
        ]
      }
    
          await this.chatThreadClient.addParticipants({
            participants: [
              {
                id: {
                  microsoftTeamsUserId: 'USER OBJECT UUID'
                }
              }
            ]
          });
    

    After that new thread will NOT show up in Teams, but it will appear when first message will come to Teams user - this is generic Teams logic - new threads will show up in list only after first message is received.

    Be careful will lifetime of ACS token - it is 24 hours and need to be refreshed if you want to reuse it later.