Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down Expand Up @@ -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;
})
Expand Down
5 changes: 3 additions & 2 deletions request-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -84,7 +84,8 @@ function init(options) {
intent: {
name: intentName,
slots: buildSlots(slots)
}
},
dialogState: dialog
},
version: '1.0'
};
Expand Down