Personality Chat Integration to Bots

There is a library and service called Personality Chat that can be integrated to a chat bot so add small talk capabilities. The interesting part of it is that you can provide a personality type like professional, friendly, humorous.

I have a LUIS chat bot, so it is an exciting option to me to integrate this capability to my bot. I have been using BotBuilder v4 SDK, and Personality Chat provides an integration point with that too. Integration itself seems simple, based on the provided samples and documentation, all you need is to setup a middleware for your bot during startup.

Tryout

The real story is a bit more involved, hence this post is born. The current status of the library is an alpha nuget package. It is referencing an alpha build of the BotBuilder v4 SDK too, which contains breaking changes. For this reason, you won't be able to add middleware to your bot, you will get a compile error.

Find out more


Build 2019

Here are the build videos from 2019, that I suggest for watching (besides the keynotes). These sessions mostly focus on serverless, microservices, .net and C# topics. This list does not include the keynotes.

.NET and C#

Serverless and Blazor

Find out more


Deep Dive in Ref Returns

In the previous post I have used Ref returns to return some data. I noticed that with slight changes we get totally different code generated by the JIT, which is can have a good or bad effect on our code.

In this post, I will dig deep (with WinDbg) in the JIT generated code. As forefront: I am using 64 bit machine, .net core 2.1 and RyuJIT.

I created a sample benchmark to showcase. I have a Point struct with 2 integer properties. I benchmark setting the values on the struct in 3 different ways, I show related IL and machine code impacting performance.

The benchmark

Find out more


The power of Span

Intro to the problem

In one organization, I had to schedule a regular meeting once a week, that fits most the people. Fortunately, the people in this organization mark their holidays in a csv file, so processing the file can help me to figure the day when the least favorable for holidays.For this I would like to have a table which shows the given weekday, and the number of holidays taken on that day.

As a note, we can assume people include public holidays to the time interval in the file, as they usually do so. They also include Saturdays and Sundays too, but those will be filtered out.

Fortunately, we can have two solutions for this problem. On is the classic solution in the 'old' C# way, and one new solution from the Span era of dotnet with a more efficient solution.

Find out more


Ref Returns

C# has recently introduced some new features (version 7.0) one of which it is ref returns. I will use this feature in this post to further improve the performance of the Parser created in my previous post.

To refresh the Parser class looked as follows:

public class Parser 
{
  public T Parse<T>(ReadOnlySpan<char> input, PropertySetter[] setters) where T : struct
  {
    T result = default;
    int separator;
    int propertySetterIndex = 0;
    while((separator = input.IndexOf(',')) != -1)
    {
      var parsedValue = int.Parse(input.Slice(0, separator));
      setters[propertySetterIndex++].SetValue(ref result, parsedValue);
      input = input.Slice(separator + 1);
    }
    return result;
  }
}

To recap it receives an input of comma separated integers that we are parsing into a struct of the user's choice: T. Extending it to other than integer types and fixing the possible ArgumentOutOfRangeException is not a concern of this blog post.

Find out more