This repository has been archived by the owner on Jan 15, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 82
Adding Telephony preview package, this includes Call Transfer Activit… #942
Merged
carlosscastro
merged 7 commits into
microsoft:feature/telephony
from
vanshu86:vasinha/telephonypackage
Apr 23, 2021
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0b9b6d2
Adding Telephony preview package, this includes Call Transfer Activit…
410c06f
addressing comments/error handling/stylecop issues
d45c6d9
Revert "addressing comments/error handling/stylecop issues"
d9b414b
updates based on comments/stylecop and throwing errors
36cc7ff
Merge branch 'main' into vasinha/telephonypackage
479664c
moving to Telephony folder
bf6ff17
updating solution too
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
packages/Microsoft.Bot.Components.Telephony/Actions/CallTransfer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
namespace Microsoft.Bot.Components.Telephony.Actions | ||
{ | ||
using System.Runtime.CompilerServices; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using AdaptiveExpressions.Properties; | ||
using Microsoft.Bot.Builder; | ||
using Microsoft.Bot.Builder.Dialogs; | ||
using Newtonsoft.Json; | ||
|
||
/// <summary> | ||
/// Transfers call to given phone number. | ||
/// </summary> | ||
public class CallTransfer : Dialog | ||
{ | ||
/// <summary> | ||
/// Class identifier. | ||
/// </summary> | ||
[JsonProperty("$kind")] | ||
public const string Kind = "Microsoft.Telephony.CallTransfer"; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="CallTransfer"/> class. | ||
/// </summary> | ||
/// <param name="sourceFilePath">Optional, source file full path.</param> | ||
/// <param name="sourceLineNumber">Optional, line number in source file.</param> | ||
[JsonConstructor] | ||
public CallTransfer([CallerFilePath] string sourceFilePath = "", [CallerLineNumber] int sourceLineNumber = 0) | ||
: base() | ||
{ | ||
// enable instances of this command as debug break point | ||
this.RegisterSourceLocation(sourceFilePath, sourceLineNumber); | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets the phone number to be included when sending the handoff activity. | ||
/// </summary> | ||
/// <value> | ||
/// <see cref="StringExpression"/>. | ||
/// </value> | ||
[JsonProperty("phoneNumber")] | ||
public StringExpression PhoneNumber { get; set; } | ||
|
||
/// <summary> | ||
/// Called when the dialog is started and pushed onto the dialog stack. | ||
/// </summary> | ||
/// <param name="dc">The <see cref="DialogContext"/> for the current turn of conversation.</param> | ||
/// <param name="options">Optional, initial information to pass to the dialog.</param> | ||
/// <param name="cancellationToken">A cancellation token that can be used by other objects | ||
/// or threads to receive notice of cancellation.</param> | ||
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns> | ||
public async override Task<DialogTurnResult> BeginDialogAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default(CancellationToken)) | ||
{ | ||
var phoneNumber = this.PhoneNumber?.GetValue(dc.State); | ||
|
||
// Create handoff event, passing the phone number to transfer to as context. | ||
var context = new { TargetPhoneNumber = phoneNumber }; | ||
var handoffEvent = EventFactory.CreateHandoffInitiation(dc.Context, context); | ||
await dc.Context.SendActivityAsync(handoffEvent, cancellationToken).ConfigureAwait(false); | ||
return await dc.EndDialogAsync(result: null, cancellationToken: cancellationToken).ConfigureAwait(false); | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
packages/Microsoft.Bot.Components.Telephony/Microsoft.Bot.Components.Telephony.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Library</OutputType> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<PackageId>Microsoft.Bot.Components.Telephony</PackageId> | ||
<VersionPrefix>1.0.0-preview</VersionPrefix> | ||
<Description>This library implements .NET support for adaptive dialogs with Telephony.</Description> | ||
<Summary>This library implements .NET support for adaptive dialogs with Telephony.</Summary> | ||
<SignAssembly>true</SignAssembly> | ||
<AssemblyOriginatorKeyFile>..\..\build\35MSSharedLib1024.snk</AssemblyOriginatorKeyFile> | ||
<DelaySign>true</DelaySign> | ||
<ContentTargetFolders>content</ContentTargetFolders> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Bot.Builder.Dialogs.Adaptive.Runtime" Version="4.13.0" /> | ||
|
||
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.333"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="**/*.dialog" /> | ||
<Content Include="**/*.lg" /> | ||
<Content Include="**/*.lu" /> | ||
<Content Include="**/*.schema" /> | ||
<Content Include="**/*.uischema" /> | ||
<Content Include="**/*.qna" /> | ||
</ItemGroup> | ||
|
||
<PropertyGroup> | ||
<!-- Disable warning for SA0001 "XML comment analysis is disabled due to project configuration" which is not true --> | ||
<!-- Disable warning for SA1649 "file name should match first type name" due to use of generics --> | ||
<NoWarn>$(NoWarn),SA0001,SA1649</NoWarn> | ||
</PropertyGroup> | ||
|
||
</Project> |
21 changes: 21 additions & 0 deletions
21
packages/Microsoft.Bot.Components.Telephony/Schemas/Microsoft.Telephony.CallTransfer.schema
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"$schema": "https://schemas.botframework.com/schemas/component/v1.0/component.schema", | ||
"$role": "implements(Microsoft.IDialog)", | ||
"title": "Call Transfer", | ||
"description": "Phone number to transfer the call to (in E.164 format such as +1425123456)", | ||
"type": "object", | ||
"required": [ | ||
"phoneNumber" | ||
], | ||
"additionalProperties": false, | ||
"properties": { | ||
"phoneNumber": { | ||
"$ref": "schema:#/definitions/stringExpression", | ||
"title": "Phone Number", | ||
"description": "Phone number to transfer the call to.", | ||
"examples": [ | ||
"in E.164 format such as +1425123456" | ||
] | ||
} | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...ages/Microsoft.Bot.Components.Telephony/Schemas/Microsoft.Telephony.CallTransfer.uischema
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"$schema": "https://schemas.botframework.com/schemas/ui/v1.0/ui.schema", | ||
"form": { | ||
"label": "Transfer a call", | ||
"subtitle": "Call Transfer", | ||
"order": [ | ||
"phoneNumber", | ||
"*" | ||
], | ||
"properties": { | ||
"phoneNumber": { | ||
"intellisenseScopes": [ | ||
"variable-scopes" | ||
] | ||
} | ||
} | ||
}, | ||
"menu": { | ||
"label": "Transfer a call", | ||
"submenu": [ "Channels", "Telephony" ] | ||
}, | ||
"flow": { | ||
"widget": "ActionCard", | ||
"body": "=action.phoneNumber" | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
packages/Microsoft.Bot.Components.Telephony/TelephonyBotComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
namespace Microsoft.Bot.Components.Telephony | ||
{ | ||
using Microsoft.Bot.Builder; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. usings outside |
||
using Microsoft.Bot.Builder.Dialogs.Declarative; | ||
using Microsoft.Bot.Components.Telephony.Actions; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
/// <summary> | ||
/// Telephony actions registration. | ||
/// </summary> | ||
public class TelephonyBotComponent : BotComponent | ||
{ | ||
/// <inheritdoc/> | ||
public override void ConfigureServices(IServiceCollection services, IConfiguration configuration) | ||
{ | ||
// Conditionals | ||
services.AddSingleton<DeclarativeType>(sp => new DeclarativeType<CallTransfer>(CallTransfer.Kind)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usings should go outside of the namespace