From 1a5521a6d13ff8d1f9d9e706603a262fa45db8ed Mon Sep 17 00:00:00 2001 From: Lord Rasta Date: Mon, 8 Jul 2019 19:38:44 +0200 Subject: [PATCH] Change key to optional --- packages/botkit/src/conversation.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/botkit/src/conversation.ts b/packages/botkit/src/conversation.ts index 50432eb33..9e5bdfcaf 100644 --- a/packages/botkit/src/conversation.ts +++ b/packages/botkit/src/conversation.ts @@ -44,7 +44,7 @@ interface BotkitMessageTemplate { attachments?: any[]; channelData?: any; collect: { - key: string; + key?: string; options?: BotkitConvoTrigger[]; }; } @@ -330,7 +330,7 @@ export class BotkitConversation extends Dialog { * @param key name of variable to store response in. */ public ask(message: Partial | string, handlers: BotkitConvoTrigger | BotkitConvoTrigger[], key: {key: string} | string): BotkitConversation { - this.addQuestion(message, handlers, key, 'default'); + this.addQuestion(message, handlers, key = null, 'default'); return this; } @@ -356,9 +356,13 @@ export class BotkitConversation extends Dialog { message = { text: [message as string] }; } - message.collect = { - key: typeof (key) === 'string' ? key : key.key - }; + message.collect = {}; + + if (key) { + message.collect = { + key: typeof (key) === 'string' ? key : key.key + }; + } if (Array.isArray(handlers)) { message.collect.options = handlers;