次の方法で共有


呼び出し間でコンテキスト データを渡す方法

Call Automation を使用すると、開発者は呼び出しをルーティングするときにカスタムのコンテキスト情報を渡すことができます。 開発者は、通話、呼び出し先、またはそれらのアプリケーションやビジネス ロジックに関連するその他の情報に関するメタデータを渡すことができます。 これにより、企業はコンテキストを失うことについて心配することなく、ネットワーク全体で通話を管理し、ルーティングできます。

コンテキストはカスタム ヘッダーを指定することで渡します。 これらは、AddParticipant または Transfer アクションの一部として含めることができるキーと値のペアからなる任意のリストです。 コンテキストは後で、IncomingCall イベント ペイロードの一部として取得できます。

カスタムの通話コンテキストも SIP プロトコルに転送されます。これには、自由形式のカスタム ヘッダーと、標準 UUI (ユーザー間情報) SIP ヘッダーの両方が含まれます。 テレフォニー ネットワークからの受信呼び出しをルーティングするとき、カスタム ヘッダーと UUI の SBC からのデータ セットも同様に IncomingCall イベント ペイロードに含まれます。

カスタムのコンテキスト データはすべて、Call Automation に対しても SIP プロトコルに対しても不明瞭であり、その内容はいかなる基本機能にも関連しません。

以下は、Call Automation でカスタム コンテキスト ヘッダーの使用を開始する方法に関するサンプルです。

このガイドを最大限に活用するには、前提条件として次の記事を参照することをお勧めします。

  • Call Automation の概念ガイドでは、アクション イベント プログラミング モデルとイベント コールバックについて説明しています。
  • このガイドで使用している CommunicationUserIdentifier や PhoneNumberIdentifier などのユーザー識別子についての説明。

すべてのコード サンプルについて、client は示されている方法で作成できる CallAutomationClient オブジェクトであり、callConnection は、Answer または CreateCall 応答から取得される CallConnection オブジェクトです。 アプリケーションで受信するコールバック イベントから取得することもできます。

技術パラメーター

Call Automation では、最大 5 つのカスタム SIP ヘッダーと 1,000 個のカスタム VOIP ヘッダーがサポートされます。 さらに、開発者は SIP ヘッダー リストの一部として専用のユーザー間ヘッダーを含めることができます。

カスタム SIP ヘッダー キーは、必須の ‘X-MS-Custom-’ プレフィックスで始まる必要があります。 SIP ヘッダー キーの最大長は、X-MS-Custom プレフィックスを含めて 64 文字です。 SIP ヘッダー キーは、英数字と、.!%*_+~- など一部の特殊な記号で構成することができます。 SIP ヘッダー値の最大長は 256 文字です。 SBC で SIP ヘッダーを構成するときも、同じ制限が適用されます。 SIP ヘッダー値は、英数字と、=;.!%*_+~- など、一部の特殊な記号で構成することができます。

VOIP ヘッダー キーの最大長は 64 文字です。 これらのヘッダーは、‘x-MS-Custom’ プレフィックスなしで送信できます。 VOIP ヘッダー値の最大長は 1024 文字です。

参加者の招待時にカスタム コンテキストを追加する

// Invite a communication services user and include one VOIP header
var addThisPerson = new CallInvite(new CommunicationUserIdentifier("<user_id>"));
addThisPerson.CustomCallingContext.AddVoip("myHeader", "myValue");
AddParticipantsResult result = await callConnection.AddParticipantAsync(addThisPerson);
// Invite a PSTN user and set UUI and custom SIP headers
var callerIdNumber = new PhoneNumberIdentifier("+16044561234"); 
var addThisPerson = new CallInvite(new PhoneNumberIdentifier("+16041234567"), callerIdNumber);

// Set custom UUI header. This key is sent on SIP protocol as User-to-User
addThisPerson.CustomCallingContext.AddSipUui("value");

// This provided key will be automatically prefixed with X-MS-Custom on SIP protocol, such as 'X-MS-Custom-{key}'
addThisPerson.CustomCallingContext.AddSipX("header1", "customSipHeaderValue1");
AddParticipantsResult result = await callConnection.AddParticipantAsync(addThisPerson);

通話転送時にカスタム コンテキストを追加する

//Transfer to communication services user and include one VOIP header
var transferDestination = new CommunicationUserIdentifier("<user_id>"); 
var transferOption = new TransferToParticipantOptions(transferDestination);   
var transferOption = new TransferToParticipantOptions(transferDestination) {
    OperationContext = "<Your_context>",
    OperationCallbackUri = new Uri("<uri_endpoint>") // Sending event to a non-default endpoint.
};
transferOption.CustomCallingContext.AddVoip("customVoipHeader1", "customVoipHeaderValue1");
TransferCallToParticipantResult result = await callConnection.TransferCallToParticipantAsync(transferOption);

//Transfer a PSTN call to phone number and set UUI and custom SIP headers
var transferDestination = new PhoneNumberIdentifier("<target_phoneNumber>");
var transferOption = new TransferToParticipantOptions(transferDestination);
transferOption.CustomCallingContext.AddSipUui("uuivalue");
transferOption.CustomCallingContext.AddSipX("header1", "headerValue");
TransferCallToParticipantResult result = await callConnection.TransferCallToParticipantAsync(transferOption)

着信呼び出しイベントからカスタム コンテキストを読み取る

AcsIncomingCallEventData incomingEvent = <incoming call event from Event Grid>;
// Retrieve incoming call custom context
AcsIncomingCallCustomContext callCustomContext = incomingEvent.CustomContext;

// Inspect dictionary with key/value pairs
var voipHeaders = callCustomContext.VoipHeaders;
var sipHeaders = callCustomContext.SipHeaders;

// Get SIP UUI header value
var userToUser = sipHeaders["user-To-User"]

// Proceed to answer or reject call as usual

その他のリソース