This repository has been archived by the owner on Sep 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update package versions to point to latest botkit
- Loading branch information
Showing
11 changed files
with
74 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
packages/generator-botkit/generators/web/templates/features/typing.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* This module demonstrates the use of the typing indicator in a conversation, and when using bot.reply | ||
* Tell your bot "typing dialog" or "typing reply" to see this in action. | ||
*/ | ||
module.exports = function(controller) { | ||
|
||
let typing = new BotkitConversation('typing', controller); | ||
|
||
typing.say('I am going to type for a while now...'); | ||
typing.addAction('typing'); | ||
|
||
// start the typing indicator | ||
typing.addMessage({type: 'typing'}, 'typing'); | ||
// trigger a gotoThread, which gives us an opportunity to delay the next message | ||
typing.addAction('next_thread','typing'); | ||
|
||
typing.addMessage('typed!','next_thread'); | ||
|
||
// use the before handler to delay the next message | ||
typing.before('next_thread', async() => { | ||
return new Promise((resolve, reject) => { | ||
// simulate some long running process | ||
setTimeout(resolve, 3000); | ||
}); | ||
}); | ||
|
||
controller.addDialog(typing); | ||
|
||
controller.hears('typing dialog', 'message', async(bot, message) => { | ||
await bot.beginDialog('typing'); | ||
}); | ||
|
||
controller.hears('typing reply', 'message', async(bot, message) => { | ||
|
||
await bot.reply(message, {type: 'typing'}); | ||
|
||
setTimeout(async () => { | ||
// will have to reset context because turn has now ended. | ||
await bot.changeContext(message.reference); | ||
await bot.reply(message, 'Typed!'); | ||
}, 1000); | ||
|
||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters