Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Change conversations key to optional #1716

Merged
merged 2 commits into from
Jul 24, 2019
Merged
Changes from 1 commit
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
14 changes: 9 additions & 5 deletions packages/botkit/src/conversation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ interface BotkitMessageTemplate {
attachments?: any[];
channelData?: any;
collect: {
key: string;
key?: string;
options?: BotkitConvoTrigger[];
};
}
Expand Down Expand Up @@ -330,7 +330,7 @@ export class BotkitConversation<O extends object = {}> extends Dialog<O> {
* @param key name of variable to store response in.
*/
public ask(message: Partial<BotkitMessageTemplate> | string, handlers: BotkitConvoTrigger | BotkitConvoTrigger[], key: {key: string} | string): BotkitConversation {
this.addQuestion(message, handlers, key, 'default');
this.addQuestion(message, handlers, key = null, 'default');
adantoscano marked this conversation as resolved.
Show resolved Hide resolved
return this;
}

Expand All @@ -356,9 +356,13 @@ export class BotkitConversation<O extends object = {}> extends Dialog<O> {
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;
Expand Down