microsoftgraph / microsoft-graph-comms-samples

Microsoft Graph Communications Samples
MIT License
208 stars 231 forks source link

VoiceRecorderAndPlaybackBot Readme - Required API permissions #224

Open MaxiPigna opened 4 years ago

MaxiPigna commented 4 years ago

The Readme of VoiceRecorderAndPlaybackBot states

This Bot doesnt need any permissions

While 2 Microsoft Graph API permissions are required:

CCNOAI commented 4 years ago

@MaxiPigna I cannot get the VoiceRecorderAndPlaybackBot to work. I can build the VoiceRecorderAndPlaybackBot.sln, I can create the App in teams, create the bot in azure, but when I call the bot in Teams it does not work. Is this a permission issue? Could you please point me in the right direction.

MaxiPigna commented 4 years ago

I suggest you to debug your bot locally to understand if you are correctly receiving messages from the User and bot works without any error.

If you didn't grant the permissions listed above I expect you receive an Unauthorized exception at this line of code. Add a try-catch there and check what happens. 😉

CCNOAI commented 4 years ago

@MaxiPigna Thanks so much for the information. What is a good way to debug locally? The webhook initiates the the local code, but is there a way to debug the controller without calling the webhook so that I can do a full debug locally. Thanks in advance. I apologize for the novice questions. I am new to .Net development.

MaxiPigna commented 4 years ago

As far as I know, this is the only way. Consider that the call flow behind the scenes between Teams client and the Bot is complicated to emulate. Remember to switch the webhook to Ngrok when running the bot locally:

Under "Bot Services" click "VoiceRecorderAndPlaybackBot", Click "Channels", Then select "Microsoft Teams" channel and enable it with next step.

  • Click "Calling" tab, select "Enable calling" check box, then fill the "Webhook (for calling)" edit box with value "{BotBaseUrl}/callback". Click "Save".

If you need help to start the sample, I would Ask a Question on Stack Overflow, you'll get the support you need. 😉

CCNOAI commented 4 years ago

@MaxiPigna I caught the error. Could you please share what you did to fix the error? Thanks in advance.

MaxiPigna commented 4 years ago

Go to Azure Portal -> Azure Active Directory -> App Registrations -> Open your App Registration -> API Permission -> Add a permission Add the permissions:

Both of type Application and remember to Grant admin consent

CCNOAI commented 4 years ago

@MaxiPigna Thanks soooo very much for your reply. I did do this. I am getting an "insufficient tenant permissions" exception. I can connect, but I do not hear the recording play. Is there something else that you had to do?

MaxiPigna commented 4 years ago

Can you post a screenshot of the API Permission you granted and the line of code returning the exception?

CCNOAI commented 4 years ago

image

CCNOAI commented 4 years ago

@MaxiPigna I added all permissions for calls and teams and it is still not working. Also, here is the stack trace.

fail: VoiceRecorderAndPlaybackBot[1742746998] 2020-07-06T23:05:11.5197Z 00000000-0000-0000-0000-000000000000 pid:23658 tid:47 (Bot.cs:247 NotificationProcessor_OnNotificationReceived): Caught an Exception running the task: Error processing notification /communications/calls/be1f0400-731f-489a-a110-5457d9a040c8 with scenario e5b6e28c-e545-4638-8f32-d8ff8a4e8fbf exception: Code: 7504 Message: Insufficient enterprise tenant permissions, cannot access this API. Inner error: AdditionalData: date: 2020-07-06T23:05:11 request-id: 2df32658-90f2-4b97-a39e-5f18ed3d2063

  StackTrace:    at Microsoft.Graph.Communications.Client.Transport.GraphAuthClient.ValidateResponseAsync(HttpResponseMessage response)
     at Microsoft.Graph.Communications.Client.Transport.GraphAuthClient.SendHttpRequestAsync[T1,T2](IGraphRequest`1 graphRequest, CancellationToken cancellationToken)
     at Sample.Common.Transport.GraphClientExtensions.SendAsync[T](IGraphClient client, IBaseRequest request, RequestType requestType, String tenant, Guid scenarioId, CancellationToken cancellationToken) in /Users/benjaminharvey/Desktop/microsoft-graph-comms-samples-master/Samples/Common/Sample.Common/Transport/GraphClientExtensions.cs:line 107
     at Sample.VoiceRecorderAndPlaybackBot.Bot.Bot.BotRecordsIncomingCallAsync(String callId, String tenantId, Guid scenarioId) in /Users/benjaminharvey/Desktop/microsoft-graph-comms-samples-master/Samples/V1.0Samples/StatelessSamples/VoiceRecorderAndPlaybackBot/Bot/Bot.cs:line 456
     at Sample.VoiceRecorderAndPlaybackBot.Bot.Bot.NotificationProcessor_OnNotificationReceivedAsync(NotificationEventArgs args) in /Users/benjaminharvey/Desktop/microsoft-graph-comms-samples-master/Samples/V1.0Samples/StatelessSamples/VoiceRecorderAndPlaybackBot/Bot/Bot.cs:line 310
     at Sample.Common.CommonUtilities.ForgetAndLogExceptionAsync(Task task, IGraphLogger logger, String description, String memberName, String filePath, Int32 lineNumber) in /Users/benjaminharvey/Desktop/microsoft-graph-comms-samples-master/Samples/Common/Sample.Common/CommonUtilities.cs:line 40
MaxiPigna commented 4 years ago

I cannot see your screenshot, it's too small. From the stack trace BotRecordsIncomingCallAsync seems to be the method throwing the exception. That method needs of Calls.AccessMedia.All permission. So, you should have a permission like this in your App Registration. image

CCNOAI commented 4 years ago

Hi @MaxiPigna. First of all thanks for all your help.

Here are the following permission that I have. I have granted admin consent for each one as well. Calls.JoinGroupCallAsGuest.All  
Calls.JoinGroupCall.All  
Calls.InitiateGroupCall.All  
Calls.Initiate.All  
Calls.AccessMedia.All  

CallRecords.Read.All

adoronin commented 3 years ago

Hi @CCNOAI. I am seeing this same error. Did you ever find a resolution? Could you please answer. We have this issue only when we add the bot app registration in another tenant. All is good only in the bot initial tenant in which he was created.

adoronin commented 3 years ago

This is a request and response with the error which we got from logs. I hope it will help to solve the issue.

Request:

{"@t":"2020-11-13T08:07:30.4700282Z","@mt":"$>2020-11-13T08:07:30.4700282Z Info: GraphAuthClient.cs:100 SendHttpRequestAsync
ScenarioId: e8ce7c6e-c1f0-44de-a241-89a59274ac6d
AppId: 8a932101-d60e-4097-a3ae-81d9a919f466
AppName: InterprefyBot.Api
TransactionDirection: Outgoing
TraceType: HttpRequest
request: POST https://graph.microsoft.com/v1.0/communications/calls
headers:
  Scenario-Id: e8ce7c6e-c1f0-44de-a241-89a59274ac6d
  Client-Request-Id: 5d6330aa-e7ce-49ed-a979-75666251d2bd
  User-Agent: GraphCommunicationsClient-InterprefyBot.Api/1.2.0.1702
  Authorization: (redacted)
  Content-Type: application/json; charset=utf-8
{
  "@odata.type": "#microsoft.graph.call",
  "direction": "outgoing",
  "callbackUri": "https://test.dreamdeveloper.site:10100/api/calling",
  "source": {
    "@odata.type": "#microsoft.graph.participantInfo",
    "identity": {
      "@odata.type": "#microsoft.graph.identitySet",
      "application": {
        "@odata.type": "#microsoft.graph.identity",
        "displayName": "(Identity: /JIi4yT5)",
        "id": "8a932101-d60e-4097-a3ae-81d9a919f466"
      }
    }
  },
  "requestedModalities": [
    "audio",
    "video"
  ],
  "mediaConfig": {
    "@odata.type": "#microsoft.graph.appHostedMediaConfig",
    "blob": "{"mpUri":"net.tcp://test.dreamdeveloper.site:20100/MediaProcessor","audioRenderContexts":["dff8d79b-b16d-47e0-9f46-315329efdc2d"],"videoRenderContexts":["d733f256-1a6d-4db8-b3a1-eaf2f7ad288a"],"audioSourceContexts":[null],"videoSourceContexts":["3a3259af-0d1e-4d71-a6ee-b4a332b2dcd6"],"dataRenderContexts":null,"dataSourceContexts":null,"supportedAudioFormat":"Pcm16K","videoSinkEncodingFormats":["Yuv"],"mpMediaSessionId":"e70c882d-155f-47b9-8bf2-48d139b8b2e4","regionAffinity":null,"skypeMediaBotsVersion":"1.17.0.0039","mediaStackVersion":"2020.7.1.12","mpVersion":"7.2.0.7736","callId":"52e8805c-076b-430d-a53a-1942880c2164"}"
  },
  "chatInfo": {
    "@odata.type": "#microsoft.graph.chatInfo",
    "threadId": "19:meeting_NGYwNTFmOWQtYzg5Ny00NGQ3LWFmYWEtMTk0MDFlZWE0Y2Ex@thread.v2",
    "messageId": "0"
  },
  "meetingInfo": {
    "@odata.type": "#microsoft.graph.organizerMeetingInfo",
    "organizer": {
      "@odata.type": "#microsoft.graph.identitySet",
      "user": {
        "@odata.type": "#microsoft.graph.identity",
        "id": "680cb77f-b79d-4f7c-b206-66ec4fd011af",
        "tenantId": "961d04a5-b756-48da-b89b-173910acb5f5"
      }
    }
  },
  "tenantId": "961d04a5-b756-48da-b89b-173910acb5f5",
  "callOptions": {
    "@odata.type": "#microsoft.graph.outgoingCallOptions",
    "allowGuestToBypassLobby": true
  }
}
","@i":"3a40542d"}

Response:

{"@t":"2020-11-13T08:07:30.7512910Z","@mt":"$>2020-11-13T08:07:30.7512910Z Error: GraphAuthClient.cs:117 SendHttpRequestAsync
ScenarioId: e8ce7c6e-c1f0-44de-a241-89a59274ac6d
AppId: 8a932101-d60e-4097-a3ae-81d9a919f466
AppName: InterprefyBot.Api
TransactionDirection: Outgoing
TraceType: HttpResponse
ResponseTime: 277
request: POST https://graph.microsoft.com/v1.0/communications/calls
response: 403 Forbidden
headers:
  request-id: aa9c5c12-c915-48af-bbbc-6535e2d57797
  client-request-id: 5d6330aa-e7ce-49ed-a979-75666251d2bd
  x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"Central US","Slice":"SliceC","Ring":"2","ScaleUnit":"001","RoleInstance":"AGSFE_IN_4"}}
  scenario-id: e8ce7c6e-c1f0-44de-a241-89a59274ac6d
  Strict-Transport-Security: max-age=31536000
  Cache-Control: private
  Date: Fri, 13 Nov 2020 08:07:30 GMT
  Content-Length: 325
  Content-Type: application/json
{
  "error": {
    "code": "7504",
    "message": "Insufficient enterprise tenant permissions, cannot access this API.",
    "innererror": {
      "date": "2020-11-13T08:07:30",
      "request-id": "aa9c5c12-c915-48af-bbbc-6535e2d57797",
      "client-request-id": "5d6330aa-e7ce-49ed-a979-75666251d2bd"
    }
  }
}
}
CCNOAI commented 3 years ago

Hey Alex,

We had two different accounts under two different users that we were using that needed to be combined. One account we were using account was for Microsoft Azure and the other we were using for Microsft Teams.

Once we got both accounts under the same Tennant ID. Everything worked.

Thanks,

~ben

On Thu, Nov 12, 2020 at 4:53 AM Alex Doronin notifications@github.com wrote:

@CCNOAI https://github.com/CCNOAI I am seeing this same error. Did you ever find a resolution? Could you please answer.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/microsoftgraph/microsoft-graph-comms-samples/issues/224#issuecomment-725970495, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANZ3LGYEO6G6OVMBXI5355LSPOV73ANCNFSM4MWWZV3Q .

-- Thanks in advance,

~Ben

Dr. Benjamin Harvey https://www.linkedin.com/in/benjamin-harvey-ph-d-1928839a/ CEO | CCNOAI, LLC 2055 L St. NW Suite 400 Washington, DC 20036 Cell: (904) 662-6611 Email: benjamin.harvey@ccnoai.com www.ccnoai.com http://ccnoai.com [image: CCNOAI] http://www.ccnoai.com