SOLVED

Cannot initiate PSTN calls from bot

Brass Contributor

Hi everybody,

 

within my calling bot I try to initiate a PSTN call like https://docs.microsoft.com/en-us/graph/api/application-post-calls?view=graph-rest-1.0&tabs=http#exam... or invite a PSTN as new participant to an Existing call like https://docs.microsoft.com/en-us/graph/api/participant-invite?view=graph-rest-1.0&tabs=http#example-...

I always get following exception:

InternalServerError
Microsoft.Graph.ServiceException: Code: 9999
Message: Unknown internal server error.
Inner error:
AdditionalData:
date: 2021-10-26T10:15:50
request-id: 58538d09-d622-4d61-854e-61606e0f6530
client-request-id: 58538d09-d622-4d61-854e-61606e0f6530
ClientRequestId: 58538d09-d622-4d61-854e-61606e0f6530

at Microsoft.Graph.HttpProvider.SendAsync(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationToken cancellationToken)
at Microsoft.Graph.BaseRequest.SendRequestAsync(Object serializableObject, CancellationToken cancellationToken, HttpCompletionOption completionOption)
at Microsoft.Graph.BaseRequest.SendAsync[T](Object serializableObject, CancellationToken cancellationToken, HttpCompletionOption completionOption)
at RC_MsGraphLink.Controllers.GraphApi.GraphHandler.MakeCall(InvitationParticipantInfo device) in C:\Users\GeW\Documents\tfshome\GLOBAL\MAIN\RC_MsGraphLink\RC_MsGraphLink\Controllers\GraphApi\GraphHandlerCallControl.cs:line 45

 

My bot has assigned a PSTN number and could be called from extern. Everything also works fine if I try the scenarios with MS Teams Users.

We also followed the instrucions from https://docs.microsoft.com/en-us/graph/cloud-communications-phone-number#assign-a-phone-number-to-yo...

 

There is a similar problem described here:
https://techcommunity.microsoft.com/t5/teams-developer/initiate-pstn-call-from-teams-to-public-landl...

 

Any ideas?

Thanks for yout help.

Regards

Gerd

 

 

8 Replies

@relkniw 

We are looking into the issue.We will update you

 

Thanks, 

Nivedipa

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

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. 

@Nivedipa-MSFTHi Nivedipa,

 

I could solve the "InternalServerError" by using following c# code:

 

AdditionalData = new Dictionary<string, object>()
{
    {"phone", new Identity() { Id = pDevice} }
}

 

instad of

 

AdditionalData = new Dictionary<string, object>()
{
    {"phone", "{\"@odata.type\":\"#microsoft.graph.identity\",\"id\":\"+12345678901\"}"}
}

 

But now I have annother problem: After sending the MakeCall Request I get an establishing Event and immediately an Terminated Event with an Error:

"value": [
{
"changeType": "Updated",
"resourceUrl": "/communications/calls/911f6100-723b-400b-9053-893f686f3131",
"resource": "/app/calls/911f6100-723b-400b-9053-893f686f3131",
"resourceData": {
"@odata.type": "#microsoft.graph.call",
"state": "establishing",
"callChainId": "ef0c7f6a-974b-4700-8525-d74fe4d924c2"
},
"@odata.type": "#microsoft.graph.commsNotification"
}
],
"@odata.type": "#microsoft.graph.commsNotifications"
}

 

{
"value": [
{
"changeType": "Deleted",
"resourceUrl": "/communications/calls/911f6100-723b-400b-9053-893f686f3131",
"resource": "/app/calls/911f6100-723b-400b-9053-893f686f3131",
"resourceData": {
"@odata.type": "#microsoft.graph.call",
"state": "terminated",
"resultInfo": {
"@odata.type": "#microsoft.graph.resultInfo",
"code": 500,
"subcode": 9999,
"message": "Get Outbound routing - failed getting userId from billedUserMri: 28:d86f4970-a209-46f1-ad06-87137338eac2. DiagCode: 500#510543"
},
"callChainId": "ef0c7f6a-974b-4700-8525-d74fe4d924c2",
"terminationSender": {
"@odata.type": "#microsoft.graph.identitySet",
"phone": {
"@odata.type": "#microsoft.graph.identity",
"id": "+41*********",
"displayName": "4:+41*******",
"identityProvider": "None"
}
}
},
"@odata.type": "#microsoft.graph.commsNotification"
}
],
"@odata.type": "#microsoft.graph.commsNotifications"
}

 

The service user for the bot has an "Microsoft 365 E3" and a "Microsoft 365 Phone System" license.

And I am able to make call from a PSTN number to the bot.

 

Any idea?

 

Regards

 

Gerd

best response confirmed by relkniw (Brass Contributor)
Solution
We could solve the problem. We used the wrong object ID for creating the call. After using the object ID from the assigned service user, it works.

@relkniw 

Hi relkniw

Could you please show where do you get the correct object id that works in your case? There seem to be several options and we are not sure which one is correct.

 

Thanks a lot.

@ecastan1

Hi ecastan1,

 

I think you have created a new service user in the Azure AD for your calling bot by using a powershell command. Something like New-CsOnlineApplicationInstance -UserPrincipalName
<new userid> -ApplicationId <ClientId>. Then you have to use the object id of that new created user.

 

Hope that answers your question.

 

Regards

 

Gerd

Thanks for your response Gerd. Much appreciated. we'll check it out.

Best regards
Esteban C.
Hi, would you mind sharing where exactly in the API / code do you user the service user object id instead of bot registration ID. Basically I'm trying to get the IncidentBot sample to call PSTN, I did all the configuration as described is this thread but getting the same error "DiagCode: 500#510543".
thanks in advance.
Łukasz
Ok, I've found the issue, you need to add call source "applicationInstance" with id of the service account. It's not well documented and not in c# api, must be done manually through additional data.
1 best response

Accepted Solutions
best response confirmed by relkniw (Brass Contributor)
Solution
We could solve the problem. We used the wrong object ID for creating the call. After using the object ID from the assigned service user, it works.

View solution in original post