Reputation: 17
In Cortana Bot Skills, the current timeout of a cortana skill waiting for the bot's response is 10 seconds.
We are integrating automation tools like ServiceNow for ticket creation based on user's query in the bot where the ticket creation takes a minute and return back for the bot to respond the user about the ticket details.
Is there any way to increase this timeout value? Is this configurable? Need help on this.
Thanks in Advance.
Upvotes: 1
Views: 128
Reputation: 903
Unfortunately in the current version of the skills kit, you cannot change the timeout period. This timeout is actually controlled by the agent (so, client side, the app or search service.)
Botframework supports "typing" messages; unfortunately Cortana does not (yet). It also supports proactive messages (out of band), and unfortunately Cortana does not (yet).
But there is hope! It depends on how your built your dialog and what input hints you use, and what device is your primary human interface.
For example, on Windows, you can use a hint of "acceptingInput". This means that the conversation is waiting indefinitely for the user to do something. Often this is used when presenting rich cards. If you follow this path, your bot should poll for completion of the task, and then present a "I am still thinking" message in response to a user input (on the next turn).
This UX is not great you say, because the user doesn't know when the task is done... but you can use replaceDialog when the task completes to get the dialog flow back on track!
If you want to provide active feedback that a task is in progress, you can do this! Use the "ignoringInput" hint with a "Please wait message". Create a loop that polls for task completion, and send this message every 5 seconds. ignoringInput causes the bot to proceed to the next turn until it gets an accepting or expecting input hint.
var restify = require('restify');
var builder = require('botbuilder');
// 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());
// Create your bot with a function to receive messages from the user
var bot = new builder.UniversalBot(connector);
bot.set('storage', new builder.MemoryBotStorage() );
const kWelcomeText = 'Hi! Say \'start\' to create a timer and a polling loop.';
const kMisunderstood = 'Sorry, I didn\'t get that.';
const kStarting = 'Starting 30 second timer. Please wait.';
const kWaiting = 'Please wait.';
const kDone = 'My task is done.';
bot.dialog('/', function (session) {
var txt = session.message.text;
if( !txt )
{
var msg = new builder.Message(session)
.text( kWelcomeText )
.speak( kWelcomeText )
.inputHint("acceptingInput");
session.send(msg);
return;
}
if( txt === 'start' )
{
console.log( 'entering pollerDialog' );
session.conversationData.counter = 0;
session.beginDialog('pollerDialog');
return;
}
else {
var msg = new builder.Message(session)
.text( kMisunderstood )
.speak( kMisunderstood )
.inputHint("acceptingInput");
session.send(msg);
return;
}
});
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
bot.dialog('pollerDialog', function (session) {
console.log( 'entering pollerDialog' );
var iter = session.conversationData.counter || 0;
session.conversationData.counter = iter + 1;
if( session.conversationData.done )
{
console.log( 'done' );
var msg = new builder.Message(session)
.text( kDone )
.speak( kDone )
.inputHint("acceptingInput");
session.endDialog(msg);
return;
}
console.log( `iteration is ${iter}` );
if( iter === 0 )
{
console.log( 'setting timeout' );
setTimeout(function () {
console.log( 'timeout done' );
session.conversationData.done = true;
}, 30000);
var msg = new builder.Message(session)
.text( kStarting )
.speak( kStarting )
.inputHint("ignoringInput");
session.sendTyping();
session.send(msg);
console.log( 'sent kStarting' );
setTimeout( function( ) {
console.log( 'replacing kStarting' );
session.replaceDialog('pollerDialog');
}, 5000);
sleep(4000);
return;
} else {
var msg = new builder.Message(session)
.text( kWaiting )
.speak( kWaiting )
.inputHint("ignoringInput");
session.sendTyping();
session.send(msg);
console.log( 'sent kWaiting' );
setTimeout( function( ) {
console.log( 'replacing kWaiting' );
session.replaceDialog('pollerDialog');
}, 5000);
sleep(4000);
return;
}
});
Upvotes: 0