Call from Teams user to Teams user is working , But teams user to PSTN is not passing through my BOT

Copper Contributor

Call from Teams user to Teams user is working fine while using Graph API, But teams user to PSTN is not passing through my BOT

 

PowerShell code:

 

# Securely storing the credentials
$TenantId = "XXXXX-49d3-40ba-a541-4b63e8e0fdc5"
$ClientId = "XXXXX-d9e7-40a7-8ed7-a915969a6833"
$ClientSecret = ConvertTo-SecureString "XXXXXXXXXXXX" -AsPlainText -Force

# Function to obtain an access token
function Get-GraphAccessToken {
param (
[Parameter(Mandatory = $true)][string]$TenantId,
[Parameter(Mandatory = $true)][string]$ClientId,
[Parameter(Mandatory = $true)][System.Security.SecureString]$ClientSecret
)

$TokenBody = @{
Grant_Type = "client_credentials"
Scope = "https://graph.microsoft.com/.default"
Client_Id = $ClientId
Client_Secret = [System.Net.NetworkCredential]::new("", $ClientSecret).Password
}

$TokenResponse = Invoke-RestMethod -Uri "https://login.microsoftonline.com/$TenantId/oauth2/v2.0/token" -Method POST -Body $TokenBody -ContentType "application/x-www-form-urlencoded"
return $TokenResponse.access_token
}

# Obtain Access Token
$AccessToken = Get-GraphAccessToken -TenantId $TenantId -ClientId $ClientId -ClientSecret $ClientSecret

# Convert the AccessToken to a SecureString
$SecureAccessToken = $AccessToken | ConvertTo-SecureString -AsPlainText -Force

# Connect to Microsoft Graph using SecureString
Connect-MgGraph -AccessToken $SecureAccessToken

# Prepare parameters for creating a call
$params = @{
"@odata.type" = "#microsoft.graph.call"
direction = "outgoing"
subject = "call with application hosted media"
callbackUri = "https://53ce-182-71-226-14.ngrok-free.app/callback"
source = @{
"@odata.type" = "#microsoft.graph.participantInfo"
identity = @{
"@odata.type" = "#microsoft.graph.identitySet"
applicationInstance = @{
"@odata.type" = "#microsoft.graph.identity"
displayName = "PPCall"
id = "XXXXXX-1127-483a-bc43-0a99c51a8db0"
}
}
}
targets = @(
@{
"@odata.type" = "#microsoft.graph.invitationParticipantInfo"
identity = @{
"@odata.type" = "#microsoft.graph.identitySet"
phone = @{
"@odata.type" = "#microsoft.graph.Phone"
id = "+14086220061"
}
}
}
)
requestedModalities = @("audio")
mediaConfig = @{
"@odata.type" = "#microsoft.graph.serviceHostedMediaConfig"
blob = "a.wav"
}
tenantId = $TenantId
}

# Error handling for creating a call
try {
$callResponse = New-MgCommunicationCall -BodyParameter $params
$callId = $callResponse.Id
Write-Host "Call created successfully. Call ID: $callId"
} catch {
Write-Error "Error in creating call: $_"
}

 

Console log on BOT:

 

Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request starting HTTP/1.1 POST https://localhost:5001/callback application/json 406
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Route matched with {action = "OnIncomingBotCallUserRequestAsync", controller = "PlatformCall"}. Executing controller action with signature System.Threading.Tasks.Task OnIncomingBotCallUserRequestAsync() on controller Sample.VoiceRecorderAndPlaybackBot.Controller.PlatformCallController (VoiceRecorderAndPlaybackBot).
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Executing action method Sample.VoiceRecorderAndPlaybackBot.Controller.PlatformCallController.OnIncomingBotCallUserRequestAsync (VoiceRecorderAndPlaybackBot) - Validation state: Valid
VoiceRecorderAndPlaybackBot:Information: 2024-01-13T13:53:33.7823Z 391018df-e558-47ca-a486-8ef4a4e5cc28 pid:16512 tid:7 (Bot.cs:270 NotificationProcessor_OnNotificationReceivedAsync):
{
"value": {
"$id": "1",
"$values": [
{
"changeType": "Updated",
"resourceUrl": "/communications/calls/591f5a00-0832-4db0-818f-4923f3a199eb",
"resource": "/app/calls/591f5a00-0832-4db0-818f-4923f3a199eb",
"resourceData": {
"callChainId": "391018df-e558-47ca-a486-8ef4a4e5cc28",
"state": "Establishing",
"@odata.type": "#microsoft.graph.call"
},
"@odata.type": "#microsoft.graph.commsNotification"
}
]
}
}
{
"HttpLogData": {
"Method": "POST",
"Url": "https://localhost:5001/callback",
"Headers": [
"Scenario-Id: 391018df-e558-47ca-a486-8ef4a4e5cc28",
"Client-Request-Id: c3b6d528-991e-461c-868e-e657710ac399",
"X-Microsoft-Tenant: (redacted)"
],
"TransactionDirection": "Incoming",
"TraceType": "HttpRequest",
"TenantId": "00000000-0000-0000-0000-000000000000"
}
}

Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Executed action method Sample.VoiceRecorderAndPlaybackBot.Controller.PlatformCallController.OnIncomingBotCallUserRequestAsync (VoiceRecorderAndPlaybackBot), returned result Microsoft.AspNetCore.Mvc.EmptyResult in 14.0509ms.
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Executed action Sample.VoiceRecorderAndPlaybackBot.Controller.PlatformCallController.OnIncomingBotCallUserRequestAsync (VoiceRecorderAndPlaybackBot) in 17.1437ms
Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request finished in 23.289ms 202
Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request starting HTTP/1.1 POST https://localhost:5001/callback application/json 428
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Route matched with {action = "OnIncomingBotCallUserRequestAsync", controller = "PlatformCall"}. Executing controller action with signature System.Threading.Tasks.Task OnIncomingBotCallUserRequestAsync() on controller Sample.VoiceRecorderAndPlaybackBot.Controller.PlatformCallController (VoiceRecorderAndPlaybackBot).
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Executing action method Sample.VoiceRecorderAndPlaybackBot.Controller.PlatformCallController.OnIncomingBotCallUserRequestAsync (VoiceRecorderAndPlaybackBot) - Validation state: Valid
VoiceRecorderAndPlaybackBot:Information: 2024-01-13T13:53:35.2586Z 391018df-e558-47ca-a486-8ef4a4e5cc28 pid:16512 tid:45 (Bot.cs:270 NotificationProcessor_OnNotificationReceivedAsync):
{
"value": {
"$id": "1",
"$values": [
{
"changeType": "Updated",
"resourceUrl": "/communications/calls/591f5a00-0832-4db0-818f-4923f3a199eb",
"resource": "/app/calls/591f5a00-0832-4db0-818f-4923f3a199eb",
"resourceData": {
"callChainId": "391018df-e558-47ca-a486-8ef4a4e5cc28",
"direction": "Outgoing",
"state": "Established",
"@odata.type": "#microsoft.graph.call"
},
"@odata.type": "#microsoft.graph.commsNotification"
}
]
}
}
{
"HttpLogData": {
"Method": "POST",
"Url": "https://localhost:5001/callback",
"Headers": [
"Scenario-Id: 391018df-e558-47ca-a486-8ef4a4e5cc28",
"Client-Request-Id: b6aa47ed-1e76-42a2-9c24-09b9d6a80ab6",
"X-Microsoft-Tenant: (redacted)"
],
"TransactionDirection": "Incoming",
"TraceType": "HttpRequest",
"TenantId": "00000000-0000-0000-0000-000000000000"
}
}

Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Executed action method Sample.VoiceRecorderAndPlaybackBot.Controller.PlatformCallController.OnIncomingBotCallUserRequestAsync (VoiceRecorderAndPlaybackBot), returned result Microsoft.AspNetCore.Mvc.EmptyResult in 6.0924ms.
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Executed action Sample.VoiceRecorderAndPlaybackBot.Controller.PlatformCallController.OnIncomingBotCallUserRequestAsync (VoiceRecorderAndPlaybackBot) in 9.1392ms
Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request finished in 15.0969ms 202
Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request starting HTTP/1.1 POST https://localhost:5001/callback application/json 792
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Route matched with {action = "OnIncomingBotCallUserRequestAsync", controller = "PlatformCall"}. Executing controller action with signature System.Threading.Tasks.Task OnIncomingBotCallUserRequestAsync() on controller Sample.VoiceRecorderAndPlaybackBot.Controller.PlatformCallController (VoiceRecorderAndPlaybackBot).
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Executing action method Sample.VoiceRecorderAndPlaybackBot.Controller.PlatformCallController.OnIncomingBotCallUserRequestAsync (VoiceRecorderAndPlaybackBot) - Validation state: Valid
VoiceRecorderAndPlaybackBot:Information: 2024-01-13T13:53:35.4283Z 391018df-e558-47ca-a486-8ef4a4e5cc28 pid:16512 tid:7 (Bot.cs:270 NotificationProcessor_OnNotificationReceivedAsync):
{
"value": {
"$id": "1",
"$values": [
{
"changeType": "Updated",
"resourceUrl": "/communications/calls/591f5a00-0832-4db0-818f-4923f3a199eb",
"resource": "/app/calls/591f5a00-0832-4db0-818f-4923f3a199eb",
"resourceData": {
"callChainId": "391018df-e558-47ca-a486-8ef4a4e5cc28",
"mediaState": {
"audio": "Active",
"@odata.type": "#microsoft.graph.callMediaState"
},
"state": "Established",
"@odata.type": "#microsoft.graph.call",
"meetingCapability": {
"@odata.type": "#microsoft.graph.meetingCapability",
"allowTranslatedCaptions": true,
"allowTranslatedTranscriptions": true,
"recorderAllowed": []
},
"meetingProperties": {
"@odata.type": "#microsoft.graph.meetingProperties",
"meetingLabel": "00000000-0000-0000-0000-000000000000"
},
"coOrganizers": []
},
"@odata.type": "#microsoft.graph.commsNotification"
}
]
}
}
{
"HttpLogData": {
"Method": "POST",
"Url": "https://localhost:5001/callback",
"Headers": [
"Scenario-Id: 391018df-e558-47ca-a486-8ef4a4e5cc28",
"Client-Request-Id: 4a1f6389-6f4a-4897-9d80-037bce1f6f3b",
"X-Microsoft-Tenant: (redacted)"
],
"TransactionDirection": "Incoming",
"TraceType": "HttpRequest",
"TenantId": "00000000-0000-0000-0000-000000000000"
}
}

Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Executed action method Sample.VoiceRecorderAndPlaybackBot.Controller.PlatformCallController.OnIncomingBotCallUserRequestAsync (VoiceRecorderAndPlaybackBot), returned result Microsoft.AspNetCore.Mvc.EmptyResult in 887.0807ms.
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Executed action Sample.VoiceRecorderAndPlaybackBot.Controller.PlatformCallController.OnIncomingBotCallUserRequestAsync (VoiceRecorderAndPlaybackBot) in 890.2196ms
Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request finished in 895.0903ms 202
Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request starting HTTP/1.1 POST https://localhost:5001/callback application/json 1057
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Route matched with {action = "OnIncomingBotCallUserRequestAsync", controller = "PlatformCall"}. Executing controller action with signature System.Threading.Tasks.Task OnIncomingBotCallUserRequestAsync() on controller Sample.VoiceRecorderAndPlaybackBot.Controller.PlatformCallController (VoiceRecorderAndPlaybackBot).
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Executing action method Sample.VoiceRecorderAndPlaybackBot.Controller.PlatformCallController.OnIncomingBotCallUserRequestAsync (VoiceRecorderAndPlaybackBot) - Validation state: Valid
VoiceRecorderAndPlaybackBot:Information: 2024-01-13T13:58:38.2067Z 9e51871c-0e6c-46a0-9937-410cfc383c79 pid:16532 tid:15 (Bot.cs:270 NotificationProcessor_OnNotificationReceivedAsync):
{
"value": {
"$id": "1",
"$values": [
{
"changeType": "Deleted",
"resourceUrl": "/communications/calls/531f5700-70f1-4a22-ada2-f62f794c0dc7",
"resource": "/app/calls/531f5700-70f1-4a22-ada2-f62f794c0dc7",
"resourceData": {
"callChainId": "9e51871c-0e6c-46a0-9937-410cfc383c79",
"resultInfo": {
"code": 200,
"message": "The conversation has ended. DiagCode: 200#1000003.@",
"subcode": 1000003,
"@odata.type": "#microsoft.graph.resultInfo"
},
"state": "Terminated",
"@odata.type": "#microsoft.graph.call",
"meetingCapability": {
"@odata.type": "#microsoft.graph.meetingCapability",
"allowTranslatedCaptions": true,
"allowTranslatedTranscriptions": true,
"recorderAllowed": []
},
"meetingProperties": {
"@odata.type": "#microsoft.graph.meetingProperties",
"meetingLabel": "00000000-0000-0000-0000-000000000000"
},
"coOrganizers": [],
"terminationSender": {
"application": {
"id": "56aa0a8f-4cd3-446b-8146-0023476a5ff2",
"@odata.type": "#microsoft.graph.identity"
},
"@odata.type": "#microsoft.graph.identitySet"
}
},
"@odata.type": "#microsoft.graph.commsNotification"
}
]
}
}
{
"HttpLogData": {
"Method": "POST",
"Url": "https://localhost:5001/callback",
"Headers": [
"Scenario-Id: 9e51871c-0e6c-46a0-9937-410cfc383c79",
"Client-Request-Id: b688afd2-2920-4700-bf4c-82c6db9f276a",
"X-Microsoft-Tenant: (redacted)"
],
"TransactionDirection": "Incoming",
"TraceType": "HttpRequest",
"TenantId": "00000000-0000-0000-0000-000000000000"
}
}

VoiceRecorderAndPlaybackBot:Information: 2024-01-13T13:58:38.2124Z 9e51871c-0e6c-46a0-9937-410cfc383c79 pid:16532 tid:15 (Bot.cs:435 CleanupCall):
Cleaning up call

4 Replies
Hello @prasanth2023,
Thanks for reporting your issue. We will test this and update you soon.

Hello @prasanth2023,
Please refer to the documentation for configuration and creation of call from Teams user to PSTN.

yes the original code was implement by referring example 10, But its not working as expected. VOIP call work as per example 2 on the same link

Hello @prasanth2023 ,

The error was from entitlement service, indicating this app has not been set up properly for PSTN calling. It needs the PSTN license and phone number to be assigned to the application instance before it can start calling PSTN. Please follow the Example 9 on this page to set up the license.

Create call - Microsoft Graph v1.0 | Microsoft Learn