Botframework-sdk: [Question] Sending a typing activity to the user

Created on 12 Jul 2016  路  5Comments  路  Source: microsoft/botframework-sdk

Hi,

With v3 of the framework a new typing activity type has been added. Does anybody have an example of how I can send this to the user when they send a message to the bot, whilst the bot is calling off to a 3rd party service to get a suitable response?

Thanks

Gary

Most helpful comment

@alexsorokoletov
Node.js SDK have middleware for these purpose.
We can use it like bot.use(builder.Middleware.sendTyping())
Each time when the some data is received for bot, a typing activity will be send as a response.
After that the bot will process the message and response accordingly.

All 5 comments

After spending a while on this last night, as soon as I posted this I managed to get this working :)

For anybody who is interested here is the code I have used;

                var connector = new ConnectorClient(new Uri(activity.ServiceUrl));
                Activity isTypingReply = activity.CreateReply();
                isTypingReply.Type = ActivityTypes.Typing;
                await connector.Conversations.ReplyToActivityAsync(isTypingReply);

Thank you, @garypretty. Wondering, what is the way to do that in the Node.js SDK.
@Stevenic would you be kind to share your thoughts on that?

@alexsorokoletov
Node.js SDK have middleware for these purpose.
We can use it like bot.use(builder.Middleware.sendTyping())
Each time when the some data is received for bot, a typing activity will be send as a response.
After that the bot will process the message and response accordingly.

Hi @garypretty . In which part of the project is that which you shared:

var connector = new ConnectorClient(new Uri(activity.ServiceUrl));
Activity isTypingReply = activity.CreateReply();
isTypingReply.Type = ActivityTypes.Typing;
await connector.Conversations.ReplyToActivityAsync(isTypingReply);

Thank you

@alexsorokoletov
With @var23rav reference I'm able to achieve it, with this:

bot.use({
    botbuilder: function (session, next) {
        session.send(); // it doesn't work without this..
        session.sendTyping();
        next();
    }
});

but, it doesn't seem to work when I omit session.send();...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mattlanham picture mattlanham  路  3Comments

hailiang-wang picture hailiang-wang  路  3Comments

stijnherreman picture stijnherreman  路  3Comments

maba4891 picture maba4891  路  3Comments

verdysh picture verdysh  路  3Comments