@agentshouse/kit 0.2.1-alpha.1 → 0.2.1-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/conversations.js +10 -2
- package/package.json +1 -1
package/dist/conversations.js
CHANGED
|
@@ -14,6 +14,9 @@ const KILLED = 'the conversation was killed';
|
|
|
14
14
|
function causeOf(error) {
|
|
15
15
|
return error instanceof Error ? error.message : String(error);
|
|
16
16
|
}
|
|
17
|
+
function answerMessage(request, response) {
|
|
18
|
+
return `The User answered a question you asked earlier.\nQuestion: ${JSON.stringify(request)}\nAnswer: ${JSON.stringify(response)}`;
|
|
19
|
+
}
|
|
17
20
|
function logged(error) {
|
|
18
21
|
process.stderr.write(`kit: ${causeOf(error)}\n`);
|
|
19
22
|
}
|
|
@@ -140,8 +143,13 @@ export class Conversations {
|
|
|
140
143
|
}
|
|
141
144
|
if (input.kind === 'option')
|
|
142
145
|
await this.option(conversation, String(input.option), input.value);
|
|
143
|
-
if (input.kind === 'answer')
|
|
144
|
-
this.questions.get(String(input.interaction_id))
|
|
146
|
+
if (input.kind === 'answer') {
|
|
147
|
+
const question = this.questions.get(String(input.interaction_id));
|
|
148
|
+
if (question === undefined) {
|
|
149
|
+
return this.message(conversation, { ...input, text: answerMessage(input.request, input.response), files: [], first: false });
|
|
150
|
+
}
|
|
151
|
+
question.answer(input.response);
|
|
152
|
+
}
|
|
145
153
|
return {};
|
|
146
154
|
}
|
|
147
155
|
async open(conversation, input) {
|