Unable to add PSTN participant using Call Automation

Vikram Singh 0 Reputation points
2025-09-05T05:32:59.7866667+00:00

I am using Call Automation client to add the participant to a call.
Document to refererence - https://learn.microsoft.com/en-gb/azure/communication-services/how-tos/call-automation/actions-for-call-control?tabs=javascript#add-a-participant-to-a-call

Here is the process-

From number - +13097392188(Azure number )
to number - +19473451543(Azure Number)

Using Azure "Try Phone Calling" we are initiating a call from above number

Once call is ringing we are answering the call by subscribing to "IncomingCall Event"

const incomingCallContext = "<IncomingCallContext_From_IncomingCall_Event>"; 
const callbackUri = "https://<myendpoint>/Events"; 
const { callConnection } = await client.answerCall(incomingCallContext, callbackUri);

Once answered we are adding a participant using communicationUserId:

const customCallingContext = []; 
customContext.push({ kind: "voip", key: "voipHeaderName", value: "voipHeaderValue" })

const addThisPerson = {
    targetParticipant: { communicationUserId: "<acs_user_id>" },
    customCallingContext: customCallingContext,
};
const addParticipantResult = await callConnection.addParticipant(addThisPerson, {
            operationCallbackUrl: "<url_endpoint>",
            operationContext: "<operation_context>"
});

And using below at client side, we recieve the call at client side.

import {
  CallClient,
  CallAgentKind,
  } from '@azure/communication-calling';
import { AzureCommunicationTokenCredential, createIdentifierFromRawId } from '@azure/communication-common';


const tokenCredential = new AzureCommunicationTokenCredential("<TOKEN>");
        const callClient = new CallClient();
        console.log({ identity, token:"<TOKEN>", tokenCredential });
        const agent = await callClient.createCallAgent(tokenCredential, {
          kind: CallAgentKind.CommunicationUser,
});

window.deviceManager = await callClient.getDeviceManager();
const permissions = await window.deviceManager.askDevicePermission({ audio: true, video: false });


agent.on('incomingCall', async (args) => {
const call = args.incomingCall;
const callInstance = await call.accept();
})

This works perfectly fine!!

But when I try to add the PSTN number,
Getting error - "SourceCallerIdNumber or TeamsAppSource should be specified when calling or adding a PSTN number"

I am providing the sourcecallerID - <To Number defined above>


const addThisPerson = {
      targetParticipant: transferDestination,
      sourceCallIdNumber: '+19473451543',
      customCallingContext: [],
    };

  await callConnection.addParticipant(addThisPerson);

Can you help me out what I am missing while adding PSTN number?

Azure Communication Services

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.