diff --git a/index.js b/index.js index 7a712ce..a16773e 100644 --- a/index.js +++ b/index.js @@ -35,7 +35,7 @@ module.exports = function conversation({name, app, appId, }) { if (handler === null) throw new Error('Must provide either an app or handler.'); - const requestBuilder = RequestBuilder.init(arguments); + const requestBuilder = RequestBuilder.init(arguments[0]); // chain of promises to handle the different conversation steps const conversationName = name; const tests = []; @@ -80,13 +80,14 @@ module.exports = function conversation({name, app, appId, // Public - function userSays(intentName, slotsArg) { + function userSays(intentName, slotsArg, dialogArg) { step++; initStep(step); const slots = slotsArg || {}; + const dialogState = dialogArg || "COMPLETED"; const index = step; dialog = dialog.then((prevEvent) => - sendRequest(requestBuilder.build(intentName, slots, prevEvent), handler).then((res) => { + sendRequest(requestBuilder.build(intentName, slots, dialogState, prevEvent), handler).then((res) => { tests[index] = _.extend(tests[index], {intentName, slots, actual: res}); return res; }) diff --git a/request-builder.js b/request-builder.js index d614ff4..90f2429 100644 --- a/request-builder.js +++ b/request-builder.js @@ -34,7 +34,7 @@ function init(options) { build }; - function build(intentName, slots, prevEvent) { + function build(intentName, slots, dialog, prevEvent) { if (!options.appId) throw String('AppId not specified. Please run events.init(appId) before building a Request'); const res = { // override more stuff later as we need session: { @@ -84,7 +84,8 @@ function init(options) { intent: { name: intentName, slots: buildSlots(slots) - } + }, + dialogState: dialog }, version: '1.0' };