Forum Discussion
xddenise
Apr 23, 2025Copper Contributor
Notifications not received at callback uri for bot
Hi,
I am trying to implement an app (acting as the bot) outside of teams client to received call notifications for incoming calls and direct them to appropriate agent based on business logic.
- I have the app registration and bot registration set up.
- For the bot, I have the teams channel set up with the calling webhook url set to my ngrok url, which tunnels to my local app.
- I am able to make outbound call with graph api to an internal user by specifying the userId in invitationParticipantInfo.
- I am also able to make inbound call from internal user to the bot through teams client by directly clicking on the call button for the bot.
- I can receive the callback notifications at the registered ngrok url in both cases.
- I have two resource accounts, a call queue and a ivr. Both have phone numbers assigned to them.
Things I am stuck on:
- making an outbound call to PSTN from my app (https://learn.microsoft.com/en-us/graph/api/application-post-calls?view=graph-rest-1.0&tabs=http#example-9-create-peer-to-peer-pstn-call-with-service-hosted-media)
- making an outbound call on behalf of a queue to PSTN from my app
- receiving incoming call notification at my app when PSTN calls a resource account (queue or ivr) or a user
Things I tried:
- I tried setting the source in Call object to the following, with id being queue account id, ivr account id, user account id, but all of them gave me an error "Call source identity invalid." with code "7507" and responseStatusCode "403".
// initializing graph client
ClientSecretCredential credential = new ClientSecretCredentialBuilder()
.clientId(CLIENT_ID)
.clientSecret(CLIENT_SECRET)
.tenantId(TENANT_ID)
.build();
GraphServiceClient graphClient = new GraphServiceClient(credential, "https://graph.microsoft.com/.default");
Call call = new Call();
// setting source
ParticipantInfo source = new ParticipantInfo();
IdentitySet appIdentitySet = new IdentitySet();
HashMap<String, Object> additionalData = new HashMap<String, Object>();
Identity applicationInstance = new Identity();
applicationInstance.setDisplayName("Calling Bot");
applicationInstance.setId(<some id>);
additionalData.put("applicationInstance", applicationInstance);
appIdentitySet.setAdditionalData(additionalData);
source.setIdentity(appIdentitySet);
call.setSource(source);
// setting target
LinkedList<InvitationParticipantInfo> targets = new LinkedList<>();
InvitationParticipantInfo invitationParticipantInfo = new InvitationParticipantInfo();
IdentitySet phoneIdentitySet = new IdentitySet();
HashMap<String, Object> additionalDataForPhone = new HashMap<>();
Identity phone = new Identity();
phone.setId("+12223334444");
additionalDataForPhone.put("phone", phone);
phoneIdentitySet.setAdditionalData(additionalDataForPhone);
invitationParticipantInfo.setIdentity(phoneIdentitySet);
targets.add(invitationParticipantInfo);
call.setTargets(targets);
// additional fields
call.setCallbackUri("https://<domain>.ngrok-free.app/api/callbacks");
LinkedList<Modality> requestedModalities = new LinkedList<>();
equestedModalities.add(Modality.Audio);
call.setRequestedModalities(requestedModalities);
ServiceHostedMediaConfig mediaConfig = new ServiceHostedMediaConfig();
call.setMediaConfig(mediaConfig);
call.setTenantId(TENANT_ID);
// making the call
Call result = graphClient.communications().calls().post(call);
Questions:
- Which part of the configuration am I missing? I'm suspecting that it's because my bot is not linked to a resource account. There are some powershell commands that I'm supposed to run as part of the set up, which I didn't because of some company configuration that doesn't allow me to do it. I think creating the resource account in teams admin center is equivalent of creating an application instance. I would like to know whether this is indeed the problem. If it is due to not linking the app to my resource accounts, how do I do it without powershell? I can't find documentation online about it.
- Is it possible to receive incoming call notifications at my app that's linked to ngrok when the incoming call is for a specific user?
Any help is appreciated! Thank you!
4 Replies
Sort By
- Prasad_Das-MSFT
Microsoft
The error Call source identity invalid with code 7507 and response status 403 indicates that the source identity is not properly configured. This is likely because the bot is not linked to a resource account or does not have the required permissions.
A resource account is required for PSTN calls. The resource account acts as the identity for the bot when making calls. Linking a resource account to your app without using PowerShell can be challenging, as Microsoft Teams typically relies on PowerShell commands (e.g., Set-CsOnlineApplicationInstance) for such configurations.
- xddeniseCopper Contributor
Thanks Prasad! Could you explain the challenging way of linking them?
- Prasad_Das-MSFT
Microsoft
Resource accounts are typically created and managed using PowerShell commands (e.g., New-CsOnlineApplicationInstance), but since you cannot use PowerShell due to company restrictions, you can try the following:
-
- Teams Admin Center:
- Go to Teams Admin Center > Voice > Resource Accounts.
- Create a new resource account and assign it a phone number.
- Assign the Microsoft Teams Phone Resource Account license to the resource account.
- Link the Bot to the Resource Account:
- In the Azure AD App Registration for your bot, ensure that the bot's Application ID is linked to the resource account. This step typically requires PowerShell (Set-CsOnlineApplicationInstance), but you may need to work with your IT admin to complete this step.
- Teams Admin Center:
-