Add Emoji in Bot Framework Reply

Based on the request of one of the site visitor, in this post, we will add Emoji in our message in bot framework reply. We will use an Echo Bot Template and show one example to use the Emoji. We need to use Unicode characters of emoji in our C# code.

Pre-requisites

  1. Visual Studio
  2. Bot Framework Emulator
  3. Create Echo Bot using Bot Builder SDK in Local Environment | Microsoft Bot Framework
  4. List of Emoji with their Unicode

Links of first two requirement are present Downloads page.


Add Emoji in Bot Reply

From the list of Emoji, I will use the Star emoji whose Unicode is U+1F929.

To use this Unicode in your C# code, you will have to use escape character in the beginning and replace the “+” with three 0s.

\U0001F929

Add the Unicode in the replyText in OnMessageActivityAsync method.

protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivity> turnContext, CancellationToken cancellationToken)
        {
            var replyText = $"Echo: {turnContext.Activity.Text} \U0001F929";
            await turnContext.SendActivityAsync(MessageFactory.Text(replyText, replyText), cancellationToken);
        }

Run the project and see the output in the Emulator.

Thank you All!!! Hope you find this useful.


Up ↑

%d bloggers like this: