Skip to content

Commit 0c04e7a

Browse files
Merge pull request #286481 from sloanster/patch-21
Create pass-contextual-data-header.md
2 parents 54e348f + 8486218 commit 0c04e7a

File tree

3 files changed

+80
-84
lines changed

3 files changed

+80
-84
lines changed

articles/communication-services/how-tos/calling-sdk/call-context.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,34 @@
22
title: How to pass contextual data between calls
33
titleSuffix: An Azure Communication Services how-to guide
44
description: Use Azure Communication Services SDKs to pass contextual data between calls.
5-
author: aakanmu
6-
ms.author: aakanmu
5+
author: sloanster
6+
ms.author: micahvivion
77
ms.service: azure-communication-services
88
ms.subservice: calling
99
ms.topic: how-to
10-
ms.date: 05/14/2024
10+
ms.date: 09/13/2024
1111
ms.custom: template-how-to
1212
---
1313

14-
# Passing Contextual Information
14+
# Using the ACS calling SDK to pass contextual User-to-User Information (UUI) data between calls
1515

1616
In this article, you learn how to pass along custom contextual information when routing calls with Azure Communication Services Calling SDKs. This capability allows users to pass metadata about the call, callee, or any other information that is relevant to their application or business logic.
1717

18+
The Azure Communication Services (ACS) WebJS SDK provides developers to include custom contextual data (included as a header on the calling object) when directing and routing calls from one person to another. This information, also known as User-to-User Information (UUI) data or call control UUI data, is a small piece of data inserted by an application initiating the call. The UUI data is opaque to end users making a call.
19+
1820
Contextual information supported includes both freeform custom headers and the standard User-to-User Information (UUI) SIP header. Also when you receive an inbound call, the custom headers and UUI are included in the incomingCall payload.
1921

2022
All custom context data is opaque to Calling SDK or SIP protocols and its content is unrelated to any basic functions.
2123

22-
[!INCLUDE [Public Preview Disclaimer](../../includes/public-preview-include-document.md)]
24+
Developers can pass this context by using custom headers, which consist of optional key-value pairs. These pairs can be included in the 'AddParticipant' or 'Transfer' actions within the calling SDK. Once added, you can read the data payload as the call moves between endpoints. By efficiently looking up this metadata and associating it with the call, developers can avoid external database lookups and have the content information readily available within the call object.
25+
26+
The custom call context can be transmitted to SIP endpoints using the SIP protocol. This transmission includes both the custom headers and the standard User-to-User Information (UUI) SIP header. When an inbound call is routed from your telephony network, the data from your Session Border Controller (SBC) in the custom headers and UUI is also included in the IncomingCall event payload.
2327

24-
## Prerequisites
28+
It’s important to note that all custom context data remains transparent to the calling SDK and isn't related to any of the SDK’s fundamental functions when used in SIP protocols. Here's a tutorial to assist you in adding custom context headers when using the WebJS SDK.
2529

26-
- An Azure account with an active subscription. [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
27-
- A deployed Communication Services resource. [Create a Communication Services resource](../../quickstarts/create-communication-resource.md).
28-
- A user access token to enable the calling client. For more information, see [Create and manage access tokens](../../quickstarts/identity/access-tokens.md).
29-
- Optional: Complete the quickstart to [add voice calling to your application](../../quickstarts/voice-video-calling/getting-started-with-calling.md)
3030

31+
> [!IMPORTANT]
32+
> To use the ability to pass User-to-User Information (UUI) data using the calling SDK you must use the calling WebJS SDK GA or public preview version `1.29.1` or later.
3133
3234
[!INCLUDE [Passing Contextual Data - Client-side JavaScript](./includes/call-context/call-context-web.md)]
3335

Lines changed: 48 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,67 @@
11
---
2-
author: aakanmu
2+
author: sloanster
33
ms.service: azure-communication-services
44
ms.topic: include
5-
ms.date: 05/14/2024
6-
ms.author: aakanmu
5+
ms.date: 09/13/2024
6+
ms.author: micahvivion
77
---
8-
[!INCLUDE [Install SDK](../install-sdk/install-sdk-web.md)]
98

10-
## Place a call with contextual Information
9+
## Technical parameters
10+
The calling SDK supports adding up to 5 custom SIP headers and 1000 custom VOIP headers. Additionally, developers can include a dedicated User-To-User header as part of SIP headers list.
1111

12-
```js
13-
// Set up customContext
14-
this.callOptions.customContext = {
15-
userToUser: <USER_TO_USER_VALUE>,
16-
xHeaders: [
17-
{ key: <CUSTOM_HEADER_KEY>, value: <CUSTOM_HEADER_VALUE> },
18-
]
19-
};
20-
```
21-
For a "1:1" call to a user, use the following code:
12+
The maximum length of a SIP header key is 64 chars, including the X-MS-Custom prefix. Due note that when the SIP header is added the calling SDK will automatically add the ‘X-MS-Custom-’ prefix (which can be seeing if you inspect the SIP header with packet inspector).
2213

23-
```js
24-
const userId = { communicationUserId: 'ACS_USER_ID' };
25-
this.currentCall = this.callAgent.startCall([userId], this.callOptions);
26-
```
14+
The SIP header key may consist of alphanumeric characters and a few selected symbols which include `.`, `!`, `%`, `*`, `_`, `+`, `~`, `-`. The maximum length of SIP header value is 256 chars. The same limitations apply when configuring the SIP headers on your SBC. The SIP header value may consist of alphanumeric characters and a few selected symbols which include `=`, `;`, `.`, `!`, `%`, `*`, `_`, `+`, `~`, `-`.
2715

28-
To place a call to a public switched telephone network (PSTN), use the `startCall` method on `callAgent` and pass the recipient's `PhoneNumberIdentifier`. Your Communication Services resource must be configured to allow PSTN calling.
16+
The maximum length of a VOIP header key is 64 chars. The maximum length of VOIP header value is 1024 chars.
2917

30-
When you call a PSTN number, specify your alternate caller ID. An alternate caller ID is a phone number (based on the E.164 standard) that identifies the caller in a PSTN call. It's the phone number the call recipient sees for an incoming call.
31-
32-
For a 1:1 call to a PSTN number, use the following code:
33-
```js
34-
const phoneNumber = { phoneNumber: <ACS_PHONE_NUMBER> };
35-
this.callOptions.alternateCallerId = { phoneNumber: <ALTERNATE_CALLER_ID>}
36-
this.currentCall = this.callAgent.startCall([phoneNumber], this.callOptions);
37-
```
18+
When adding these custom headers as a developer you can choose to add only SIP headers, only VoIP headers or both can be included.
3819

3920
> [!NOTE]
40-
> Passing contextual information in group call and add participant scenarios are not supported
21+
> Currently, adding custom User-to-User Information headers is only supported when initiating a 1:1 call. Passing User-to-User Information headers in group calls is not currently supported. To work around this after starting the 1:1 call, you can include additional participants while maintaining the User-to-User Information within the calls.
4122
42-
## Receive an incoming call
4323

44-
The `callAgent` instance emits an `incomingCall` event when the logged-in identity receives an incoming call. To listen to this event and extract contextual info, subscribe by using one of these options:
24+
## Place a call with User-to-User Information (UUI) data
4525

4626
```js
47-
const incomingCallHandler = async (args: { incomingCall: IncomingCall }) => {
48-
const incomingCall = args.incomingCall;
49-
50-
// receiving customContext
51-
const customContext = args.incomingCall.customContext;
52-
53-
// Get incoming call ID
54-
var incomingCallId = incomingCall.id
55-
56-
// Get information about this Call. This API is provided as a preview for developers
57-
// and may change based on feedback that we receive. Do not use this API in a production environment.
58-
// To use this api please use 'beta' release of Azure Communication Services Calling Web SDK
59-
var callInfo = incomingCall.info;
60-
61-
// Get information about caller
62-
var callerInfo = incomingCall.callerInfo
27+
// Setting custom context UUI Headers
28+
const callOptions = {
29+
customContext: {
30+
voipHeaders: [
31+
{key: 'voip-key-1', value: 'voip-value-1'},
32+
{key: 'voip-key-2', value: 'voip-value-2'}
33+
],
34+
35+
sipHeaders: [
36+
{key: 'sip-key-1', value: 'sip-value-1'},
37+
{key: 'sip-key-2', value: 'sip-value-2'}
38+
],
39+
userToUser: 'userToUserHeader',
40+
},
41+
};
42+
});
43+
```
6344

64-
// Accept the call
65-
var call = await incomingCall.accept();
6645

67-
// Reject the call
68-
incomingCall.reject();
46+
## Read and parse User-to-User Information headers in a call
6947

70-
// Subscribe to callEnded event and get the call end reason
71-
incomingCall.on('callEnded', args => {
72-
console.log(args.callEndReason);
73-
});
48+
The `callAgent` instance emits an `incomingCall` event when the logged-in identity receives an incoming call. To listen to this event and extract contextual info, subscribe by using one of these options:
7449

75-
// callEndReason is also a property of IncomingCall
76-
var callEndReason = incomingCall.callEndReason;
77-
};
78-
callAgentInstance.on('incomingCall', incomingCallHandler);
79-
```
50+
```js
51+
let info = '';
52+
53+
callAgent.on("incomingCall", (args) => {
54+
const incomingCall = args.incomingCall;
55+
if (incomingCall.customContext) {
56+
if (incomingCall.customContext.userToUser) {
57+
info += `userToUser: '${incomingCall.customContext.userToUser}'\n`;
58+
}
59+
if (incomingCall.customContext.sipHeaders) {
60+
incomingCall.customContext.sipHeaders.forEach(header => info += `sip: ${header.key}: '${header.value}'\n`);
61+
}
62+
if (incomingCall.customContext.voipHeaders) {
63+
incomingCall.customContext.voipHeaders.forEach(header => info += `voip: ${header.key}: '${header.value}'\n`);
64+
}
65+
}
66+
});
67+
```

articles/communication-services/toc.yml

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -287,18 +287,7 @@ items:
287287
href: tutorials/building-app-start.md
288288
- name: Build an authentication service using Azure Functions
289289
href: tutorials/trusted-service-tutorial.md
290-
- name: Add video calling to your Android WebView client app
291-
href: quickstarts/voice-video-calling/get-started-android-webview.md
292-
- name: Using Event Grid to send calling push notifications
293-
href: tutorials/add-voip-push-notifications-event-grid.md
294-
- name: Proxy your calling traffic
295-
href: tutorials/proxy-calling-support-tutorial.md
296-
- name: Survey users
297-
href: tutorials/end-of-call-survey-tutorial.md
298-
displayName: diagnostics, Survey, feedback, quality, reliability, users, end, call, quick
299-
- name: Collecting user feedback with the mobile UI Library
300-
href: tutorials/collecting-user-feedback/collecting-user-feedback.md
301-
- name: Audio quality enhancements
290+
- name: Adding audio quality enhancements
302291
items:
303292
- name: Enabling audio effects
304293
href: tutorials/audio-quality-enhancements/add-noise-supression.md
@@ -364,15 +353,15 @@ items:
364353
href: how-tos/calling-sdk/closed-captions-teams-interop-how-to.md
365354
- name: Get local capabilities
366355
href: how-tos/calling-sdk/capabilities.md
367-
- name: Pass contextual information
356+
- name: Pass User-to-User Information (UUI) data in a header
368357
href: how-tos/calling-sdk/call-context.md
369358
- name: Call recording
370359
items:
371360
- name: Record a call
372361
href: quickstarts/voice-video-calling/get-started-call-recording.md
373362
- name: Record every call in the resource
374363
href: how-tos/call-automation/record-every-call.md
375-
- name: Editing media from the client
364+
- name: Editing audio and video media from the client
376365
items:
377366
- name: Access raw audio and video
378367
href: quickstarts/voice-video-calling/get-started-raw-media-access.md
@@ -415,6 +404,13 @@ items:
415404
- name: 3. Microphone and camera setup before a call
416405
href: tutorials/call-readiness/call-readiness-tutorial-part-3-camera-microphone-setup.md
417406
displayName: diagnostics, diagnose, feedback, quality, reliability, users, call, quick, satisfaction, improve, issues
407+
- name: Add end of call survey
408+
items:
409+
- name: Using the survey users API
410+
href: tutorials/end-of-call-survey-tutorial.md
411+
displayName: diagnostics, Survey, feedback, quality, reliability, users, end, call, quick
412+
- name: Collecting user feedback with the mobile UI Library
413+
href: tutorials/collecting-user-feedback/collecting-user-feedback.md
418414
- name: Migrating to Azure Communication Services
419415
items:
420416
- name: Migrate from Twilio Video to Azure Communication Services
@@ -469,6 +465,8 @@ items:
469465
href: how-tos/ui-library-sdk/troubleshooting.md
470466
- name: Events
471467
items:
468+
- name: Using Event Grid to send calling push notifications
469+
href: tutorials/add-voip-push-notifications-event-grid.md
472470
- name: View calling events
473471
href: quickstarts/voice-video-calling/handle-calling-events.md
474472
- name: Analytics
@@ -493,6 +491,14 @@ items:
493491
href: how-tos/calling-sdk/breakoutrooms.md
494492
- name: Together Mode
495493
href: how-tos/calling-sdk/together-mode.md
494+
- name: Configuring to proxy traffic
495+
items:
496+
- name: Proxy your calling traffic
497+
href: tutorials/proxy-calling-support-tutorial.md
498+
- name: Build a Webview based client
499+
items:
500+
- name: Add audio and video calling to your WebView application
501+
href: quickstarts/voice-video-calling/get-started-webview.md
496502
- name: Chat
497503
items:
498504
- name: Build an authentication service using Azure Functions

0 commit comments

Comments
 (0)