发送打字指示

时间:2018-07-24 17:07:26

标签: bottender

有没有一种方法可以仅使用一个函数调用发送带有键入指示的消息。

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

谢谢

1 个答案:

答案 0 :(得分:2)

我能够在示例文件夹中找到。 我在文档中进行搜索,但似乎没有充分记录。 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...');
});