@guava-ai/guava-sdk 0.9.0 → 0.11.0

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.
Files changed (65) hide show
  1. package/README.md +1 -1
  2. package/bin/example-runner.ts +4 -4
  3. package/dist/bin/example-runner.js +4 -4
  4. package/dist/bin/example-runner.js.map +1 -1
  5. package/dist/examples/help-desk.js +71 -0
  6. package/dist/examples/help-desk.js.map +1 -0
  7. package/dist/examples/property-insurance.js +14 -22
  8. package/dist/examples/property-insurance.js.map +1 -1
  9. package/dist/examples/restaurant-waitlist.js +74 -0
  10. package/dist/examples/restaurant-waitlist.js.map +1 -0
  11. package/dist/examples/scheduling-outbound.js +30 -54
  12. package/dist/examples/scheduling-outbound.js.map +1 -1
  13. package/dist/src/{action_item.d.ts → action-item.d.ts} +2 -0
  14. package/dist/src/{action_item.js → action-item.js} +3 -1
  15. package/dist/src/action-item.js.map +1 -0
  16. package/dist/src/agent.d.ts +72 -0
  17. package/dist/src/agent.js +444 -0
  18. package/dist/src/agent.js.map +1 -0
  19. package/dist/src/call-controller.d.ts +1 -1
  20. package/dist/src/call-controller.js +1 -1
  21. package/dist/src/call.d.ts +73 -0
  22. package/dist/src/call.js +252 -0
  23. package/dist/src/call.js.map +1 -0
  24. package/dist/src/commands.d.ts +95 -0
  25. package/dist/src/commands.js +24 -2
  26. package/dist/src/commands.js.map +1 -1
  27. package/dist/src/events.d.ts +25 -0
  28. package/dist/src/events.js +12 -1
  29. package/dist/src/events.js.map +1 -1
  30. package/dist/src/example-data.d.ts +1 -0
  31. package/dist/src/example-data.js +41 -1
  32. package/dist/src/example-data.js.map +1 -1
  33. package/dist/src/index.d.ts +14 -5
  34. package/dist/src/index.js +7 -2
  35. package/dist/src/index.js.map +1 -1
  36. package/dist/src/logging.js +1 -1
  37. package/dist/src/logging.js.map +1 -1
  38. package/dist/src/version.d.ts +1 -1
  39. package/dist/src/version.js +1 -1
  40. package/dist/src/version.js.map +1 -1
  41. package/examples/README.md +6 -0
  42. package/examples/help-desk.ts +60 -0
  43. package/examples/property-insurance.ts +14 -30
  44. package/examples/restaurant-waitlist.ts +47 -0
  45. package/examples/scheduling-outbound.ts +40 -76
  46. package/package.json +2 -1
  47. package/src/{action_item.ts → action-item.ts} +3 -0
  48. package/src/agent.ts +439 -0
  49. package/src/call-controller.ts +1 -1
  50. package/src/call.ts +279 -0
  51. package/src/commands.ts +31 -1
  52. package/src/events.ts +15 -0
  53. package/src/example-data.ts +41 -0
  54. package/src/index.ts +7 -5
  55. package/src/logging.ts +1 -1
  56. package/src/version.ts +1 -1
  57. package/dist/examples/credit-card-activation.js +0 -177
  58. package/dist/examples/credit-card-activation.js.map +0 -1
  59. package/dist/examples/thai-palace.js +0 -94
  60. package/dist/examples/thai-palace.js.map +0 -1
  61. package/dist/src/action_item.js.map +0 -1
  62. package/examples/credit-card-activation.ts +0 -178
  63. package/examples/thai-palace.ts +0 -67
  64. /package/dist/examples/{credit-card-activation.d.ts → help-desk.d.ts} +0 -0
  65. /package/dist/examples/{thai-palace.d.ts → restaurant-waitlist.d.ts} +0 -0
@@ -1,94 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.run = run;
37
- const guava = __importStar(require("@guava-ai/guava-sdk"));
38
- const guava_sdk_1 = require("@guava-ai/guava-sdk");
39
- const openai_1 = require("@guava-ai/guava-sdk/helpers/openai");
40
- class ThaiPalaceCallController extends guava.CallController {
41
- choices = ["restaurant waitlist", "anything else"];
42
- intentRecognizer;
43
- constructor(logger) {
44
- super(logger);
45
- this.intentRecognizer = new openai_1.IntentRecognizer(this.choices, logger);
46
- this.setPersona({
47
- organizationName: "Thai Palace",
48
- });
49
- }
50
- async onIncomingCall(from_number) {
51
- await super.onIncomingCall(from_number);
52
- this.acceptCall();
53
- this.setThaiPalaceTask();
54
- }
55
- setThaiPalaceTask() {
56
- this.setTask({
57
- objective: `You are a virtual assistant for a restaurant called Thai Palace.
58
- Your job is to add callers to the waitlist.`,
59
- checklist: [
60
- guava.Field({
61
- key: "caller_name",
62
- fieldType: "text",
63
- description: "The name to be added to the waitlist",
64
- }),
65
- guava.Field({
66
- key: "party_size",
67
- fieldType: "integer",
68
- description: "The number of people attending",
69
- }),
70
- guava.Field({
71
- key: "phone_number",
72
- fieldType: "text",
73
- description: "phone number to text when table is ready",
74
- }),
75
- "Read the phone number back to the caller to make sure you got it right",
76
- ],
77
- }, () => this.hangup());
78
- }
79
- async onIntent(intent) {
80
- const choice = await this.intentRecognizer.classify(intent);
81
- this.logger.info(`Chosen intent: ${choice}`);
82
- if (choice === "restaurant waitlist") {
83
- this.setThaiPalaceTask();
84
- return null;
85
- }
86
- else {
87
- return "Tell them we only handle waitlist additions at this number.";
88
- }
89
- }
90
- }
91
- async function run(_args) {
92
- new guava.Client().listenInbound({ agent_number: process.env.GUAVA_AGENT_NUMBER }, (logger) => new ThaiPalaceCallController((0, guava_sdk_1.getConsoleLogger)("debug")));
93
- }
94
- //# sourceMappingURL=thai-palace.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"thai-palace.js","sourceRoot":"","sources":["../../examples/thai-palace.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,kBAKC;AAlED,2DAA6C;AAC7C,mDAAoE;AACpE,+DAAsE;AAEtE,MAAM,wBAAyB,SAAQ,KAAK,CAAC,cAAc;IACjD,OAAO,GAAG,CAAC,qBAAqB,EAAE,eAAe,CAAU,CAAC;IAC5D,gBAAgB,CAAwC;IAChE,YAAY,MAAc;QACxB,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,gBAAgB,GAAG,IAAI,yBAAgB,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACnE,IAAI,CAAC,UAAU,CAAC;YACd,gBAAgB,EAAE,aAAa;SAChC,CAAC,CAAC;IACL,CAAC;IAEQ,KAAK,CAAC,cAAc,CAAC,WAAoB;QAChD,MAAM,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QACxC,IAAI,CAAC,UAAU,EAAE,CAAC;QAClB,IAAI,CAAC,iBAAiB,EAAE,CAAC;IAC3B,CAAC;IAED,iBAAiB;QACf,IAAI,CAAC,OAAO,CACV;YACE,SAAS,EAAE;6CAC0B;YACrC,SAAS,EAAE;gBACT,KAAK,CAAC,KAAK,CAAC;oBACV,GAAG,EAAE,aAAa;oBAClB,SAAS,EAAE,MAAM;oBACjB,WAAW,EAAE,sCAAsC;iBACpD,CAAC;gBACF,KAAK,CAAC,KAAK,CAAC;oBACV,GAAG,EAAE,YAAY;oBACjB,SAAS,EAAE,SAAS;oBACpB,WAAW,EAAE,gCA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C;AACL,CAAC;AAED,SAAgB,GAAG,CAAC,SAAiB;IACnC,OAAO,eAAO,CAAC,KAAK,CAAC;QACnB,SAAS,EAAE,KAAK;QAChB,SAAS,EAAE,SAAS;KACrB,CAAC,CAAC;AACL,CAAC"}
@@ -1,178 +0,0 @@
1
- import * as guava from "@guava-ai/guava-sdk";
2
- import { IntentRecognizer } from "@guava-ai/guava-sdk/helpers/openai";
3
- import type { Logger } from "@guava-ai/guava-sdk";
4
-
5
- interface Customer {
6
- name: string;
7
- ssn: string;
8
- unactivated_cards: Record<string, number>;
9
- }
10
-
11
- const CUSTOMER_DB: Customer[] = [
12
- {
13
- name: "John Smith",
14
- ssn: "123456789",
15
- unactivated_cards: {
16
- "6011002980139424": 567,
17
- },
18
- },
19
- ];
20
-
21
- function findCustomerBySSN(ssn: string): Customer | undefined {
22
- return CUSTOMER_DB.find((c) => c.ssn === ssn);
23
- }
24
-
25
- const ORGANIZATION_NAME = "Harper Valley Bank";
26
-
27
- class CreditCardActivationController extends guava.CallController {
28
- private choices = ["activate credit card", "anything else"] as const;
29
- private intentRecognizer: IntentRecognizer<typeof this.choices>;
30
- constructor(logger: Logger) {
31
- super(logger);
32
- this.intentRecognizer = new IntentRecognizer(this.choices, logger);
33
- this.setPersona({
34
- organizationName: ORGANIZATION_NAME,
35
- agentPurpose: `You are a customer service voice agent that activates credit cards for customers of ${ORGANIZATION_NAME}.`,
36
- });
37
- this.readScript(
38
- `Hello, thank you for calling the credit card activation line for ${ORGANIZATION_NAME}. My name is Grace. Are you here to activate your credit card?`,
39
- );
40
- this.acceptCall();
41
- }
42
-
43
- override async onIntent(intent: string) {
44
- const choice = await this.intentRecognizer.classify(intent);
45
- this.logger.info(`Chosen intent: ${choice}`);
46
- if (choice === "activate credit card") {
47
- await this.activateCreditCard();
48
- return null;
49
- } else {
50
- return "Unfortunately I'm not able to help with that.";
51
- }
52
- }
53
-
54
- async findCustomer() {
55
- let customer: Customer | undefined;
56
- let cardNumber: string;
57
- while (true) {
58
- await this.awaitTask({
59
- checklist: [
60
- guava.Field({
61
- description: "Could you give me your social security number?",
62
- key: "social_security_number",
63
- fieldType: "integer",
64
- required: true,
65
- }),
66
- ],
67
- });
68
-
69
- const ssn_data = this.getField("social_security_number");
70
- let ssn: string;
71
- if (typeof ssn_data === "string") {
72
- ssn = ssn_data;
73
- } else {
74
- // Should we assume all payloads are strings? or leave room by returning unknown
75
- ssn = JSON.stringify(ssn_data);
76
- }
77
- customer = findCustomerBySSN(ssn);
78
- if (!customer) {
79
- this.sendInstruction(
80
- "We were unable to identify the customer using the SSN they provided. Let the caller know this, and ask if they have the correct social security number.",
81
- );
82
- } else {
83
- await this.awaitTask({
84
- objective:
85
- "We were able to identify the customer using the Social Security Number they have provided. We're going to confirm the client's name.",
86
- checklist: [
87
- guava.Field({
88
- description: `We're going to confirm the client's name. Am I speaking with ${customer.name}?`,
89
- key: "is_client",
90
- fieldType: "multiple_choice",
91
- choices: ["yes", "no"],
92
- required: true,
93
- }),
94
- ],
95
- });
96
-
97
- if (this.getField("is_client") === "no") {
98
- this.sendInstruction(
99
- "We were unable to identify the client's name in our files. Let the caller know this, and re-ask their social security number.",
100
- );
101
- } else {
102
- break;
103
- }
104
- }
105
- }
106
-
107
- this.sendInstruction(
108
- "We were able to find the client's name in our files. Proceed to ask for their card number.",
109
- );
110
- while (true) {
111
- await this.awaitTask({
112
- checklist: [
113
- guava.Field({
114
- fieldType: "integer",
115
- description: "Could you read me the digits on the front of your credit card?",
116
- key: "credit_card_number",
117
- required: true,
118
- }),
119
- ],
120
- });
121
-
122
- cardNumber = this.getField("credit_card_number") as string;
123
- if (!(cardNumber in customer.unactivated_cards)) {
124
- this.sendInstruction(
125
- "We were unable to find the matching card number in our system. Let the caller know this, and re-ask for the credit card number.",
126
- );
127
- } else {
128
- this.sendInstruction(
129
- "We were able to find the matching card number in our system. Let the caller know this, and ask for security code on their card.",
130
- );
131
- break;
132
- }
133
- }
134
-
135
- const correctCvv = customer.unactivated_cards[cardNumber];
136
- while (true) {
137
- await this.awaitTask({
138
- checklist: [
139
- guava.Field({
140
- fieldType: "integer",
141
- key: "security_code",
142
- description: "To wrap up, could I get the security code on your card?",
143
- required: true,
144
- }),
145
- ],
146
- });
147
-
148
- const security_code = this.getField("security_code") as string;
149
- if (security_code !== correctCvv.toString()) {
150
- this.sendInstruction(
151
- "We were unable to match the security code to the credit card. Let the caller know this and re-ask for the security code.",
152
- );
153
- } else {
154
- break;
155
- }
156
- }
157
- this.hangup(
158
- "Explain to the caller that their credit card has now been activated. Thank them for using the bank's services, and hang up.",
159
- );
160
- }
161
-
162
- async activateCreditCard() {
163
- this.sendInstruction(
164
- "We are starting the credit card activation process, which starts with asking the caller for their social security number.",
165
- );
166
-
167
- await this.findCustomer();
168
- }
169
- }
170
-
171
- export async function run(_args: string[]) {
172
- new guava.Client().listenInbound(
173
- {
174
- agent_number: process.env.GUAVA_AGENT_NUMBER!,
175
- },
176
- (logger) => new CreditCardActivationController(logger),
177
- );
178
- }
@@ -1,67 +0,0 @@
1
- import * as guava from "@guava-ai/guava-sdk";
2
- import { getConsoleLogger, type Logger } from "@guava-ai/guava-sdk";
3
- import { IntentRecognizer } from "@guava-ai/guava-sdk/helpers/openai";
4
-
5
- class ThaiPalaceCallController extends guava.CallController {
6
- private choices = ["restaurant waitlist", "anything else"] as const;
7
- private intentRecognizer: IntentRecognizer<typeof this.choices>;
8
- constructor(logger: Logger) {
9
- super(logger);
10
- this.intentRecognizer = new IntentRecognizer(this.choices, logger);
11
- this.setPersona({
12
- organizationName: "Thai Palace",
13
- });
14
- }
15
-
16
- override async onIncomingCall(from_number?: string): Promise<void> {
17
- await super.onIncomingCall(from_number);
18
- this.acceptCall();
19
- this.setThaiPalaceTask();
20
- }
21
-
22
- setThaiPalaceTask() {
23
- this.setTask(
24
- {
25
- objective: `You are a virtual assistant for a restaurant called Thai Palace.
26
- Your job is to add callers to the waitlist.`,
27
- checklist: [
28
- guava.Field({
29
- key: "caller_name",
30
- fieldType: "text",
31
- description: "The name to be added to the waitlist",
32
- }),
33
- guava.Field({
34
- key: "party_size",
35
- fieldType: "integer",
36
- description: "The number of people attending",
37
- }),
38
- guava.Field({
39
- key: "phone_number",
40
- fieldType: "text",
41
- description: "phone number to text when table is ready",
42
- }),
43
- "Read the phone number back to the caller to make sure you got it right",
44
- ],
45
- },
46
- () => this.hangup(),
47
- );
48
- }
49
-
50
- override async onIntent(intent: string) {
51
- const choice = await this.intentRecognizer.classify(intent);
52
- this.logger.info(`Chosen intent: ${choice}`);
53
- if (choice === "restaurant waitlist") {
54
- this.setThaiPalaceTask();
55
- return null;
56
- } else {
57
- return "Tell them we only handle waitlist additions at this number.";
58
- }
59
- }
60
- }
61
-
62
- export async function run(_args: string[]) {
63
- new guava.Client().listenInbound(
64
- { agent_number: process.env.GUAVA_AGENT_NUMBER! },
65
- (logger) => new ThaiPalaceCallController(getConsoleLogger("debug")),
66
- );
67
- }