3
votes

The official docs for Microsoft bot-framework SDK v4 do not demonstrate how to send a typing indicator (whereas v3 has these instructions). I'm using DirectLine and botframework-webchat.

How do I do this? Thanks!

3

3 Answers

13
votes

You can send a typing indicator by sending an activity with the typing type. Read more about how to send a typing indicator.

await context.sendActivities([
            { type: ActivityTypes.Typing },
            { type: 'delay', value: 3000 },
            { type: ActivityTypes.Message, text: 'Finished typing' }
        ]);

Also the showTypingMiddleware can be used to automatically send the typing indicator. This snippet will also show how to send a typing indicator, if you are looking for more sample code.

5
votes

I believe you should do something like this

await context.sendActivities([
    { type: 'typing' },
    { type: 'delay', value: 2000 },
    { type: 'message', text: 'Your message here' }
]);
1
votes

I think you can just add in OnTurnAsync function before await base.OnTurnAsync(turnContext, cancellationToken); :

await turnContext.SendActivityAsync(new Activity { Type = ActivityTypes.Typing }, cancellationToken);