首页 > 解决方案 > 发送打字指示

问题描述

有没有办法只使用一个函数调用来发送带有打字指示的消息。

还是我必须在一定时间内打开打字,然后在发送消息之前将其关闭?

谢谢

标签: bottender

解决方案


我能够在示例文件夹中找到。我在文档中搜索,但似乎没有很好的记录。the delay and withTyping

这里是整个示例文件以供参考。

const { MessengerBot, withTyping } = require('bottender');
const { createServer } = require('bottender/express');

const bot = new MessengerBot({
  accessToken: '__FILL_YOUR_TOKEN_HERE__',
  appSecret: '__FILL_YOUR_SECRET_HERE__',
});

bot.use(withTyping({ delay: 1000 }));

bot.onEvent(async context => {
 await context.sendText('Hello World');
 await context.sendText('Hello World');
 await context.sendText('Hello World~~~~~~~~~~', { delay: 2000 });
});

const server = createServer(bot);

server.listen(5000, () => {
  console.log('server is running on 5000 port...');
});

推荐阅读