Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marcl/botkit-middleware-typing
BotKit middleware to enable typing indicator on platforms that support it
https://github.com/marcl/botkit-middleware-typing
botkit botkit-middleware chatbots messenger slack
Last synced: 25 days ago
JSON representation
BotKit middleware to enable typing indicator on platforms that support it
- Host: GitHub
- URL: https://github.com/marcl/botkit-middleware-typing
- Owner: MarcL
- License: mit
- Created: 2018-11-13T21:53:21.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-03T17:54:56.000Z (almost 2 years ago)
- Last Synced: 2024-04-25T07:22:37.235Z (7 months ago)
- Topics: botkit, botkit-middleware, chatbots, messenger, slack
- Language: JavaScript
- Size: 1.35 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# botkit-middleware-typing
BotKit middleware to enable the typing indicator on [Facebook](#issues) for all messages. This will include those sent via [Botkit conversations](https://botkit.ai/docs/core.html#multi-message-conversations).
## Install
Add the module to your `package.json` using either `npm` or `yarn`.
```
npm install botkit-middleware-typing
```OR
```
yarn add botkit-middleware-typing
```## Use
Include the middleware in your Botkit application.
```
const botkitTypingMiddleware = require('botkit-middleware-typing');
```Add this as a [Botkit send middleware](https://botkit.ai/docs/middleware.html#send-middleware):
```
const controller = Botkit.facebookbot(botConfig);const typingMiddleware = botkitTypingMiddleware();
controller.middleware.send.use(typingMiddleware);
```## Configuration
You can configure the typing delay for the middleware with the following optional parameters.
This will allow you to set a maximum delay or allows you to set a delay for all typing.| Property | Description |
| -------------------- | :-------------------------------------------: |
| maximumTypingDelayMs | Sets the maximum typing delay in milliseconds |
| typingDelayMs | Sets a specified typing delay in milliseconds |### Examples
Set the maximum typing delay to 1 second.
```
const typingMiddleware = botkitTypingMiddleware({
maximumTypingDelayMs: 1000
});controller.middleware.send.use(typingMiddleware);
```Set all typing delays to 4.5 seconds.
```
const typingMiddleware = botkitTypingMiddleware({
typingDelayMs: 4500
});controller.middleware.send.use(typingMiddleware);
```## Issues
With the current implementation of Botkit, there's no easy way to tell which platform the bot is running on. This middleware makes an assumption that the bot supports typing if it has a `bot.startTyping` method. This is currently avaible on Facebook and Slack. Currently only Facebook is supported but I'll look to add Slack shortly.