UNPKG

botbuilder-unit

Version:
43 lines (36 loc) 1.31 kB
/* jslint es6 */ 'use strict'; const DEFAULT_ADDRESS = require('./SessionMessage').DEFAULT_ADDRESS; const BaseScriptStep = require('./BaseScriptStep'); function SetDialogMessage(step, config, bot, logReporter, prevStepPromise ) { BaseScriptStep.call(this,step,config,bot,logReporter,prevStepPromise); this.stepFinishedPromise = Promise.all([prevStepPromise] ).then(() => { return this.send(); }); } SetDialogMessage.prototype = Object.create(BaseScriptStep.prototype); SetDialogMessage.prototype.constructor = SetDialogMessage; SetDialogMessage.prototype.initSession = function () { return new Promise((resolve, reject) => { this.bot.loadSession(DEFAULT_ADDRESS,resolve); }); } SetDialogMessage.prototype.send = function () { return new Promise((resolve, reject) => { this.initSession() .then((session) => { if ( "undefined" != typeof this.config.dialog ) { this.bot.settings.defaultDialogId = this.config.dialog; } if ( "undefined" != typeof this.config.args ) { this.bot.settings.defaultDialogArgs = this.config.args ; } }) .then(() => { this.logReporter.startupDialog(this.step, this.config.dialog, this.config.args); resolve(); }) .catch(reject) }) } module.exports = SetDialogMessage;