Skip to content

Commit 5b74ccd

Browse files
authored
Add Teams CallDetails custom context support (Azure#49784)
* Add Teams CallDetails custom context support * Updated the CallConnectionTests * Make all properties in TeamsPhone*Details classes publicly settable * Adding a null check for internalEvent.CustomEvent in case of non Pstn events * Updatng the Incoming Call Context null check * Added the Teams Call Context in Incoming Call * Updated the TeamsPhoneCallDetails and TeamsPhoneSourceDetails public constructors * Update Models to accept TeamsPhoneCallDetails and add helper to convert to internal format * Addressed the PR comments
1 parent b6b38c1 commit 5b74ccd

29 files changed

+1185
-32
lines changed

sdk/communication/Azure.Communication.CallAutomation/api/Azure.Communication.CallAutomation.net8.0.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,10 +823,12 @@ public partial class CustomCallingContext
823823
{
824824
internal CustomCallingContext() { }
825825
public System.Collections.Generic.IDictionary<string, string> SipHeaders { get { throw null; } }
826+
public Azure.Communication.CallAutomation.TeamsPhoneCallDetails TeamsPhoneCallDetails { get { throw null; } }
826827
public System.Collections.Generic.IDictionary<string, string> VoipHeaders { get { throw null; } }
827828
public void AddSipUui(string value) { }
828829
public void AddSipX(string key, string value, Azure.Communication.CallAutomation.CustomCallingContext.SipHeaderPrefix prefix = Azure.Communication.CallAutomation.CustomCallingContext.SipHeaderPrefix.XMSCustom) { }
829830
public void AddVoip(string key, string value) { }
831+
public void SetTeamsPhoneCallDetails(Azure.Communication.CallAutomation.TeamsPhoneCallDetails teamsPhoneCallDetails) { }
830832
public enum SipHeaderPrefix
831833
{
832834
XMSCustom = 0,
@@ -1883,6 +1885,39 @@ public TeamsExtensionUserIdentifierModel(string userId, string tenantId, string
18831885
public string TenantId { get { throw null; } set { } }
18841886
public string UserId { get { throw null; } set { } }
18851887
}
1888+
public partial class TeamsPhoneCallDetails
1889+
{
1890+
public TeamsPhoneCallDetails() { }
1891+
public string CallContext { get { throw null; } set { } }
1892+
public string CallSentiment { get { throw null; } set { } }
1893+
public string CallTopic { get { throw null; } set { } }
1894+
public string Intent { get { throw null; } set { } }
1895+
public string SessionId { get { throw null; } set { } }
1896+
public string SuggestedActions { get { throw null; } set { } }
1897+
public Azure.Communication.CallAutomation.TeamsPhoneCallerDetails TeamsPhoneCallerDetails { get { throw null; } set { } }
1898+
public Azure.Communication.CallAutomation.TeamsPhoneSourceDetails TeamsPhoneSourceDetails { get { throw null; } set { } }
1899+
public string TranscriptUrl { get { throw null; } set { } }
1900+
}
1901+
public partial class TeamsPhoneCallerDetails
1902+
{
1903+
public TeamsPhoneCallerDetails(Azure.Communication.CommunicationIdentifier caller, string name, string phoneNumber) { }
1904+
public System.Collections.Generic.IDictionary<string, string> AdditionalCallerInformation { get { throw null; } }
1905+
public bool? IsAuthenticated { get { throw null; } set { } }
1906+
public string Name { get { throw null; } set { } }
1907+
public string PhoneNumber { get { throw null; } set { } }
1908+
public string RecordId { get { throw null; } set { } }
1909+
public string ScreenPopUrl { get { throw null; } set { } }
1910+
public bool AddAdditionalCallerInformation(string key, string value) { throw null; }
1911+
}
1912+
public partial class TeamsPhoneSourceDetails
1913+
{
1914+
public TeamsPhoneSourceDetails(Azure.Communication.CommunicationIdentifier source, string language, string status) { }
1915+
public System.Collections.Generic.IDictionary<string, Azure.Communication.CommunicationIdentifier> IntendedTargets { get { throw null; } }
1916+
public string Language { get { throw null; } set { } }
1917+
public Azure.Communication.CommunicationIdentifier Source { get { throw null; } set { } }
1918+
public string Status { get { throw null; } set { } }
1919+
public bool AddIntendedTargets(string key, Azure.Communication.CommunicationIdentifier target) { throw null; }
1920+
}
18861921
public enum TextFormat
18871922
{
18881923
Display = 0,

sdk/communication/Azure.Communication.CallAutomation/api/Azure.Communication.CallAutomation.netstandard2.0.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,10 +822,12 @@ public partial class CustomCallingContext
822822
{
823823
internal CustomCallingContext() { }
824824
public System.Collections.Generic.IDictionary<string, string> SipHeaders { get { throw null; } }
825+
public Azure.Communication.CallAutomation.TeamsPhoneCallDetails TeamsPhoneCallDetails { get { throw null; } }
825826
public System.Collections.Generic.IDictionary<string, string> VoipHeaders { get { throw null; } }
826827
public void AddSipUui(string value) { }
827828
public void AddSipX(string key, string value, Azure.Communication.CallAutomation.CustomCallingContext.SipHeaderPrefix prefix = Azure.Communication.CallAutomation.CustomCallingContext.SipHeaderPrefix.XMSCustom) { }
828829
public void AddVoip(string key, string value) { }
830+
public void SetTeamsPhoneCallDetails(Azure.Communication.CallAutomation.TeamsPhoneCallDetails teamsPhoneCallDetails) { }
829831
public enum SipHeaderPrefix
830832
{
831833
XMSCustom = 0,
@@ -1882,6 +1884,39 @@ public TeamsExtensionUserIdentifierModel(string userId, string tenantId, string
18821884
public string TenantId { get { throw null; } set { } }
18831885
public string UserId { get { throw null; } set { } }
18841886
}
1887+
public partial class TeamsPhoneCallDetails
1888+
{
1889+
public TeamsPhoneCallDetails() { }
1890+
public string CallContext { get { throw null; } set { } }
1891+
public string CallSentiment { get { throw null; } set { } }
1892+
public string CallTopic { get { throw null; } set { } }
1893+
public string Intent { get { throw null; } set { } }
1894+
public string SessionId { get { throw null; } set { } }
1895+
public string SuggestedActions { get { throw null; } set { } }
1896+
public Azure.Communication.CallAutomation.TeamsPhoneCallerDetails TeamsPhoneCallerDetails { get { throw null; } set { } }
1897+
public Azure.Communication.CallAutomation.TeamsPhoneSourceDetails TeamsPhoneSourceDetails { get { throw null; } set { } }
1898+
public string TranscriptUrl { get { throw null; } set { } }
1899+
}
1900+
public partial class TeamsPhoneCallerDetails
1901+
{
1902+
public TeamsPhoneCallerDetails(Azure.Communication.CommunicationIdentifier caller, string name, string phoneNumber) { }
1903+
public System.Collections.Generic.IDictionary<string, string> AdditionalCallerInformation { get { throw null; } }
1904+
public bool? IsAuthenticated { get { throw null; } set { } }
1905+
public string Name { get { throw null; } set { } }
1906+
public string PhoneNumber { get { throw null; } set { } }
1907+
public string RecordId { get { throw null; } set { } }
1908+
public string ScreenPopUrl { get { throw null; } set { } }
1909+
public bool AddAdditionalCallerInformation(string key, string value) { throw null; }
1910+
}
1911+
public partial class TeamsPhoneSourceDetails
1912+
{
1913+
public TeamsPhoneSourceDetails(Azure.Communication.CommunicationIdentifier source, string language, string status) { }
1914+
public System.Collections.Generic.IDictionary<string, Azure.Communication.CommunicationIdentifier> IntendedTargets { get { throw null; } }
1915+
public string Language { get { throw null; } set { } }
1916+
public Azure.Communication.CommunicationIdentifier Source { get { throw null; } set { } }
1917+
public string Status { get { throw null; } set { } }
1918+
public bool AddIntendedTargets(string key, Azure.Communication.CommunicationIdentifier target) { throw null; }
1919+
}
18851920
public enum TextFormat
18861921
{
18871922
Display = 0,

sdk/communication/Azure.Communication.CallAutomation/src/CallAutomationClient.cs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,8 @@ private AnswerCallRequestInternal CreateAnswerCallRequest(AnswerCallOptions opti
259259
request.OperationContext = options.OperationContext;
260260
request.CustomCallingContext = new CustomCallingContextInternal(
261261
options.CustomCallingContext?.VoipHeaders ?? new ChangeTrackingDictionary<string, string>(),
262-
options.CustomCallingContext?.SipHeaders ?? new ChangeTrackingDictionary<string, string>());
262+
options.CustomCallingContext?.SipHeaders ?? new ChangeTrackingDictionary<string, string>(),
263+
CustomCallContextHelpers.CreateTeamsPhoneCallDetailsInternal(options.CustomCallingContext?.TeamsPhoneCallDetails));
263264

264265
return request;
265266
}
@@ -295,8 +296,9 @@ public virtual async Task<Response> RedirectCallAsync(RedirectCallOptions option
295296
RedirectCallRequestInternal request = new RedirectCallRequestInternal(options.IncomingCallContext, CommunicationIdentifierSerializer.Serialize(options.CallInvite.Target));
296297

297298
request.CustomCallingContext = new CustomCallingContextInternal(
298-
options.CallInvite.CustomCallingContext.VoipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CallInvite.CustomCallingContext.VoipHeaders,
299-
options.CallInvite.CustomCallingContext.SipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CallInvite.CustomCallingContext.SipHeaders);
299+
options.CallInvite?.CustomCallingContext?.VoipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CallInvite?.CustomCallingContext?.VoipHeaders,
300+
options.CallInvite?.CustomCallingContext?.SipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CallInvite?.CustomCallingContext?.SipHeaders,
301+
CustomCallContextHelpers.CreateTeamsPhoneCallDetailsInternal(options.CallInvite?.CustomCallingContext?.TeamsPhoneCallDetails));
300302

301303
return await AzureCommunicationServicesRestClient.RedirectCallAsync(request, cancellationToken).ConfigureAwait(false);
302304
}
@@ -338,8 +340,9 @@ public virtual Response RedirectCall(RedirectCallOptions options, CancellationTo
338340
RedirectCallRequestInternal request = new RedirectCallRequestInternal(options.IncomingCallContext, CommunicationIdentifierSerializer.Serialize(options.CallInvite.Target));
339341

340342
request.CustomCallingContext = new CustomCallingContextInternal(
341-
options.CallInvite.CustomCallingContext.VoipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CallInvite.CustomCallingContext.VoipHeaders,
342-
options.CallInvite.CustomCallingContext.SipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CallInvite.CustomCallingContext.SipHeaders);
343+
options.CallInvite?.CustomCallingContext?.VoipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CallInvite.CustomCallingContext.VoipHeaders,
344+
options.CallInvite?.CustomCallingContext?.SipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CallInvite.CustomCallingContext.SipHeaders,
345+
CustomCallContextHelpers.CreateTeamsPhoneCallDetailsInternal(options.CallInvite?.CustomCallingContext?.TeamsPhoneCallDetails));
343346

344347
return AzureCommunicationServicesRestClient.RedirectCall(request, cancellationToken);
345348
}
@@ -729,8 +732,9 @@ private CreateCallRequestInternal CreateCallRequest(CreateCallOptions options)
729732
};
730733

731734
request.CustomCallingContext = new CustomCallingContextInternal(
732-
options.CallInvite.CustomCallingContext.VoipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CallInvite.CustomCallingContext.VoipHeaders,
733-
options.CallInvite.CustomCallingContext.SipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CallInvite.CustomCallingContext.SipHeaders);
735+
options.CallInvite?.CustomCallingContext?.VoipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CallInvite?.CustomCallingContext?.VoipHeaders,
736+
options.CallInvite?.CustomCallingContext?.SipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CallInvite.CustomCallingContext.SipHeaders,
737+
CustomCallContextHelpers.CreateTeamsPhoneCallDetailsInternal(options.CallInvite?.CustomCallingContext?.TeamsPhoneCallDetails));
734738

735739
// Add CallIntelligenceOptions such as custom cognitive service domain name
736740
string cognitiveServicesEndpoint = options.CallIntelligenceOptions?.CognitiveServicesEndpoint?.AbsoluteUri;
@@ -766,8 +770,9 @@ private CreateCallRequestInternal CreateCallRequest(CreateGroupCallOptions optio
766770
};
767771

768772
request.CustomCallingContext = new CustomCallingContextInternal(
769-
options.CustomCallingContext.VoipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CustomCallingContext.VoipHeaders,
770-
options.CustomCallingContext.SipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CustomCallingContext.SipHeaders);
773+
options.CustomCallingContext?.VoipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CustomCallingContext?.VoipHeaders,
774+
options.CustomCallingContext?.SipHeaders == null ? new ChangeTrackingDictionary<string, string>() : options.CustomCallingContext?.SipHeaders,
775+
CustomCallContextHelpers.CreateTeamsPhoneCallDetailsInternal(options.CustomCallingContext?.TeamsPhoneCallDetails));
771776

772777
// Add CallIntelligenceOptions such as custom cognitive service domain name
773778
string cognitiveServicesEndpoint = options.CallIntelligenceOptions?.CognitiveServicesEndpoint?.AbsoluteUri;

sdk/communication/Azure.Communication.CallAutomation/src/CallConnection.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,8 @@ private static TransferToParticipantRequestInternal CreateTransferToParticipantR
284284
{
285285
CustomCallingContext = new CustomCallingContextInternal(
286286
options.CustomCallingContext?.VoipHeaders ?? new ChangeTrackingDictionary<string, string>(),
287-
options.CustomCallingContext?.SipHeaders ?? new ChangeTrackingDictionary<string, string>()),
287+
options.CustomCallingContext?.SipHeaders ?? new ChangeTrackingDictionary<string, string>(),
288+
CustomCallContextHelpers.CreateTeamsPhoneCallDetailsInternal(options.CustomCallingContext?.TeamsPhoneCallDetails)),
288289
OperationContext = options.OperationContext == default ? Guid.NewGuid().ToString() : options.OperationContext,
289290
Transferee = options.Transferee == default ? null : CommunicationIdentifierSerializer.Serialize(options.Transferee),
290291
OperationCallbackUri = options.OperationCallbackUri?.AbsoluteUri,
@@ -387,8 +388,8 @@ private static AddParticipantRequestInternal CreateAddParticipantRequest(AddPart
387388
{
388389
CustomCallingContext = new CustomCallingContextInternal(
389390
options.ParticipantToAdd.CustomCallingContext?.VoipHeaders ?? new ChangeTrackingDictionary<string, string>(),
390-
options.ParticipantToAdd.CustomCallingContext?.SipHeaders ?? new ChangeTrackingDictionary<string, string>()
391-
),
391+
options.ParticipantToAdd.CustomCallingContext?.SipHeaders ?? new ChangeTrackingDictionary<string, string>(),
392+
CustomCallContextHelpers.CreateTeamsPhoneCallDetailsInternal(options.ParticipantToAdd.CustomCallingContext?.TeamsPhoneCallDetails)),
392393
SourceCallerIdNumber = options.ParticipantToAdd.SourceCallerIdNumber == null
393394
? null
394395
: new PhoneNumberIdentifierModel(options.ParticipantToAdd.SourceCallerIdNumber.PhoneNumber),

0 commit comments

Comments
 (0)