Is there a way to add a bit of a delay to the responses? So the bot feels more real, like if it was typing? Just a little bit. Right now the reaction from testers has been that it’s too fast. Which is great, but… feels too “cold”. With a little time where it looks like the bot is typing, it would feel a bit more warm and fuzzy: :)
I need to add delay between two lines
session.send("Account created successfully");
session.send("Please login");
Below is the full code
var restify = require('restify');
var builder = require('botbuilder');
var botbuilder_azure = require("botbuilder-azure");
// Setup Restify Server
var server = restify.createServer();
server.listen(process.env.port || process.env.PORT || 3978, function () {
console.log('%s listening to %s', server.name, server.url);
});
// Create chat connector for communicating with the Bot Framework Service
var connector = new builder.ChatConnector({
appId: process.env.MicrosoftAppId,
appPassword: process.env.MicrosoftAppPassword,
openIdMetadata: process.env.BotOpenIdMetadata
});
// Listen for messages from users
server.post('/api/messages', connector.listen());
var bot = new builder.UniversalBot(connector);
bot.on('conversationUpdate', (message) => {
if (message.membersAdded) {
message.membersAdded.forEach(function (identity) {
if (identity.id === message.address.bot.id) {
bot.beginDialog(message.address, 'accountCheck');
}
});
}
});
bot.dialog('accountCheck', [
function (session, results, next) {
session.send("Account created successfully");
session.send("Please login");
}
]).endConversationAction("stop",
"",
{
matches: /^cancel$|^goodbye$|^exit|^stop|^close/i
// confirmPrompt: "This will cancel your order. Are you sure?"
}
);
Bot framework SDK v4:
await turnContext.sendActivity({ type: ActivityTypes.Typing })
Documentation link SDK v4
Bot Framework SDK v3:
session.sendTyping()
Documentation link SDK v3
You can use session.delay()
bot.dialog('accountCheck', [
function (session, results, next) {
session.send("Account created successfully");
// 0.5 sec delay between messages
session.delay(500)
session.send("Please login");
}
]).endConversationAction("stop",
"",
{
matches: /^cancel$|^goodbye$|^exit|^stop|^close/i
// confirmPrompt: "This will cancel your order. Are you sure?"
}
);
see the docs: https://docs.botframework.com/en-us/node/builder/chat-reference/classes/_botbuilder_d_.session.html#delay
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With