microsoft-teams

Make outbound Teams PSTN call - Azure Communication Services Teams Interoperability


I try to implement a PSTN call feature using Azure Communication Services Teams Interoperability referring this sample code and use case:

https://github.com/Azure-Samples/communication-services-javascript-quickstarts/tree/main/add-1-on-1-cte-video-calling https://learn.microsoft.com/en-us/azure/communication-services/concepts/interop/custom-teams-endpoint-use-cases#use-case-1-make-outbound-teams-pstn-call

I added the following code to the sample, but I got an error.

startPSTNButton.addEventListener('click',async () => {
    try {
        console.log('PSTN IN');
        const pstnCallee = { phoneNumber: '+81311112222' }
        const oneToOneCall = teamsCallAgent.startCall([pstnCallee], { threadId: '00000000-0000-0000-0000-000000000000' });

        console.log('Call out');
        // Subscribe to the call's properties and events.
        subscribeToCall(oneToOneCall);
    } catch (error) {
        console.error(error);
    }
});

Error:

CallingCommunicationError: Starting a one to one with thread ID is invalid.
    at TeamsCallAgentImpl.startCall (sdk.bundle.js:183:140138)
    at W.value (sdk.bundle.js:161:2267)
    at HTMLButtonElement. (client.js:311:1) (anonymous) @ client.js:317

Is threadId: '00000000-0000-0000-0000-000000000000' correct?
How to fix the error?


Solution

  • I found it out, and threadId is not required. https://github.com/Azure/Communication/blob/master/releasenotes/acs-javascript-calling-library-release-notes.md#170-beta1-2022-08-01

     const phoneCallee = { phoneNumber: '<PHONE_NUMBER_E164_FORMAT>' }
     const oneToOneCall = teamsCallAgent.startCall(phoneCallee );
    

    I try this, and it works fine.