@onereach/step-voice 6.0.13 → 6.0.14-identifiers.4

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.
@@ -11,7 +11,7 @@ interface INPUT {
11
11
  promptsTriggers: TODO[];
12
12
  usePromptsTriggers: boolean;
13
13
  recognitionModel?: string;
14
- resultInterpretation?: string;
14
+ resultInterpretation: string[];
15
15
  phraseList: Array<{
16
16
  phrase: string;
17
17
  }>;
@@ -41,7 +41,9 @@ const isRepromptTrigger = (recogResult, promptsTriggers) => {
41
41
  return !lodash_1.default.isEmpty(phrases.filter((e) => triggers.includes(e)));
42
42
  };
43
43
  const alterRecognitionPhrases = (phrases, interpretation) => {
44
- switch (interpretation) {
44
+ if (interpretation.length !== 1)
45
+ return;
46
+ switch (interpretation[0]) {
45
47
  case '$POSTALCODE':
46
48
  phrases.forEach(p => { p.lexical = p.lexical.replace(/\s+/g, ''); });
47
49
  break;
@@ -8,6 +8,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
8
8
  const tslib_1 = require("tslib");
9
9
  const voice_1 = tslib_1.__importDefault(require("./voice"));
10
10
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
11
+ const { Flows } = require('@onereach/sdk');
12
+ const { Identifiers } = require('@or-sdk/identifiers');
11
13
  const defaultSessionTimeout = 5 * 60 * 1000;
12
14
  class WaitForCall extends voice_1.default {
13
15
  get conversation() {
@@ -16,6 +18,23 @@ class WaitForCall extends voice_1.default {
16
18
  return this.step.dataOut;
17
19
  }
18
20
  async runStep() {
21
+ const flowsApi = new Flows({
22
+ userTokenFactory: () => `FLOW ${this.config.flowToken}`,
23
+ dataHubUrl: this.config.env.DATA_HUB_URL
24
+ });
25
+ const identifiersApi = new Identifiers({
26
+ dataHubUrl: this.config.env.DATA_HUB_URL,
27
+ sdkUrl: this.config.sdkApiUrl,
28
+ token: `FLOW ${this.config.flowToken}`,
29
+ });
30
+ if (this.event.name === 'activate') {
31
+ const flow = await flowsApi.getFlowById(this.config.flowId, ['identifier']);
32
+ const identifierId = lodash_1.default.get(flow, 'identifier.id');
33
+ if (identifierId) {
34
+ const identifier = await identifiersApi.getIdentifierV2ById(identifierId);
35
+ this.data.selectedNumbers = identifier.data.phoneNumbers;
36
+ }
37
+ }
19
38
  const selectedNumbers = this.data.selectedNumbers;
20
39
  lodash_1.default.forEach(selectedNumbers, number => {
21
40
  this.triggers.on(`in/voice/${number.value}/call`, this.onCall);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onereach/step-voice",
3
- "version": "6.0.13",
3
+ "version": "6.0.14-identifiers.4",
4
4
  "author": "Roman Zolotarov <roman.zolotarov@onereach.com>",
5
5
  "contributors": [
6
6
  "Roman Zolotarov",
@@ -14,6 +14,7 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "@onereach/step-conversation": "^1.0.40",
17
+ "@or-sdk/identifiers": "0.25.0-beta.1454.0",
17
18
  "lodash": "^4.17.21",
18
19
  "nanoid": "^3.3.4",
19
20
  "uuid": "^9.0.0"