Skip to content

Commit 8d9178a

Browse files
committed
Initialize AssistantV1 in constructor
1 parent b29dc3d commit 8d9178a

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

lib/index.js

Lines changed: 3 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ export class WatsonMiddleware {
6868
if (config.minimum_confidence) {
6969
this.minimumConfidence = config.minimum_confidence;
7070
}
71+
72+
debug(
73+
'Creating Assistant object with parameters: ' +
74+
JSON.stringify(this.config, null, 2),
75+
);
76+
this.conversation = new AssistantV1(this.config);
7177
}
7278

7379
public hear(patterns: string[], message: Botkit.BotkitMessage): boolean {
@@ -105,14 +111,6 @@ export class WatsonMiddleware {
105111
message: Botkit.BotkitMessage,
106112
contextDelta: ContextDelta,
107113
): Promise<void> {
108-
if (!this.conversation) {
109-
debug(
110-
'Creating Assistant object with parameters: ' +
111-
JSON.stringify(this.config, null, 2),
112-
);
113-
this.conversation = new AssistantV1(this.config);
114-
}
115-
116114
if (
117115
(!message.text && message.type !== 'welcome') ||
118116
this.ignoreType.indexOf(message.type) !== -1 ||

0 commit comments

Comments
 (0)