From 4d542d6516ec34933a0bd1a7b6df2f91897fdde0 Mon Sep 17 00:00:00 2001 From: rvinothrajendran Date: Sat, 22 Jan 2022 16:29:58 +0100 Subject: [PATCH 1/5] MessageBird adapter for BotComposer --- Bot.Builder.Community.sln | 11 ++++ .../MessageBirdAdapter.cs | 4 +- .../MessageBirdAdapterOptions.cs | 9 +++- ...ity.Components.Adapters.MessageBird.csproj | 50 +++++++++++++++++++ .../MessageBirdBotComponent.cs | 11 ++++ .../README.md | 50 +++++++++++++++++++ ...BuilderCommunity.MessageBirdAdapter.schema | 41 +++++++++++++++ ...ilderCommunity.MessageBirdAdapter.uischema | 17 +++++++ 8 files changed, 190 insertions(+), 3 deletions(-) create mode 100644 libraries/Bot.Builder.Community.Components.Adapters.MessageBird/Bot.Builder.Community.Components.Adapters.MessageBird.csproj create mode 100644 libraries/Bot.Builder.Community.Components.Adapters.MessageBird/MessageBirdBotComponent.cs create mode 100644 libraries/Bot.Builder.Community.Components.Adapters.MessageBird/README.md create mode 100644 libraries/Bot.Builder.Community.Components.Adapters.MessageBird/Schemas/BotBuilderCommunity.MessageBirdAdapter.schema create mode 100644 libraries/Bot.Builder.Community.Components.Adapters.MessageBird/Schemas/BotBuilderCommunity.MessageBirdAdapter.uischema diff --git a/Bot.Builder.Community.sln b/Bot.Builder.Community.sln index c895d8e3..7940ac2f 100644 --- a/Bot.Builder.Community.sln +++ b/Bot.Builder.Community.sln @@ -165,6 +165,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bot.Builder.Community.Compo EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bot.Builder.Community.Components.Trigger.ExpireConversation", "libraries\Bot.Builder.Community.Components.Trigger.ExpireConversation\Bot.Builder.Community.Components.Trigger.ExpireConversation.csproj", "{53DD5870-58AC-4B4E-9C12-16AA218EBFCE}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bot.Builder.Community.Components.Adapters.MessageBird", "libraries\Bot.Builder.Community.Components.Adapters.MessageBird\Bot.Builder.Community.Components.Adapters.MessageBird.csproj", "{E438DC4C-670F-496A-AAB3-C800C78E0532}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug - NuGet Packages|Any CPU = Debug - NuGet Packages|Any CPU @@ -715,6 +717,14 @@ Global {53DD5870-58AC-4B4E-9C12-16AA218EBFCE}.Documentation|Any CPU.Build.0 = Debug|Any CPU {53DD5870-58AC-4B4E-9C12-16AA218EBFCE}.Release|Any CPU.ActiveCfg = Release|Any CPU {53DD5870-58AC-4B4E-9C12-16AA218EBFCE}.Release|Any CPU.Build.0 = Release|Any CPU + {E438DC4C-670F-496A-AAB3-C800C78E0532}.Debug - NuGet Packages|Any CPU.ActiveCfg = Debug|Any CPU + {E438DC4C-670F-496A-AAB3-C800C78E0532}.Debug - NuGet Packages|Any CPU.Build.0 = Debug|Any CPU + {E438DC4C-670F-496A-AAB3-C800C78E0532}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E438DC4C-670F-496A-AAB3-C800C78E0532}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E438DC4C-670F-496A-AAB3-C800C78E0532}.Documentation|Any CPU.ActiveCfg = Debug|Any CPU + {E438DC4C-670F-496A-AAB3-C800C78E0532}.Documentation|Any CPU.Build.0 = Debug|Any CPU + {E438DC4C-670F-496A-AAB3-C800C78E0532}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E438DC4C-670F-496A-AAB3-C800C78E0532}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -794,6 +804,7 @@ Global {55546728-AADE-4ED0-88AD-B517B915CD5D} = {1F7F4CAF-CF22-491F-840D-A63835726C12} {56A89D8F-2CD5-439B-8E04-A7A6D9C7566C} = {1F7F4CAF-CF22-491F-840D-A63835726C12} {53DD5870-58AC-4B4E-9C12-16AA218EBFCE} = {1F7F4CAF-CF22-491F-840D-A63835726C12} + {E438DC4C-670F-496A-AAB3-C800C78E0532} = {1F7F4CAF-CF22-491F-840D-A63835726C12} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {9FE3B75E-BA2B-45BC-BBF0-DDA8BA10C4F0} diff --git a/libraries/Bot.Builder.Community.Adapters.MessageBird/MessageBirdAdapter.cs b/libraries/Bot.Builder.Community.Adapters.MessageBird/MessageBirdAdapter.cs index fb3445a5..bbdd9266 100644 --- a/libraries/Bot.Builder.Community.Adapters.MessageBird/MessageBirdAdapter.cs +++ b/libraries/Bot.Builder.Community.Adapters.MessageBird/MessageBirdAdapter.cs @@ -37,7 +37,7 @@ public class MessageBirdAdapter : BotAdapter, IBotFrameworkHttpAdapter public MessageBirdAdapter(MessageBirdAdapterOptions options = null, ILogger logger = null) { - _options = options ?? throw new ArgumentNullException(nameof(options)); + _options = options ?? new MessageBirdAdapterOptions(); _logger = logger ?? NullLogger.Instance; if (_options.UseWhatsAppSandbox) @@ -50,7 +50,9 @@ public MessageBirdAdapter(MessageBirdAdapterOptions options = null, ILogger logg } _requestAuthorization = new MessageBirdRequestAuthorization(); } + Client _messageBirdClient; + public async Task ProcessAsync(HttpRequest httpRequest, HttpResponse httpResponse, IBot bot, CancellationToken cancellationToken = default) { if (httpRequest == null) diff --git a/libraries/Bot.Builder.Community.Adapters.MessageBird/MessageBirdAdapterOptions.cs b/libraries/Bot.Builder.Community.Adapters.MessageBird/MessageBirdAdapterOptions.cs index 189c0679..6b3a9ae4 100644 --- a/libraries/Bot.Builder.Community.Adapters.MessageBird/MessageBirdAdapterOptions.cs +++ b/libraries/Bot.Builder.Community.Adapters.MessageBird/MessageBirdAdapterOptions.cs @@ -1,12 +1,14 @@ using Microsoft.Extensions.Configuration; using System; -using System.Collections.Generic; -using System.Text; namespace Bot.Builder.Community.Adapters.MessageBird { public class MessageBirdAdapterOptions { + public MessageBirdAdapterOptions() + { + + } public MessageBirdAdapterOptions(IConfiguration configuration) : this(configuration["MessageBirdAccessKey"], configuration["MessageBirdSigningKey"], Convert.ToBoolean(configuration["MessageBirdUseWhatsAppSandbox"])) { } @@ -17,8 +19,11 @@ public MessageBirdAdapterOptions(string accessKey, string signingKey, bool useWh SigningKey = signingKey; UseWhatsAppSandbox = useWhatsAppSandbox; } + public string AccessKey { get; set; } + public string SigningKey { get; set; } + public bool UseWhatsAppSandbox { get; set; } } } diff --git a/libraries/Bot.Builder.Community.Components.Adapters.MessageBird/Bot.Builder.Community.Components.Adapters.MessageBird.csproj b/libraries/Bot.Builder.Community.Components.Adapters.MessageBird/Bot.Builder.Community.Components.Adapters.MessageBird.csproj new file mode 100644 index 00000000..75058454 --- /dev/null +++ b/libraries/Bot.Builder.Community.Components.Adapters.MessageBird/Bot.Builder.Community.Components.Adapters.MessageBird.csproj @@ -0,0 +1,50 @@ + + + + + netstandard2.0 + Adapter component for v4 of the Bot Builder .NET SDK to allow for a bot to be used with MessageBird whatsapp. + Bot Builder Community + Bot Builder Community + https://github.com/BotBuilderCommunity/botbuilder-community-dotnet/blob/master/LICENSE + https://github.com/BotBuilderCommunity/botbuilder-community-dotnet/tree/master/libraries/Bot.Builder.Community.Components.Adapters.MessageBird + 1.0.0 + 1.0.0 + 1.0.0 + package-icon.png + https://github.com/BotBuilderCommunity/botbuilder-community-dotnet/ + true + content + bots;ai;botframework;botbuilder;msbot-component;msbot-adapter + $(NoWarn);NU5104 + + + + true + + + + + + + + + + + + + + + + + + + + + + + + True + + + diff --git a/libraries/Bot.Builder.Community.Components.Adapters.MessageBird/MessageBirdBotComponent.cs b/libraries/Bot.Builder.Community.Components.Adapters.MessageBird/MessageBirdBotComponent.cs new file mode 100644 index 00000000..ca870e6c --- /dev/null +++ b/libraries/Bot.Builder.Community.Components.Adapters.MessageBird/MessageBirdBotComponent.cs @@ -0,0 +1,11 @@ +using Bot.Builder.Community.Adapters.MessageBird; +using Bot.Builder.Community.Components.Shared.Adapters; + +namespace Bot.Builder.Community.Components.Adapters.MessageBird +{ + public class MessageBirdBotComponent : + AdapterBotComponent + { + + } +} diff --git a/libraries/Bot.Builder.Community.Components.Adapters.MessageBird/README.md b/libraries/Bot.Builder.Community.Components.Adapters.MessageBird/README.md new file mode 100644 index 00000000..d80c9708 --- /dev/null +++ b/libraries/Bot.Builder.Community.Components.Adapters.MessageBird/README.md @@ -0,0 +1,50 @@ +# Unofficial MessageBird WhatsApp Adapter for Bot Framework Composer + + +# Description + +This is part of the [Bot Builder Community](https://github.com/botbuildercommunity) project which contains Bot Framework Components and other projects / packages for use with Bot Framework Composer and the Bot Builder .NET SDK v4. + +The MessageBird WhatsApp adapter enables receiving and sending WhatsApp messages. The MessageBird adapter allows you to add an additional endpoint to your bot for receiving WhatsApp messages. The MessageBird endpoint can be used in conjunction with other channels meaning, for example, you can have a bot exposed on out of the box channels such as Facebook and Teams, but also via an MessageBird (as well as side by side with the Google/Twitter adapters also available from the Bot Builder Community Project). + + +The adapter currently supports the following scenarios: + +* Send/receive messages with WhatsApp Sandbox +* Send/receive text messages +* Send/receive media messages (document, image, video, audio) - Supported formats for media message types available [here](https://developers.facebook.com/docs/whatsapp/api/media/#supported-files) +* Send/receive location messages +* Verification of incoming MessageBird requests (There is one issue for delivery report webhook verification, MessageBird team is investigating.) +* Receive delivery reports +* Full incoming request from MessageBird is added to the incoming activity as ChannelData + +## Usage + +- [Prerequisites](#Prerequisites) +- [Component Installation](#Component-installation-via-Composer-Package-Manager) +- [Configure the MessageBird connection in Composer](#Configuring-the-MessageBird-connection-in-Bot-Framework-Composer) + +### Prerequisites + +- [Bot Framework Composer](https://dev.botframework.com/) + +## Component installation via Composer Package Manager + +1. Go to Package Manager (in the left hand navigation within Composer). + +2. Within in Package Manager, search for an install the latest version of Bot.Builder.Community.Components.Adapters.MessageBird. + +## Configuring the MessageBird connection in Bot Framework Composer + +1. In Composer, go to your project settings. Within the 'Connections' tab, there should be a new entry called `MessageBird Connection`. Select `Configure` to configure the new connection. + + +2. A modal will pop up. Fill the fields with the values + + + +3. Once you close the modal, your connection should appear as configured in the bot settings. + + +- Signing & Access key information ref & MessageBird [here](https://github.com/BotBuilderCommunity/botbuilder-community-dotnet/tree/develop/libraries/Bot.Builder.Community.Adapters.MessageBird) + diff --git a/libraries/Bot.Builder.Community.Components.Adapters.MessageBird/Schemas/BotBuilderCommunity.MessageBirdAdapter.schema b/libraries/Bot.Builder.Community.Components.Adapters.MessageBird/Schemas/BotBuilderCommunity.MessageBirdAdapter.schema new file mode 100644 index 00000000..f2b13a7a --- /dev/null +++ b/libraries/Bot.Builder.Community.Components.Adapters.MessageBird/Schemas/BotBuilderCommunity.MessageBirdAdapter.schema @@ -0,0 +1,41 @@ +{ + "$schema": "https://schemas.botframework.com/schemas/component/v1.0/component.schema", + "$role": "implements(Microsoft.IAdapter)", + "title": "MessageBird Connection", + "description": "Connects a bot to Zoom.", + "type": "object", + "properties": { + "AccessKey": { + "type": "string", + "title": "Access Key", + "description": "Endpoint on which messages will be sent." + }, + "SigningKey": { + "type": "string", + "title": "Signing Key", + "description": "Signing Key for requests authentication and authorization." + }, + "UseWhatsAppSandbox": { + "type": "boolean", + "title": "UseWhatsAppSandbox", + "description": "Use WhatsApp Sandbox." + }, + "route": { + "type": "string", + "title": "Route", + "description": "Optional route where the adapter is exposed.", + "default": "messagebird" + }, + "type": { + "type": "string", + "title": "Type", + "description": "Adapter type.", + "default": "Bot.Builder.Community.Adapters.MessageBird.MessageBirdAdapter" + } + }, + "required": [ + "AccessKey", + "SigningKey", + "UseWhatsAppSandbox" + ] +} diff --git a/libraries/Bot.Builder.Community.Components.Adapters.MessageBird/Schemas/BotBuilderCommunity.MessageBirdAdapter.uischema b/libraries/Bot.Builder.Community.Components.Adapters.MessageBird/Schemas/BotBuilderCommunity.MessageBirdAdapter.uischema new file mode 100644 index 00000000..2aebf9e9 --- /dev/null +++ b/libraries/Bot.Builder.Community.Components.Adapters.MessageBird/Schemas/BotBuilderCommunity.MessageBirdAdapter.uischema @@ -0,0 +1,17 @@ +{ + "$schema": "https://schemas.botframework.com/schemas/ui/v1.0/ui.schema", + "form": { + "label": "MessageBirdAdapter connection", + "description": "Connects a bot to MessageBird whatsApp.", + "helpLink": "https://github.com/BotBuilderCommunity/botbuilder-community-dotnet/blob/feature/packages-preview/libraries/Bot.Builder.Community.Adapters.Zoom/Component/README.md", + "order": [ + "AccessKey", + "SigningKey", + "UseWhatsAppSandbox", + "*" + ], + "hidden": [ + "type" + ] + } +} From 74a953138e2334190bbf60242029a54de70f296a Mon Sep 17 00:00:00 2001 From: Vinoth Rajendran Date: Sat, 22 Jan 2022 16:42:41 +0100 Subject: [PATCH 2/5] MessageBird adapter for BotComposer --- .../README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libraries/Bot.Builder.Community.Components.Adapters.MessageBird/README.md b/libraries/Bot.Builder.Community.Components.Adapters.MessageBird/README.md index d80c9708..7fe34f23 100644 --- a/libraries/Bot.Builder.Community.Components.Adapters.MessageBird/README.md +++ b/libraries/Bot.Builder.Community.Components.Adapters.MessageBird/README.md @@ -23,7 +23,7 @@ The adapter currently supports the following scenarios: - [Prerequisites](#Prerequisites) - [Component Installation](#Component-installation-via-Composer-Package-Manager) - [Configure the MessageBird connection in Composer](#Configuring-the-MessageBird-connection-in-Bot-Framework-Composer) - +- [More Information](#More-Information) ### Prerequisites - [Bot Framework Composer](https://dev.botframework.com/) @@ -38,13 +38,18 @@ The adapter currently supports the following scenarios: 1. In Composer, go to your project settings. Within the 'Connections' tab, there should be a new entry called `MessageBird Connection`. Select `Configure` to configure the new connection. +![image](https://user-images.githubusercontent.com/16264167/150645167-fd69af6a-277a-47bf-b3ea-87cc90fb5d5c.png) + 2. A modal will pop up. Fill the fields with the values +![image](https://user-images.githubusercontent.com/16264167/150645351-c45e011b-c353-4734-9bb7-aa9643ca6d76.png) 3. Once you close the modal, your connection should appear as configured in the bot settings. -- Signing & Access key information ref & MessageBird [here](https://github.com/BotBuilderCommunity/botbuilder-community-dotnet/tree/develop/libraries/Bot.Builder.Community.Adapters.MessageBird) + +## More Information +- ref MessageBird [here](https://github.com/BotBuilderCommunity/botbuilder-community-dotnet/tree/develop/libraries/Bot.Builder.Community.Adapters.MessageBird) From 1f053456a97cd88e1e59f546af9a0e055b7c136c Mon Sep 17 00:00:00 2001 From: Vinoth Rajendran Date: Sat, 22 Jan 2022 16:44:00 +0100 Subject: [PATCH 3/5] MessageBird adapter for BotComposer --- .../README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/Bot.Builder.Community.Components.Adapters.MessageBird/README.md b/libraries/Bot.Builder.Community.Components.Adapters.MessageBird/README.md index 7fe34f23..ab369e03 100644 --- a/libraries/Bot.Builder.Community.Components.Adapters.MessageBird/README.md +++ b/libraries/Bot.Builder.Community.Components.Adapters.MessageBird/README.md @@ -51,5 +51,5 @@ The adapter currently supports the following scenarios: ## More Information -- ref MessageBird [here](https://github.com/BotBuilderCommunity/botbuilder-community-dotnet/tree/develop/libraries/Bot.Builder.Community.Adapters.MessageBird) +- [MessageBird](https://github.com/BotBuilderCommunity/botbuilder-community-dotnet/tree/develop/libraries/Bot.Builder.Community.Adapters.MessageBird) From 38cf5d9a18482fb652a3633e3e38828427a85292 Mon Sep 17 00:00:00 2001 From: Vinoth Rajendran Date: Sat, 22 Jan 2022 16:45:51 +0100 Subject: [PATCH 4/5] MessageBird adapter for BotComposer --- .../Bot.Builder.Community.Components.Adapters.MessageBird.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/libraries/Bot.Builder.Community.Components.Adapters.MessageBird/Bot.Builder.Community.Components.Adapters.MessageBird.csproj b/libraries/Bot.Builder.Community.Components.Adapters.MessageBird/Bot.Builder.Community.Components.Adapters.MessageBird.csproj index 75058454..408ba6e7 100644 --- a/libraries/Bot.Builder.Community.Components.Adapters.MessageBird/Bot.Builder.Community.Components.Adapters.MessageBird.csproj +++ b/libraries/Bot.Builder.Community.Components.Adapters.MessageBird/Bot.Builder.Community.Components.Adapters.MessageBird.csproj @@ -25,7 +25,6 @@ - From 8335f97d4afb04c03aa0c8b6fa0db942d48a1189 Mon Sep 17 00:00:00 2001 From: Vinoth Rajendran Date: Fri, 28 Jan 2022 11:43:09 +0100 Subject: [PATCH 5/5] Update BotBuilderCommunity.MessageBirdAdapter.schema --- .../Schemas/BotBuilderCommunity.MessageBirdAdapter.schema | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/Bot.Builder.Community.Components.Adapters.MessageBird/Schemas/BotBuilderCommunity.MessageBirdAdapter.schema b/libraries/Bot.Builder.Community.Components.Adapters.MessageBird/Schemas/BotBuilderCommunity.MessageBirdAdapter.schema index f2b13a7a..d5e0191a 100644 --- a/libraries/Bot.Builder.Community.Components.Adapters.MessageBird/Schemas/BotBuilderCommunity.MessageBirdAdapter.schema +++ b/libraries/Bot.Builder.Community.Components.Adapters.MessageBird/Schemas/BotBuilderCommunity.MessageBirdAdapter.schema @@ -2,7 +2,7 @@ "$schema": "https://schemas.botframework.com/schemas/component/v1.0/component.schema", "$role": "implements(Microsoft.IAdapter)", "title": "MessageBird Connection", - "description": "Connects a bot to Zoom.", + "description": "Connects a bot to MessageBird WhatsApp.", "type": "object", "properties": { "AccessKey": {