Trying to show typing indicator

i am trying to show typing indicator in inbuilt action wait.js when wait.js executes nothing shows i want to show typing indicator till next thing is delayed to execute

@KristlyDsena The wait only delays further answers, the ideal way would be to send a typing event, then use the wait action, eg something like this

bp.events.replyToEvent(event, { type: 'typing', value: true })

sorry @allardy i don’t understand how to use it exactly.

You can check an example here:

Can you post the code you used to show typing indicators with the wait.js? I think I am trying to do the same thing as you, but am having zero luck. Thanks!

Hi @JoeyG

Here’s a working example to show the bot typing for the duration of the delay. I’ve edited the wait builtin action:

/**
   * Wait for a bit.
   *
   * @title Wait/Delay
   * @category Utility
   * @author Botpress, Inc.
   * @param {number} delay=1000 - The number of milliseconds to wait
   */
  const wait = async delay => {
    await bp.events.replyToEvent(event, [{ type: 'typing', value: delay }])
    return new Promise(resolve => setTimeout(() => resolve(), delay));
  };

  return wait(args.delay || 1000);
1 Like

Hello allardy,

Can i use this script to edit the speed at which the bot replies to questions asked?

Hi @kenkaigu, You can edit the script to tell it how much time to wait before processing the next instruction. That action is already built in in Botpress, you just need to set the number of ms to wait

Thanks for the repy… Where can i locate this file so i can edit it?

All files are located in data/global/actions, you also have hooks that you can edit in data/global/hooks, and it’s also possible to have bot-specific actions in data/bots/BOT_ID/actions