LM-Development / aks-sample

Community project providing an undeprecated Microsoft Teams bot sample that runs on Azure Kubernetes Service
https://github.com/LM-Development/aks-sample/tree/main/Samples/PublicSamples/RecordingBot
MIT License
1 stars 0 forks source link

Can we invite this recording bot directly to a peer-to-peer call? #57

Open bijaykush opened 2 months ago

bijaykush commented 2 months ago

I am using this sample to create a recording bot which will join both peer-to-peer call and MS Teams meeting to get the audio streams.

MS Teams Meeting: I have used joinURL from MS Teams meeting to ask the Bot to join the call - Succeeded. MS Teams p-2-p call (between Teams user OR PSTN caller and Teams user) - Not Succeeded.

Any help would be appreciated. Thank you

1fabi0 commented 2 months ago

Hi with a compliance recording setup the bot would automatically join into those calls. Within the setup of a compliance recording policy you set up an application instance, that instance can also have a licensed phone number (I never tested if it works, but it's possible). Alternatively you can create a teams bot application template (the one that is used for chat bots) and activate call functionality, then you can invite the bot into p2p calls by adding the bot like a normal participant.

I'm not 100% sure if this is what you want, but you can't do something like join by url for p2p calls.

I hope that helps 🙂

bijaykush commented 2 months ago

Hi @1fabi0 @InDieTasten thank you for your time looking into the scenario.

I know the the process to join the Teams Meeting or Teams p-2-p call through compliance recording bot. But I am using this sample without compliance recording approach i.e. joining the meeting directly with Join URL which is implemented, and working on figuring out the process to join p-2-p call.

Workaround: I was converting the p-2-p call to group call by inviting a Teams user(who never picks the call) through Invite participant API and then using ChatInfo property to generate the join URL and joining that group call using this sample. Unfortunately from this last month, Graph notifications is giving ChatInfo as null even in group call which fails this workaround.

I am wondering if there is another way of doing this OR looking to know why the chatInfo property is null?

1fabi0 commented 2 months ago

The why is hard to answer probably you get some kind of meetingInfo that is a JWT token, but that doesn't answer why you don't get a chatInfo property.

The exact reason is not known to me and we can only know if we could look into the source code of Microsoft, which we obviously can't. However the chatInfo is only partly connected to meetings. For example you can also use the chatInfo to send messages into the chat of a meeting with the graph API chat endpoint. So my assumption is for some calls, like meetings, Microsoft saves the metadata( where a meeting takes place, like which datacenter, if it's currently active, etc.)in some kind of chat message or the chat Id does not directly refer to chat messages which also would make sense. And for other calls like p2p and calls Microsoft either spontaniously creates this metadata and does not save it or saves the Metadata not in a special chat message or does not draw a connection for group calls and p2p calls with the chat.

As I said: I would try to create a teams application manifest that allows for calling ( as you can see here there is an option to allow for calling), or try if the application Instances from the policy creation as they get a UPN and afaik telephone numbers can be assigened to them.

During writing I just remembered that I did work on a bot that joined with urls that were provided by a teams manifest app, the app was a teams iframe application that read the chatInfo etc from the teams SDK but I don't remember if it worked for groups or if the manifest app just didn't support groups.

Hope that helps 🙂

bijaykush commented 2 months ago

Hi @1fabi0 Thank you so much for taking the time to provide such a detailed explanation! Your insights are incredibly helpful and shed light on the nuances of the issue. From your suggestions on application instance, I guess, you are suggesting me to create application instance with a afaik phone number assigned to it. And then assign recording policy to that application instance so that when we invite the application instance though Invite API to the p-2-p call, it will be recorded. Please correct me if I am getting it wrong.

If I am correct, should I create a recording policy with application instance A, and then assign the policy to application instance B (having afaik ph number), and then invite application instance B in required p-2-p call to record it?

1fabi0 commented 2 months ago

Hi, not directly I would first try to create a teams bot with a manifest with calling enabled and try to invite the manifest bot via the Invite API. If this doesn't work try to create a application instance and try to invite the application instance via the invite API. The telephone number thing was ment to mean: "the application instance is like a user, we can even assign it a telephone number".

But i think the first option works better for you're use case as you can search for that bot in the teams UI and wouldn't need an application in the middle that is just there to do invatations. Then users could just try to add the bot like any other participant (also in meetings) and the bot joins and does its thing.

bijaykush commented 2 months ago

This sound interesting. I assume this teams bot with manifest process will join the call on invitations and does the recording of the call. I will check it out and come back. Thank you so much for your time and information.

bijaykush commented 2 months ago

HI @1fabi0 your suggestion works. I created a manifest with audio calling support and then pointed the recording bot which runs this sample code without policy creation. I invited the bot_name manually in the call Teams call and meeting from Teams client and it gives the recording data.

But do you know any way how I can invite this Bot using Invite API instead of adding it manually? I tried of creating application instance based on Recording Bot App Id and then invite the object Id of that created application instance using Invite API with this payload

{
        "@odata.type": "#microsoft.graph.participantInviteRequestBody",
        "participants": [
          {
            "@odata.type": "#microsoft.graph.invitationParticipantInfo",
            "identity": {
              "@odata.type": "#microsoft.graph.identitySet",
              "application": {
                "@odata.type": "#microsoft.graph.identity",
                "id": "608a4454-ab62-4cfa-a#############" //object Id of application instance
              },
              "tenantId": "a3329193-f9c6-4829-################"
            }
          }
        ],
      }

But It gives me tenant mismatch error

 {
        "@odata.type": "#microsoft.graph.errorResponse",
        "error": {
          "@odata.type": "#microsoft.graph.error",
          "code": "7505",
          "message": "Request authorization tenant mismatch.",
          "innererror": {
            "@odata.type": "#microsoft.graph.error",
            "date": "2024-04-28T06:38:28",
            "request-id": "33163486-203a-457c-8fc9-c4536fb45602",
            "client-request-id": "651f9250-af24-4185-a867-8cf487e2778f"
          }
        }
      }

May be I am thinking in wrong direction. I just wanted to invite this recording bot/teams manifest bot into another call (a p-2-p call between a IVR Bot and Phone Number of same tenant).