@digipair/skill-chatbot 0.30.1 → 0.31.1

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/index.cjs.js CHANGED
@@ -4,6 +4,17 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var engine = require('@digipair/engine');
6
6
 
7
+ function _extends() {
8
+ _extends = Object.assign || function assign(target) {
9
+ for(var i = 1; i < arguments.length; i++){
10
+ var source = arguments[i];
11
+ for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
12
+ }
13
+ return target;
14
+ };
15
+ return _extends.apply(this, arguments);
16
+ }
17
+
7
18
  let ChatbotService = class ChatbotService {
8
19
  async answer(params, _pinsSettingsList, context) {
9
20
  const { command = [], boosts = [], assistant, sources, logs } = params;
@@ -15,6 +26,13 @@ let ChatbotService = class ChatbotService {
15
26
  logs
16
27
  };
17
28
  }
29
+ async execute(params, _pinsSettingsList, context) {
30
+ const { step } = params;
31
+ const { steps } = context.boost;
32
+ const execute = steps.findIndex(({ name })=>name === step);
33
+ const result = await engine.executePinsList(execute, context);
34
+ return result;
35
+ }
18
36
  // SCENES
19
37
  async boost(params, _pinsSettingsList, context) {
20
38
  if (context.request.method !== 'POST') {
@@ -26,9 +44,31 @@ let ChatbotService = class ChatbotService {
26
44
  const result = await engine.executePinsList(execute, context);
27
45
  return result;
28
46
  }
47
+ async boostBySteps(params, _pinsSettingsList, context) {
48
+ if (context.request.method !== 'POST') {
49
+ return {
50
+ error: 'Method not allowed'
51
+ };
52
+ }
53
+ const { steps } = params;
54
+ const step = context.request.body.step ? steps.findIndex(({ name })=>name === context.request.body.step) : 0;
55
+ const execute = steps[step];
56
+ const result = await engine.executePinsList(execute, _extends({}, context, {
57
+ boost: {
58
+ steps
59
+ }
60
+ }));
61
+ return result;
62
+ }
29
63
  };
30
- const boost = (params, pinsSettingsList, context)=>new ChatbotService().boost(params, pinsSettingsList, context);
64
+ // PIN'S
31
65
  const answer = (params, pinsSettingsList, context)=>new ChatbotService().answer(params, pinsSettingsList, context);
66
+ const execute = (params, pinsSettingsList, context)=>new ChatbotService().execute(params, pinsSettingsList, context);
67
+ // SCENES
68
+ const boost = (params, pinsSettingsList, context)=>new ChatbotService().boost(params, pinsSettingsList, context);
69
+ const boostBySteps = (params, pinsSettingsList, context)=>new ChatbotService().boost(params, pinsSettingsList, context);
32
70
 
33
71
  exports.answer = answer;
34
72
  exports.boost = boost;
73
+ exports.boostBySteps = boostBySteps;
74
+ exports.execute = execute;
package/index.esm.js CHANGED
@@ -1,5 +1,16 @@
1
1
  import { preparePinsSettings, executePinsList } from '@digipair/engine';
2
2
 
3
+ function _extends() {
4
+ _extends = Object.assign || function assign(target) {
5
+ for(var i = 1; i < arguments.length; i++){
6
+ var source = arguments[i];
7
+ for(var key in source)if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];
8
+ }
9
+ return target;
10
+ };
11
+ return _extends.apply(this, arguments);
12
+ }
13
+
3
14
  let ChatbotService = class ChatbotService {
4
15
  async answer(params, _pinsSettingsList, context) {
5
16
  const { command = [], boosts = [], assistant, sources, logs } = params;
@@ -11,6 +22,13 @@ let ChatbotService = class ChatbotService {
11
22
  logs
12
23
  };
13
24
  }
25
+ async execute(params, _pinsSettingsList, context) {
26
+ const { step } = params;
27
+ const { steps } = context.boost;
28
+ const execute = steps.findIndex(({ name })=>name === step);
29
+ const result = await executePinsList(execute, context);
30
+ return result;
31
+ }
14
32
  // SCENES
15
33
  async boost(params, _pinsSettingsList, context) {
16
34
  if (context.request.method !== 'POST') {
@@ -22,8 +40,28 @@ let ChatbotService = class ChatbotService {
22
40
  const result = await executePinsList(execute, context);
23
41
  return result;
24
42
  }
43
+ async boostBySteps(params, _pinsSettingsList, context) {
44
+ if (context.request.method !== 'POST') {
45
+ return {
46
+ error: 'Method not allowed'
47
+ };
48
+ }
49
+ const { steps } = params;
50
+ const step = context.request.body.step ? steps.findIndex(({ name })=>name === context.request.body.step) : 0;
51
+ const execute = steps[step];
52
+ const result = await executePinsList(execute, _extends({}, context, {
53
+ boost: {
54
+ steps
55
+ }
56
+ }));
57
+ return result;
58
+ }
25
59
  };
26
- const boost = (params, pinsSettingsList, context)=>new ChatbotService().boost(params, pinsSettingsList, context);
60
+ // PIN'S
27
61
  const answer = (params, pinsSettingsList, context)=>new ChatbotService().answer(params, pinsSettingsList, context);
62
+ const execute = (params, pinsSettingsList, context)=>new ChatbotService().execute(params, pinsSettingsList, context);
63
+ // SCENES
64
+ const boost = (params, pinsSettingsList, context)=>new ChatbotService().boost(params, pinsSettingsList, context);
65
+ const boostBySteps = (params, pinsSettingsList, context)=>new ChatbotService().boost(params, pinsSettingsList, context);
28
66
 
29
- export { answer, boost };
67
+ export { answer, boost, boostBySteps, execute };
@@ -1,5 +1,4 @@
1
1
  import { PinsSettings } from '@digipair/engine';
2
- export declare const boost: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
3
2
  export declare const answer: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<{
4
3
  assistant: any;
5
4
  command: any[];
@@ -7,3 +6,6 @@ export declare const answer: (params: any, pinsSettingsList: PinsSettings[], con
7
6
  sources: any;
8
7
  logs: any;
9
8
  }>;
9
+ export declare const execute: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
10
+ export declare const boost: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
11
+ export declare const boostBySteps: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digipair/skill-chatbot",
3
- "version": "0.30.1",
3
+ "version": "0.31.1",
4
4
  "dependencies": {},
5
5
  "typings": "./index.d.ts",
6
6
  "main": "./index.cjs.js",
package/schema.en.json CHANGED
@@ -16,7 +16,7 @@
16
16
  {
17
17
  "name": "assistant",
18
18
  "required": true,
19
- "description": "Response from the assistant",
19
+ "description": "Assistant's response",
20
20
  "schema": {
21
21
  "type": "string"
22
22
  }
@@ -62,6 +62,25 @@
62
62
  ],
63
63
  "x-events": []
64
64
  }
65
+ },
66
+ "/execute": {
67
+ "post": {
68
+ "tags": ["boost"],
69
+ "summary": "Execute a step",
70
+ "description": "Execute a step of a step-by-step boost",
71
+ "parameters": [
72
+ {
73
+ "name": "step",
74
+ "required": true,
75
+ "summary": "Name",
76
+ "description": "Name of the step to execute",
77
+ "schema": {
78
+ "type": "string"
79
+ }
80
+ }
81
+ ],
82
+ "x-events": []
83
+ }
65
84
  }
66
85
  },
67
86
  "components": {
@@ -89,6 +108,9 @@
89
108
  "url": {
90
109
  "type": "string"
91
110
  },
111
+ "step": {
112
+ "type": "string"
113
+ },
92
114
  "inputs": {
93
115
  "type": "array",
94
116
  "items": {
@@ -97,6 +119,25 @@
97
119
  }
98
120
  },
99
121
  "required": []
122
+ },
123
+ "Step": {
124
+ "type": "object",
125
+ "tags": ["boost"],
126
+ "summary": "Step",
127
+ "properties": {
128
+ "name": {
129
+ "summary": "Step name",
130
+ "type": "string"
131
+ },
132
+ "execute": {
133
+ "summary": "Actions to execute",
134
+ "type": "array",
135
+ "items": {
136
+ "$ref": "https://schemas.digipair.ai/pinsSettings"
137
+ }
138
+ }
139
+ },
140
+ "required": ["name", "execute"]
100
141
  }
101
142
  }
102
143
  },
@@ -133,6 +174,39 @@
133
174
  }
134
175
  }
135
176
  ]
177
+ },
178
+ "/boostBySteps": {
179
+ "summary": "Step-by-step boost",
180
+ "description": "Step-by-step boost proposed by Digipair",
181
+ "tags": ["boost", "service"],
182
+ "metadata": [
183
+ {
184
+ "name": "boosts",
185
+ "summary": "List of triggers",
186
+ "required": true,
187
+ "description": "List of boost triggers",
188
+ "schema": {
189
+ "type": "array",
190
+ "items": {
191
+ "$ref": "#/components/schemas/Boost"
192
+ }
193
+ }
194
+ }
195
+ ],
196
+ "parameters": [
197
+ {
198
+ "name": "steps",
199
+ "summary": "Execute the following steps",
200
+ "required": true,
201
+ "description": "Execute the defined steps",
202
+ "schema": {
203
+ "type": "array",
204
+ "items": {
205
+ "$ref": "#/components/schemas/Step"
206
+ }
207
+ }
208
+ }
209
+ ]
136
210
  }
137
211
  }
138
212
  }
package/schema.fr.json CHANGED
@@ -62,6 +62,25 @@
62
62
  ],
63
63
  "x-events": []
64
64
  }
65
+ },
66
+ "/execute": {
67
+ "post": {
68
+ "tags": ["boost"],
69
+ "summary": "Execute une étape",
70
+ "description": "Execute une étape d'un boost par étapes",
71
+ "parameters": [
72
+ {
73
+ "name": "step",
74
+ "required": true,
75
+ "summary": "Nom",
76
+ "description": "Nom de l'étape à exécuter",
77
+ "schema": {
78
+ "type": "string"
79
+ }
80
+ }
81
+ ],
82
+ "x-events": []
83
+ }
65
84
  }
66
85
  },
67
86
  "components": {
@@ -89,6 +108,9 @@
89
108
  "url": {
90
109
  "type": "string"
91
110
  },
111
+ "step": {
112
+ "type": "string"
113
+ },
92
114
  "inputs": {
93
115
  "type": "array",
94
116
  "items": {
@@ -97,6 +119,25 @@
97
119
  }
98
120
  },
99
121
  "required": []
122
+ },
123
+ "Step": {
124
+ "type": "object",
125
+ "tags": ["boost"],
126
+ "summary": "Etape",
127
+ "properties": {
128
+ "name": {
129
+ "summary": "Nom de l'étape",
130
+ "type": "string"
131
+ },
132
+ "execute": {
133
+ "summary": "Actions à exécuter",
134
+ "type": "array",
135
+ "items": {
136
+ "$ref": "https://schemas.digipair.ai/pinsSettings"
137
+ }
138
+ }
139
+ },
140
+ "required": ["name", "execute"]
100
141
  }
101
142
  }
102
143
  },
@@ -133,6 +174,39 @@
133
174
  }
134
175
  }
135
176
  ]
177
+ },
178
+ "/boostBySteps": {
179
+ "summary": "Boost par étapes",
180
+ "description": "Boost avec étapes proposé par le Digipair",
181
+ "tags": ["boost", "service"],
182
+ "metadata": [
183
+ {
184
+ "name": "boosts",
185
+ "summary": "Liste des déclencheurs",
186
+ "required": true,
187
+ "description": "Liste des déclencheurs du boost",
188
+ "schema": {
189
+ "type": "array",
190
+ "items": {
191
+ "$ref": "#/components/schemas/Boost"
192
+ }
193
+ }
194
+ }
195
+ ],
196
+ "parameters": [
197
+ {
198
+ "name": "steps",
199
+ "summary": "Exécute les étapes suivantes",
200
+ "required": true,
201
+ "description": "Exécute les étapes définies",
202
+ "schema": {
203
+ "type": "array",
204
+ "items": {
205
+ "$ref": "#/components/schemas/Step"
206
+ }
207
+ }
208
+ }
209
+ ]
136
210
  }
137
211
  }
138
212
  }
package/schema.json CHANGED
@@ -16,7 +16,7 @@
16
16
  {
17
17
  "name": "assistant",
18
18
  "required": true,
19
- "description": "Response from the assistant",
19
+ "description": "Assistant's response",
20
20
  "schema": {
21
21
  "type": "string"
22
22
  }
@@ -62,6 +62,25 @@
62
62
  ],
63
63
  "x-events": []
64
64
  }
65
+ },
66
+ "/execute": {
67
+ "post": {
68
+ "tags": ["boost"],
69
+ "summary": "Execute a step",
70
+ "description": "Execute a step of a step-by-step boost",
71
+ "parameters": [
72
+ {
73
+ "name": "step",
74
+ "required": true,
75
+ "summary": "Name",
76
+ "description": "Name of the step to execute",
77
+ "schema": {
78
+ "type": "string"
79
+ }
80
+ }
81
+ ],
82
+ "x-events": []
83
+ }
65
84
  }
66
85
  },
67
86
  "components": {
@@ -89,6 +108,9 @@
89
108
  "url": {
90
109
  "type": "string"
91
110
  },
111
+ "step": {
112
+ "type": "string"
113
+ },
92
114
  "inputs": {
93
115
  "type": "array",
94
116
  "items": {
@@ -97,6 +119,25 @@
97
119
  }
98
120
  },
99
121
  "required": []
122
+ },
123
+ "Step": {
124
+ "type": "object",
125
+ "tags": ["boost"],
126
+ "summary": "Step",
127
+ "properties": {
128
+ "name": {
129
+ "summary": "Step name",
130
+ "type": "string"
131
+ },
132
+ "execute": {
133
+ "summary": "Actions to execute",
134
+ "type": "array",
135
+ "items": {
136
+ "$ref": "https://schemas.digipair.ai/pinsSettings"
137
+ }
138
+ }
139
+ },
140
+ "required": ["name", "execute"]
100
141
  }
101
142
  }
102
143
  },
@@ -133,6 +174,39 @@
133
174
  }
134
175
  }
135
176
  ]
177
+ },
178
+ "/boostBySteps": {
179
+ "summary": "Step-by-step boost",
180
+ "description": "Step-by-step boost proposed by Digipair",
181
+ "tags": ["boost", "service"],
182
+ "metadata": [
183
+ {
184
+ "name": "boosts",
185
+ "summary": "List of triggers",
186
+ "required": true,
187
+ "description": "List of boost triggers",
188
+ "schema": {
189
+ "type": "array",
190
+ "items": {
191
+ "$ref": "#/components/schemas/Boost"
192
+ }
193
+ }
194
+ }
195
+ ],
196
+ "parameters": [
197
+ {
198
+ "name": "steps",
199
+ "summary": "Execute the following steps",
200
+ "required": true,
201
+ "description": "Execute the defined steps",
202
+ "schema": {
203
+ "type": "array",
204
+ "items": {
205
+ "$ref": "#/components/schemas/Step"
206
+ }
207
+ }
208
+ }
209
+ ]
136
210
  }
137
211
  }
138
212
  }