1
votes

I've been programming a lot with the MS Bot Framework but I can't seem to make this seemingly trivial part work: sending a Typing activity.

This fails every time: enter image description here

"Object reference not set to an instance of an object"

What is going on?

1

1 Answers

1
votes

Try it like this (if inside a dialog):

private async Task MessageReceivedAsync(IDialogContext context, IAwaitable<object> result)
{
    var activity = await result as Activity;
    var activity2 = activity.CreateReply();
    activity2.Type = ActivityTypes.Typing;
    await context.PostAsync(activity2);
    context.Wait(MessageReceivedAsync);
}

This is most likely because you are using MakeMessage() but not actually setting any of the fields it needs, you are only setting Type so some property in the activity created is throwing the null object reference error.