-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Telephony preview package, this includes Call Transfer Activit…
…y currently and it will be a place for all telephony extentions for composer
- Loading branch information
Vanshika Sinha
committed
Apr 20, 2021
1 parent
43c35ce
commit 0b9b6d2
Showing
6 changed files
with
174 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
packages/Microsoft.Bot.Components.Telephony/Actions/CallTransferDialog.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,53 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using AdaptiveExpressions.Properties; | ||
using Microsoft.Bot.Builder; | ||
using Microsoft.Bot.Builder.Dialogs; | ||
using Newtonsoft.Json; | ||
using System.Runtime.CompilerServices; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Microsoft.Bot.Components.Telephony.Actions | ||
{ | ||
public class CallTransferDialog : Dialog | ||
{ | ||
[JsonConstructor] | ||
public CallTransferDialog([CallerFilePath] string sourceFilePath = "", [CallerLineNumber] int sourceLineNumber = 0) | ||
: base() | ||
{ | ||
// enable instances of this command as debug break point | ||
this.RegisterSourceLocation(sourceFilePath, sourceLineNumber); | ||
} | ||
|
||
[JsonProperty("$kind")] | ||
public const string Kind = "CallTransferDialog"; | ||
|
||
[JsonProperty("targetPhoneNumber")] | ||
public StringExpression TargetPhoneNumber { get; set; } | ||
|
||
public async override Task<DialogTurnResult> BeginDialogAsync(DialogContext dc, object options = null, CancellationToken cancellationToken = default(CancellationToken)) | ||
{ | ||
var targetPhoneNumber = TargetPhoneNumber.GetValue(dc.State); | ||
|
||
await dc.Context.SendActivityAsync($"Transferring to \"{targetPhoneNumber}\"..."); | ||
|
||
// Create handoff event, passing the phone number to transfer to as context. | ||
var poContext = new { TargetPhoneNumber = targetPhoneNumber }; | ||
var poHandoffEvent = EventFactory.CreateHandoffInitiation(dc.Context, poContext); | ||
|
||
try | ||
{ | ||
await dc.Context.SendActivityAsync(poHandoffEvent, cancellationToken); | ||
await dc.Context.SendActivityAsync($"Call transfer initiation succeeded"); | ||
} | ||
catch | ||
{ | ||
await dc.Context.SendActivityAsync($"Call transfer failed"); | ||
} | ||
|
||
return await dc.EndDialogAsync(result: 0, cancellationToken: cancellationToken); | ||
} | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
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,50 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<Version Condition=" '$(PreviewPackageVersion)' == '' ">$(LocalPackageVersion)</Version> | ||
<Version Condition=" '$(PreviewPackageVersion)' != '' ">$(PreviewPackageVersion)</Version> | ||
<PackageVersion Condition=" '$(PreviewPackageVersion)' == '' ">$(LocalPackageVersion)</PackageVersion> | ||
<PackageVersion Condition=" '$(PreviewPackageVersion)' != '' ">$(PreviewPackageVersion)</PackageVersion> | ||
<Configurations>Debug;Release</Configurations> | ||
<DocumentationFile>bin\$(Configuration)\netstandard2.0\Microsoft.Bot.Builder.Dialogs.Adaptive.xml</DocumentationFile> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<PackageId>Microsoft.Bot.Components.Telephony</PackageId> | ||
<Description>This library implements .NET support for adaptive dialogs with Telephony</Description> | ||
<Summary>This library implements .NET support for adaptive dialogs with Microsoft Telephony</Summary> | ||
<ContentTargetFolders>content</ContentTargetFolders> | ||
<PackageTags>msbot-action;msbot-trigger;msbot-component</PackageTags> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> | ||
<DebugType>Full</DebugType> | ||
<DebugSymbols>true</DebugSymbols> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<!-- These documentation warnings excludes should be removed as part of https:/microsoft/botbuilder-dotnet/issues/4052 --> | ||
<NoWarn>$(NoWarn);CS1591</NoWarn> | ||
<Version>1.0.0-preview</Version> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="**/*.dialog" /> | ||
<Content Include="**/*.lg" /> | ||
<Content Include="**/*.lu" /> | ||
<Content Include="**/*.schema" /> | ||
<Content Include="**/*.uischema" /> | ||
<Content Include="**/*.qna" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Remove="Schemas\CallTransferDialog.schema" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Bot.Builder.Dialogs.Adaptive" Version="4.13.0-rc4" /> | ||
</ItemGroup> | ||
|
||
</Project> |
18 changes: 18 additions & 0 deletions
18
packages/Microsoft.Bot.Components.Telephony/Schemas/CallTransferDialog.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,18 @@ | ||
{ | ||
"$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", | ||
"additionalProperties": false, | ||
"properties": { | ||
"targetPhoneNumber": { | ||
"$ref": "schema:#/definitions/stringExpression", | ||
"title": "Target 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
packages/Microsoft.Bot.Components.Telephony/Schemas/CallTransferDialog.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": [ | ||
"targetPhoneNumber", | ||
"*" | ||
], | ||
"properties": { | ||
"targetPhoneNumber": { | ||
"intellisenseScopes": [ | ||
"variable-scopes" | ||
] | ||
} | ||
} | ||
}, | ||
"menu": { | ||
"label": "Transfer a call", | ||
"submenu": [ "Channels", "Telephony" ] | ||
}, | ||
"flow": { | ||
"widget": "ActionCard", | ||
"body": "=action.targetPhoneNumber" | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
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,21 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using Microsoft.Bot.Components.Telephony.Actions; | ||
using Microsoft.Bot.Builder.Dialogs.Declarative; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Bot.Builder; | ||
|
||
namespace Microsoft.Bot.Components.Telephony | ||
{ | ||
public class TeamsBotComponent : BotComponent | ||
{ | ||
/// <inheritdoc/> | ||
public override void ConfigureServices(IServiceCollection services, IConfiguration configuration) | ||
{ | ||
// Conditionals | ||
services.AddSingleton<DeclarativeType>(sp => new DeclarativeType<CallTransferDialog>(CallTransferDialog.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