Skip to content

Commit

Permalink
Multiple fixes (#489)
Browse files Browse the repository at this point in the history
* Swallow handoff events and suppport datetime (#404)

* Swallow handoff events and suppport datetime

Ensure handoff events handled by the handoff middleware are swallowed and not passed to the user. Update ServiceNow controller / middleware to handle datetimepicker. Update readme.

* Fix link / multi link support and add card support

* Update TokenExchangeSkillHandler tags and package info (#397)

Fixes: #396

* Added TextRecognizer middlware compoent (#402)

* Added TextRecognizer middlware compoent

* Added readme file for TextRecognizer middleware

* Updated readme.md file

* Replace with Bot_Builder_Version tag

* add it to the turn state and remove from conversation state

* Updated read.md file

* Add Sentiment Analysis Middleware Component (#400)

* chore: update the SentimentAnalyzer reference for Sentiment Analysis Middleware

* chore: add the Sentiment Analysis Middleware component

* chore: modified the description.

* Update README.md

Add all the relevant details

* chore: add solution file and fixed the null check

* chore: add it to the turn state and remove from conversation state after discussing with SDK team

Co-authored-by: Gary Pretty <gary@garypretty.co.uk>

* ServiceNow Component Updates (#407)

* Swallow handoff events and suppport datetime

Ensure handoff events handled by the handoff middleware are swallowed and not passed to the user. Update ServiceNow controller / middleware to handle datetimepicker. Update readme.

* Fix link / multi link support and add card support

* Updates for images / carousels

* Add Google Business Messaging Adapter Component (#408)

* Add Google Business Messaging Component

* Update project file and component registration

* Add package icon

* Include schemas in project

* Add incoming message validation and partnerKey property

* Change to UTF8 encoding in the body validation when requesting authorization (#439)

* StreamReader overload to specify UTF8 encoding type

StreamReader overload to UTF8 encoding type in order to have more compatibility with the character sets of other languages ​​apart from English.  
since this can generate incompatibility in certain cases such as in #435

* Change from ASCII to UTF8 encoding in _requestBodyByte

Change from ASCII to UTF8 encoding type in the body request to have more compatibility with the character sets of other languages ​​apart from English.  
since this can generate incompatibility in certain cases such as in #435

* Include gifs in cards library readme (#431)

Co-authored-by: Kyle Delaney <v-kydel@microsoft.com>

* Update cards library sample dependencies (#430)

Co-authored-by: Kyle <v-kydel@microsoft.com>

* Added null conditional operators for default case and outputText Case to handle  Null reference exception (#425)

* Resolved the issue by adding text inside the hero card, changed item.header to display title for the single link response type. (#426)

* Modifications made in the else part of picker case and boolean case  to render the text within the hero card instead of separate message. (#424)

* Limiting the number of buttons to 50  and cards to 10 that can be rendered in a Hero card carousel. (#423)

* A new response type called OutPutHTML is released in the latest build. With this release, the rich text is not shown and line breaks are missing, displays as a plain text. (#428)

* UI change to Incident card Keys/Titles like Short description  to be bold in the card response type. (#422)

* Added Multi select choice input (#420)

* Added Multi select choice input

* Create README.md

* Document has updated

* URL is not constructed properly (#427)

* Checking for the takeControl flag  along with the responseMessage.completed flag to hand over back the user to MS Bot (#421)

* Removed unnecessary param in the payload (#429)

* Removed unnecessary param in the payload

* Revert "Removed unnecessary param in the payload"

This reverts commit 4003a9f.

* Removed unnecessary param in the payload

* Fix for Ticket Details are truncating and not wrapping (#452)

Co-authored-by: Palanikumar Ravichandran <palanikumar.ravic@hcl.com>

* Update token exchange skill handler readme (#440)

* Update readme.md

* Update readme.md

* Update readme.md

Co-authored-by: Gary Pretty <gary@garypretty.co.uk>

* Expire Conversation Trigger for Bot composer (#456)

* Added expire conversation trigger

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

Co-authored-by: Gary Pretty <gary@garypretty.co.uk>

* Bump RestSharp in /libraries/Bot.Builder.Community.Adapters.Zoom (#445)

Bumps [RestSharp](https://github.com/restsharp/RestSharp) from 106.10.2-alpha.0.8 to 106.12.0.
- [Release notes](https://github.com/restsharp/RestSharp/releases)
- [Changelog](https://github.com/restsharp/RestSharp/blob/dev/releasenotes.md)
- [Commits](https://github.com/restsharp/RestSharp/commits/106.12)

---
updated-dependencies:
- dependency-name: RestSharp
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Gary Pretty <gary@garypretty.co.uk>

* Added custom Bot composer dialog Inputs (#457)

* Added custom inputs

* Added custom dialog inputs

* Added custom dialog inputs

Co-authored-by: Gary Pretty <gary@garypretty.co.uk>

* Move Facebook, Slack, Twilio, Webex adapters (#461)

* Copy Facebook Adapter

* Delete schema files

* Rename project file.

* -Change namespace
-Remove unused usings
-Remove Microsoft copyright notice

* Add README, project file, update solution

* Add Slack, Twilio, Webex initial copy from MS repo

* Slack - update namespace, remove MS copyright notice, remove ununsed usings

* Twilio - update namespaces, remove MS copyright

* Webex - update namespace, remove copyright

* Remove schemas, icons

* Add fully qualified name to Schema

* Add Facebook, Slack, Twilio, Webex tests from MS repo

* Update adapters tests

* Update READMEs

* Remove old project file

* Remove old project files.

* MessageBird adapter for BotComposer (#460)

* MessageBird adapter for BotComposer

* MessageBird adapter for BotComposer

* MessageBird adapter for BotComposer

* MessageBird adapter for BotComposer

* Update BotBuilderCommunity.MessageBirdAdapter.schema

Co-authored-by: Gary Pretty <gary@garypretty.co.uk>

* Google adapter fix for Access Token (#463)

Co-authored-by: Gary Pretty <gary@garypretty.co.uk>

* MessageBird API New Request Verification Method and Breaking Changes (#467)

* #466

* switch statement added, if/else blokcs are removed.

* added caption support for MediaContent's like image, video, audio, file

* fixed some unnecessary indentations

* Changed sample , image caption and added Sample project to the solution file

* fix content type for samples

* added sample code to readme file

* more fixing readme file

* updating composer component to reflect the breaking changes of the adapter, NuGet tags and description

* reverting a tag for NuGet

* Move Samples for Facebook, Slack, Twilio, Webex adapters (#472)

* Copy Facebook Adapter

* Delete schema files

* Rename project file.

* -Change namespace
-Remove unused usings
-Remove Microsoft copyright notice

* Add README, project file, update solution

* Add Slack, Twilio, Webex initial copy from MS repo

* Slack - update namespace, remove MS copyright notice, remove ununsed usings

* Twilio - update namespaces, remove MS copyright

* Webex - update namespace, remove copyright

* Remove schemas, icons

* Add fully qualified name to Schema

* Add Facebook, Slack, Twilio, Webex tests from MS repo

* Update adapters tests

* Update READMEs

* Remove old project file

* Remove old project files.

* Add Facebook, Twilio, Slack, Webex adapter samples.

* Update namespaces, remove copyright notice, update adapter package references, update READMEs.

* Update namespaces.

* Update READMEs.

* Update test projects target framework to netcoreapp3.1.

* Bug fix for mapping of item in reaction_event (#478)

* Bug fix for mapping of item in reaction_event

* restoring message body

* minor fixe

* fixed spacing

* fixed spacing

Co-authored-by: Anshul Sharma <ansharma@linkedin.com>

* Changing encoding from ASCII to UTF8 to support extended charset (#480)

* change split character (#477)

* Webex Adapter: Adding support for Markdown and set default text format to Markdown instead of plain text (#482)

* adding reference to Bot.Builder.Community.Adapters.Share

* handling format and passing MessageTextType to CreateMessageAsync and CreateMessageWithAttachmentsAsync

* Adding support for markdown and additional plain text

* Setting default text format to markdown

* Add activity to google event for GoogleBusinessMessagingRequestMapper (#483)

* Add activity to google event mapping

* update display name

Co-authored-by: Eric Dahlvang <erdahlva@microsoft.com>
Co-authored-by: Vinoth Rajendran <r.vinoth@live.com>
Co-authored-by: Arafat Tehsin <arafattehsin@hotmail.com>
Co-authored-by: Ricardo Zamudio <46466785+JustZeus@users.noreply.github.com>
Co-authored-by: Kyle Delaney <kyle_delaney@msn.com>
Co-authored-by: Kyle Delaney <v-kydel@microsoft.com>
Co-authored-by: Amit-singh96 <85606479+Amit-singh96@users.noreply.github.com>
Co-authored-by: newlogics <30690070+newlogics@users.noreply.github.com>
Co-authored-by: Palanikumar Ravichandran <palanikumar.ravic@hcl.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Monica Rivera <44449640+mrivera-ms@users.noreply.github.com>
Co-authored-by: lauren-mills <lamil@microsoft.com>
Co-authored-by: ahmetkocadogan <ahmetkocadogan@gmail.com>
Co-authored-by: Anshul21 <anshul2117@gmail.com>
Co-authored-by: Anshul Sharma <ansharma@linkedin.com>
Co-authored-by: Bastian Thiede <34596230+bastian-thiede@users.noreply.github.com>
Co-authored-by: Zhipeng Wang <zhiwang@microsoft.com>
  • Loading branch information
18 people authored Jun 9, 2022
1 parent fce3823 commit 71b63a7
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private Activity ConvertToActivity(MessageBirdWebhookPayload response)
{
Type = ActivityTypes.Event,
Id = response.message.id,
ChannelId = $"{response.message.platform}-{response.message.channelId}",
ChannelId = $"{response.message.platform}#{response.message.channelId}",
ChannelData = response,
Recipient = new ChannelAccount { Id = response.message.to },
From = new ChannelAccount { Id = response.message.from ?? "you" },
Expand Down Expand Up @@ -73,7 +73,7 @@ private IActivity ConvertMessageToMessageActivity(MessageBirdWebhookPayload resp

activity.Type = ActivityTypes.Message;
activity.Id = response.message.id;
activity.ChannelId = $"{response.message.platform}-{response.message.channelId}";
activity.ChannelId = $"{response.message.platform}#{response.message.channelId}";
activity.ChannelData = response;
activity.Recipient = new ChannelAccount { Id = response.message.to };
activity.From = new ChannelAccount { Id = response.message.from };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private static MessageBirdSendMessagePayload CreateMessage(IMessageActivity acti
conversationMessageRequest = new ConversationMessageSendRequest()
{
ConversationId = activity.Conversation.Id,
ChannelId = activity.ChannelId.Split('-')[1]
ChannelId = activity.ChannelId.Split('#')[1]
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ public class EventType

public string Ts { get; set; }

public JObject Item { get; } = new JObject();
public JObject Item { get; set;}

[JsonProperty(PropertyName = "event_ts")]
public string EventTs { get; set; }

public string Channel { get; set; }

[JsonProperty(PropertyName = "channel_id")]
Expand All @@ -35,4 +34,4 @@ public class EventType
[JsonExtensionData(ReadData = true, WriteData = true)]
public IDictionary<string, JToken> AdditionalProperties { get; } = new Dictionary<string, JToken>();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,8 @@
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="$(Bot_Builder_Version)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Bot.Builder.Community.Adapters.Shared\Bot.Builder.Community.Adapters.Shared.csproj" />
</ItemGroup>

</Project>
15 changes: 12 additions & 3 deletions libraries/Bot.Builder.Community.Adapters.Webex/WebexAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ public override async Task<ResourceResponse[]> SendActivitiesAsync(ITurnContext
string recipientId;
var target = MessageTarget.PersonId;

// map text format
if (activity.TextFormat == TextFormatTypes.Xml)
{
_logger.LogTrace($"Unsupported TextFormat: '{activity.TextFormat}'. Only TextFormat of types 'Plain' or 'Markdown' are supported.");
activity.TextFormat = TextFormatTypes.Plain;
}

var messageType = activity.TextFormat == TextFormatTypes.Plain ? MessageTextType.Text : MessageTextType.Markdown;

if (activity.Conversation?.Id != null)
{
recipientId = activity.Conversation.Id;
Expand All @@ -110,7 +119,7 @@ public override async Task<ResourceResponse[]> SendActivitiesAsync(ITurnContext
{
if (activity.Attachments[0].ContentType == "application/vnd.microsoft.card.adaptive")
{
responseId = await _webexClient.CreateMessageWithAttachmentsAsync(recipientId, activity.Text, activity.Attachments, MessageTextType.Text, target, cancellationToken).ConfigureAwait(false);
responseId = await _webexClient.CreateMessageWithAttachmentsAsync(recipientId, activity.Text, activity.Attachments, messageType, target, cancellationToken).ConfigureAwait(false);
}
else
{
Expand All @@ -122,13 +131,13 @@ public override async Task<ResourceResponse[]> SendActivitiesAsync(ITurnContext
files.Add(file);
}

responseId = await _webexClient.CreateMessageAsync(recipientId, activity.Text, files.Count > 0 ? files : null, MessageTextType.Text, target, cancellationToken).ConfigureAwait(false);
responseId = await _webexClient.CreateMessageAsync(recipientId, activity.Text, files.Count > 0 ? files : null, messageType, target, cancellationToken).ConfigureAwait(false);
}
}
else
{
responseId = await _webexClient
.CreateMessageAsync(recipientId, activity.Text, target: target, cancellationToken: cancellationToken)
.CreateMessageAsync(recipientId, activity.Text, messageType: messageType, target: target, cancellationToken: cancellationToken)
.ConfigureAwait(false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public virtual bool ValidateSignature(HttpRequest request, string jsonPayload)
/// <param name="target">Target for the message.</param>
/// <param name="cancellationToken">A cancellation token for the task.</param>
/// <returns>The created message id.</returns>
public virtual async Task<string> CreateMessageAsync(string recipient, string text, IList<Uri> files = null, MessageTextType messageType = MessageTextType.Text, MessageTarget target = MessageTarget.PersonId, CancellationToken cancellationToken = default)
public virtual async Task<string> CreateMessageAsync(string recipient, string text, IList<Uri> files = null, MessageTextType messageType = MessageTextType.Markdown, MessageTarget target = MessageTarget.PersonId, CancellationToken cancellationToken = default)
{
var webexResponse = await _api.CreateMessageAsync(recipient, text, files, target, messageType, cancellationToken: cancellationToken).ConfigureAwait(false);

Expand All @@ -107,13 +107,13 @@ public virtual async Task DeleteMessageAsync(string messageId, CancellationToken
/// Creates a message with attachments.
/// </summary>
/// <param name="recipient">PersonId, email or roomId of the message.</param>
/// <param name="text">Text of the message.</param>
/// <param name="textOrMarkdown">Text or markdown of the message.</param>
/// <param name="attachments">List of attachments attached to the message.</param>
/// <param name="messageType">Type of the message. It can be Text or Markdown.</param>
/// <param name="target">Target for the message.</param>
/// <param name="cancellationToken">A cancellation token for the task.</param>
/// <returns>The created message id.</returns>
public virtual async Task<string> CreateMessageWithAttachmentsAsync(string recipient, string text, IList<Attachment> attachments, MessageTextType messageType = MessageTextType.Text, MessageTarget target = MessageTarget.PersonId, CancellationToken cancellationToken = default)
public virtual async Task<string> CreateMessageWithAttachmentsAsync(string recipient, string textOrMarkdown, IList<Attachment> attachments, MessageTextType messageType = MessageTextType.Markdown, MessageTarget target = MessageTarget.PersonId, CancellationToken cancellationToken = default)
{
Message result;

Expand All @@ -124,23 +124,34 @@ public virtual async Task<string> CreateMessageWithAttachmentsAsync(string recip
attachmentsContent.Add(attach.Content);
}

var text = textOrMarkdown ?? string.Empty;
string markdown = null;

if (!string.IsNullOrEmpty(textOrMarkdown) && messageType == MessageTextType.Markdown)
{
markdown = textOrMarkdown;
text = Shared.MarkdownToPlaintextRenderer.Render(textOrMarkdown);
}

var request = new WebexMessageRequest
{
RoomId = target == MessageTarget.SpaceId ? recipient : null,
ToPersonId = target == MessageTarget.SpaceId ? null : recipient,
Text = text ?? string.Empty,
Text = text,
Markdown = markdown,
Attachments = attachmentsContent.Count > 0 ? attachmentsContent : null,
};

var http = (HttpWebRequest)WebRequest.Create(new Uri(MessageUrl));
http.PreAuthenticate = true;
http.Headers.Add("Authorization", "Bearer " + Options.WebexAccessToken);
http.Accept = "application/json";
http.ContentType = "application/json";
http.ContentType = "application/json" +
"; charset=utf-8";
http.Method = "POST";

var parsedContent = JsonConvert.SerializeObject(request);
var encoding = new ASCIIEncoding();
var encoding = new UTF8Encoding();
var bytes = encoding.GetBytes(parsedContent);

var newStream = await http.GetRequestStreamAsync().ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ public Activity RequestToActivity(GoogleBusinessRequest request)
return RequestToEventActivity(request);
}

public OutgoingEvent ActivityToEvent(Activity activity)
{
var googleEvent = new OutgoingEvent();

if (activity is ITypingActivity)
googleEvent.EventType = GoogleEventType.TYPING_STARTED;
else
googleEvent.EventType = GoogleEventType.EVENT_TYPE_UNSPECIFIED;

return googleEvent;
}

public OutgoingMessage ActivityToMessage(Activity activity)
{
var messageId = Guid.NewGuid().ToString();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Bot.Builder.Community.Components.Adapters.GoogleBusiness.Core.Model
{
public enum GoogleEventType
{
EVENT_TYPE_UNSPECIFIED,
TYPING_STARTED,
TYPING_STOPPED,
REPRESENTATIVE_JOINED,
REPRESENTATIVE_LEFT
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace Bot.Builder.Community.Components.Adapters.GoogleBusiness.Core.Model
{
public class OutgoingEvent
{
[JsonConverter(typeof(StringEnumConverter))]
public GoogleEventType EventType { get; set; }

public Representative Representative { get; set; } = new Representative()
{
DisplayName = "Bot",
RepresentativeType = "BOT"
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class OutgoingMessage

public Representative Representative { get; set; } = new Representative()
{
DisplayName = "Contoso",
DisplayName = "Bot",
RepresentativeType = "BOT"
};

Expand Down

0 comments on commit 71b63a7

Please sign in to comment.