Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send Typing Indicator Helper #621

Closed
ryanvolum opened this issue Nov 9, 2018 · 8 comments
Closed

Send Typing Indicator Helper #621

ryanvolum opened this issue Nov 9, 2018 · 8 comments
Assignees
Labels
4.3 February 14, 2019 Release P2 Nice to have triaged Reviewed by the Triage Team

Comments

@ryanvolum
Copy link
Contributor

ryanvolum commented Nov 9, 2018

Send Typing Indicator Helper
In the v3 SDK and in early iterations of the v4 SDK, there was a simple utility that allowed developers to have their bot send typing indicators. Albeit a minor user experience feature, it gives the end user of the bot the sense that they're communicating with a real agent that's actively typing.

Describe the solution you'd like
In the current iteration of the SDK there appears to be a showTypingMiddleware which sends typing indicators for every outgoing message. While this may be valuable for some bots, I'd like to see a solution that allows the developer to send typing messages themselves.

Additional context
While digging around the source code I found this comment that demonstrates how to send a typing indicator. It both seems like too much code, which could easily be abstracted into a helper function, and doesn't seem to work:

     * // Send a typing indicator without going through a middleware listeners.
     * const reference = TurnContext.getConversationReference(context.activity);
     * const activity = TurnContext.applyConversationReference({ type: 'typing' }, reference);
     * await context.adapter.sendActivities([activity]);

I also noted this bug, but was not able to use the resolution to send the indicator:

await dc.context.sendActivity({ type: ActivityTypes.Typing });

Note: I'm currently testing the typing in the emulator. It's entirely possible that the above code works in other channels, and that this is an emulator bug

[enhancement]

@sgellock sgellock added Enhancement P2 Nice to have 4.3 February 14, 2019 Release triaged Reviewed by the Triage Team labels Nov 12, 2018
@sgellock sgellock added the DX label Dec 6, 2018
@Ric01
Copy link

Ric01 commented Dec 26, 2018

Typing indicator is a very important feature for improving ux experience. SDKv3 was way easier than SDKv4, i couldnt make it work for SDKv4. Saw some examples for the dotnet sdk but none for javascript. Love to hear improvements on this topic

@Ric01
Copy link

Ric01 commented Dec 26, 2018

Recently checked the documentation and find out about the SendActivities method.
Tried it and it worked!, in case someone writing on javascript runs with the same issue.

await context.sendActivities([
* { type: 'typing' },
* { type: 'delay', value: 2000 },
* { type: 'message', text: 'Hello... How are you?' }
* ]);

@hinojosachapel
Copy link

Recently checked the documentation and find out about the SendActivities method.
Tried it and it worked!, in case someone writing on javascript runs with the same issue.

await context.sendActivities([

  • { type: 'typing' },
  • { type: 'delay', value: 2000 },
  • { type: 'message', text: 'Hello... How are you?' }
  • ]);

Great! Thanks! Your solution worked for me, though I introduced a little modification:

async sendTyping(context) {
    await context.sendActivities([
        { type: 'typing' },
        { type: 'delay', value: 2000 }
    ]);
}

@sgellock
Copy link
Member

We've talked this over, and I don't see us adding this, given the view lines of code above to implement the behavior.

@sanjeevgaut
Copy link

Hi It worked for me also in localhost/emulator. but when i deployed in azure it is not working.
i can see there is delay in the response but typing is not coming

@sanjeevgaut
Copy link

sanjeevgaut commented May 6, 2021

This is for node js. It should work..

await step.context.sendActivity({ type: ActivityTypes.Typing });

This will work on the web.

Which channel your bot is deployed.

@NereaCabiedasMoreno
Copy link

yes, that work well, thanks!!, but how to add Typing Indicator whenever BOT have received a message and is processing? @sanjeevgaut thanks!!

@sanjeevgaut
Copy link

yes, that work well, thanks!!, but how to add Typing Indicator whenever BOT have received a message and is processing? @sanjeevgaut thanks!!
Just add await step.context.sendActivity({ type: ActivityTypes.Typing }); in the next step.
or when any processing is hepening add below
step.context.sendActivity({ type: ActivityTypes.Typing });

it should work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.3 February 14, 2019 Release P2 Nice to have triaged Reviewed by the Triage Team
Projects
None yet
Development

No branches or pull requests

7 participants