@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
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Guava Typescript SDK
2
- ![NPM Version](https://img.shields.io/npm/v/%40guava-ai%2Fguava-sdk)
2
+ [![NPM Version](https://img.shields.io/npm/v/%40guava-ai%2Fguava-sdk)](https://www.npmjs.com/package/@guava-ai/guava-sdk)
3
3
 
4
4
  This library allows you to build Guava voice agents using TypeScript or Javascript. Currently only NodeJS is officially supported as a runtime.
5
5
 
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  import * as schedulingOutbound from "../examples/scheduling-outbound";
3
3
  import * as propertyInsurance from "../examples/property-insurance";
4
- import * as creditCardActivation from "../examples/credit-card-activation";
5
- import * as thaiPalace from "../examples/thai-palace";
4
+ import * as restaurantWaitlist from "../examples/restaurant-waitlist";
5
+ import * as helpDesk from "../examples/help-desk";
6
6
 
7
7
  const EXAMPLES = {
8
8
  "scheduling-outbound": schedulingOutbound,
9
9
  "property-insurance": propertyInsurance,
10
- "credit-card-activation": creditCardActivation,
11
- "thai-palace": thaiPalace,
10
+ "restaurant-waitlist": restaurantWaitlist,
11
+ "help-desk": helpDesk,
12
12
  };
13
13
 
14
14
  const exampleName = process.argv[2];
@@ -36,13 +36,13 @@ var __importStar = (this && this.__importStar) || (function () {
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
37
  const schedulingOutbound = __importStar(require("../examples/scheduling-outbound"));
38
38
  const propertyInsurance = __importStar(require("../examples/property-insurance"));
39
- const creditCardActivation = __importStar(require("../examples/credit-card-activation"));
40
- const thaiPalace = __importStar(require("../examples/thai-palace"));
39
+ const restaurantWaitlist = __importStar(require("../examples/restaurant-waitlist"));
40
+ const helpDesk = __importStar(require("../examples/help-desk"));
41
41
  const EXAMPLES = {
42
42
  "scheduling-outbound": schedulingOutbound,
43
43
  "property-insurance": propertyInsurance,
44
- "credit-card-activation": creditCardActivation,
45
- "thai-palace": thaiPalace,
44
+ "restaurant-waitlist": restaurantWaitlist,
45
+ "help-desk": helpDesk,
46
46
  };
47
47
  const exampleName = process.argv[2];
48
48
  if (!exampleName) {
@@ -1 +1 @@
1
- {"version":3,"file":"example-runner.js","sourceRoot":"","sources":["../../bin/example-runner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,oFAAsE;AACtE,kFAAoE;AACpE,yFAA2E;AAC3E,oEAAsD;AAEtD,MAAM,QAAQ,GAAG;IACf,qBAAqB,EAAE,kBAAkB;IACzC,oBAAoB,EAAE,iBAAiB;IACvC,wBAAwB,EAAE,oBAAoB;IAC9C,aAAa,EAAE,UAAU;CAC1B,CAAC;AAEF,MAAM,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpC,IAAI,CAAC,WAAW,EAAE,CAAC;IACjB,OAAO,CAAC,KAAK,CAAC,oDAAoD,CAAC,CAAC;IACpE,O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,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,CAAC,CAAC,WAAW,IAAI,QAAQ,CAAC,EAAE,CAAC;IAC/B,OAAO,CAAC,KAAK,CAAC,oBAAoB,WAAW,0BAA0B,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC3G,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,CAAC,KAAK,IAAI,EAAE;IACV,MAAM,QAAQ,CAAC,WAAoC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAClF,CAAC,CAAC,EAAE,CAAC"}
@@ -0,0 +1,71 @@
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 openai_1 = require("@guava-ai/guava-sdk/helpers/openai");
39
+ const example_data_1 = require("@guava-ai/guava-sdk/example-data");
40
+ const guava_sdk_1 = require("@guava-ai/guava-sdk");
41
+ const agent = new guava.Agent({
42
+ name: "Nova",
43
+ organization: "Clearfield Home & Living",
44
+ purpose: "Answer questions and route callers to the appropriate department.",
45
+ });
46
+ const logger = (0, guava_sdk_1.getDefaultLogger)();
47
+ const documentQA = new openai_1.DocumentQA("clearfield-home-living-qa", example_data_1.FURNITURE_RETAILER_QA);
48
+ const intentRecognizer = new openai_1.IntentRecognizer(["sales", "delivery-and-returns", "account-management", "other"], logger);
49
+ agent.onQuestion(async (_call, question) => {
50
+ return await documentQA.ask(question);
51
+ });
52
+ agent.onActionRequest(async (_call, request) => {
53
+ const key = await intentRecognizer.classify(request);
54
+ return { key };
55
+ });
56
+ agent.onAction("sales", async (call) => {
57
+ call.transfer("+15555555555", "Notify the caller that you will be transferring them to the Sales department.");
58
+ });
59
+ agent.onAction("delivery-and-returns", async (call) => {
60
+ call.transfer("+15555555555", "Notify the caller that you will be transferring them to the Delivery and Returns department.");
61
+ });
62
+ agent.onAction("account-management", async (call) => {
63
+ call.transfer("+15555555555", "Notify the caller that you will be transferring them to the Account Management department.");
64
+ });
65
+ agent.onAction("other", async (call) => {
66
+ call.transfer("+15555555555", "Notify the caller that you will be connecting them with a service representative.");
67
+ });
68
+ async function run(_args) {
69
+ agent.inboundPhone(process.env.GUAVA_AGENT_NUMBER);
70
+ }
71
+ //# sourceMappingURL=help-desk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help-desk.js","sourceRoot":"","sources":["../../examples/help-desk.ts"],"names":[],"mappings":";;;;;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AC,QAAQ,CAAC,oBAAoB,EAAE,KAAK,EAAE,IAAgB,EAAE,EAAE;IAC9D,IAAI,CAAC,QAAQ,CACX,cAAc,EACd,4FAA4F,CAC7F,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,IAAgB,EAAE,EAAE;IACjD,IAAI,CAAC,QAAQ,CACX,cAAc,EACd,mFAAmF,CACpF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEI,KAAK,UAAU,GAAG,CAAC,KAAe;IACvC,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAmB,CAAC,CAAC;AACtD,CAAC"}
@@ -37,28 +37,20 @@ exports.run = run;
37
37
  const guava = __importStar(require("@guava-ai/guava-sdk"));
38
38
  const openai_1 = require("@guava-ai/guava-sdk/helpers/openai");
39
39
  const example_data_1 = require("@guava-ai/guava-sdk/example-data");
40
- class InsuranceCallController extends guava.CallController {
41
- documentQA;
42
- constructor() {
43
- super();
44
- this.documentQA = new openai_1.DocumentQA("harper-valley-property-insurance", example_data_1.PROPERTY_INSURANCE_POLICY);
45
- this.setPersona({
46
- organizationName: "Harper Valley Property Insurance",
47
- });
48
- this.setTask({
49
- objective: "You are making an outbound call to a potential customer. Your task is to answer questions regarding property insurance policy until there are no more questions.",
50
- });
51
- }
52
- async onQuestion(question) {
53
- return await this.documentQA.ask(question);
54
- }
55
- }
40
+ const agent = new guava.Agent({
41
+ organization: "Harper Valley Property Insurance",
42
+ purpose: "Answer questions regarding property insurance policy until there are no more questions",
43
+ });
44
+ // This is a built-in knowledge base helper that we will use for this example.
45
+ // You can use any RAG system you prefer.
46
+ const documentQA = new openai_1.DocumentQA("harper-valley-property-insurance", example_data_1.PROPERTY_INSURANCE_POLICY);
47
+ // When the Agent is asked a question that it cannot answer, it will invoke the on_question callback.
48
+ agent.onQuestion(async (call, question) => {
49
+ // Forward the Agent's question to the knowledge base and return the answer.
50
+ // You can plug in any knowledge base system you want here.
51
+ return await documentQA.ask(question);
52
+ });
56
53
  async function run(args) {
57
- const [phone] = args;
58
- if (!phone) {
59
- console.error("Usage: guava-example property-insurance <phone>");
60
- process.exit(1);
61
- }
62
- new guava.Client().createOutbound(process.env.GUAVA_AGENT_NUMBER, phone, new InsuranceCallController());
54
+ agent.inboundPhone(process.env.GUAVA_AGENT_NUMBER);
63
55
  }
64
56
  //# sourceMappingURL=property-insurance.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"property-insurance.js","sourceRoot":"","sources":["../../examples/property-insurance.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,kBAaC;AAtCD,2DAA6C;AAC7C,+DAAgE;AAChE,mEAA6E;AAE7E,MAAM,uBAAwB,SAAQ,KAAK,CAAC,cAAc;IAChD,UAAU,CAAa;IAC/B;QACE,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,UAAU,GAAG,IAAI,mBAAU,CAAC,kCAAkC,EAAE,wCAAyB,CAAC,CAAC;QAEhG,IAAI,CAAC,UAAU,CAAC;YACd,gBAAgB,EAAE,kCAAkC;SACrD,CAAC,CAAC;QACH,IAAI,CAAC,OAAO,CAAC;YACX,SAAS,EACP,kKAAkK;SACrK,CAAC,CAAC;IACL,CAAC;IAEQ,KAAK,CAAC,UAAU,CAAC,QAAgB;QACxC,OAAO,MAAM,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC7C,CAAC;CACF;AAEM,KAAK,UAAU,GAAG,CAAC,IAAc;IACtC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;IAErB,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,iDAAiD,CAAC,CAAC;QACjE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC,cAAc,CAC/B,OAAO,CAAC,GAAG,CAAC,kBAAmB,EAC/B,KAAK,EACL,IAAI,uBAAuB,EAAE,CAC9B,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"property-insurance.js","sourceRoot":"","sources":["../../examples/property-insurance.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,kBAEC;AAtBD,2DAA6C;AAC7C,+DAAgE;AAChE,mEAA6E;AAE7E,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC;IAC5B,YAAY,EAAE,kCAAkC;IAChD,OAAO,EAAE,wFAAwF;CAClG,CAAC,CAAC;AAEH,8EAA8E;AAC9E,yCAAyC;AACzC,MAAM,UAAU,GAAG,IAAI,mBAAU,CAAC,kCAAkC,EAAE,wCAAyB,CAAC,CAAC;AAEjG,qGAAqG;AACrG,KAAK,CAAC,UAAU,CAAC,KAAK,EAAE,IAAgB,EAAE,QAAgB,EAAE,EAAE;IAC5D,4EAA4E;IAC5E,2DAA2D;IAC3D,OAAO,MAAM,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;AACxC,CAAC,CAAC,CAAC;AAEI,KAAK,UAAU,GAAG,CAAC,IAAc;IACtC,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAmB,CAAC,CAAC;AACtD,CAAC"}
@@ -0,0 +1,74 @@
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 logger = (0, guava_sdk_1.getDefaultLogger)();
40
+ const agent = new guava.Agent({
41
+ name: "Mia",
42
+ organization: "Thai Palace",
43
+ purpose: "Helping callers join the restaurant waitlist",
44
+ });
45
+ agent.onCallReceived(async (_callInfo) => {
46
+ // In this callback you have the option to accept or reject a call based off the caller info.
47
+ // For now we will accept all calls. If this callback is not provided, the default behavior is
48
+ // to accept all calls.
49
+ return { action: "accept" };
50
+ });
51
+ agent.onCallStart(async (call) => {
52
+ await call.setTask({
53
+ taskId: "waitlist",
54
+ objective: "You are a virtual assistant for Thai Palace. Add callers to the waitlist.",
55
+ checklist: [
56
+ guava.Field({ key: "caller_name", fieldType: "text", description: "Name for the waitlist" }),
57
+ guava.Field({ key: "party_size", fieldType: "integer", description: "Number of people" }),
58
+ guava.Field({
59
+ key: "phone_number",
60
+ fieldType: "text",
61
+ description: "Phone number to text when the table is ready",
62
+ }),
63
+ "Read the phone number back to the caller to confirm.",
64
+ ],
65
+ });
66
+ });
67
+ agent.onTaskComplete("waitlist", async (call) => {
68
+ logger.info("Added %s, party of %d, to waitlist.", await call.getField("caller_name"), await call.getField("party_size"));
69
+ await call.hangup("Thank the caller and let them know we'll text when their table is ready.");
70
+ });
71
+ async function run(_args) {
72
+ agent.inboundPhone(process.env.GUAVA_AGENT_NUMBER);
73
+ }
74
+ //# sourceMappingURL=restaurant-waitlist.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"restaurant-waitlist.js","sourceRoot":"","sources":["../../examples/restaurant-waitlist.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,kBAEC;AA9CD,2DAA6C;AAC7C,mDAAuD;AAEvD,MAAM,MAAM,GAAG,IAAA,4BAAgB,GAAE,CAAC;AAElC,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC;IAC5B,IAAI,EAAE,KAAK;IACX,YAAY,EAAE,aAAa;IAC3B,OAAO,EAAE,8CAA8C;CACxD,CAAC,CAAC;AAEH,KAAK,CAAC,cAAc,CAAC,KAAK,EAAE,SAAyB,EAAE,EAAE;IACvD,6FAA6F;IAC7F,8FAA8F;IAC9F,uBAAuB;IACvB,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AAC9B,CAAC,CAAC,CAAC;AAEH,KAAK,CAAC,WAAW,CAAC,KAAK,EAAE,IAAgB,EAAE,EAAE;IAC3C,MAAM,IAAI,CAAC,OAAO,CAAC;QACjB,MAAM,EAAE,UAAU;QAClB,SAAS,EAAE,2EAA2E;QACtF,SAAS,EAAE;YACT,KAAK,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,uBAAuB,EAAE,CAAC;YAC5F,KAAK,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,kBAAkB,EAAE,CAAC;YACzF,KAAK,CAAC,KAAK,CAAC;gBACV,GAAG,EAAE,cAAc;gBACnB,SAAS,EAAE,MAAM;gBACjB,WAAW,EAAE,8CAA8C;aAC5D,CAAC;YACF,sDAAsD;SACvD;KACF,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,KAAK,CAAC,cAAc,CAAC,UAAU,EAAE,KAAK,EAAE,IAAgB,EAAE,EAAE;IAC1D,MAAM,CAAC,IAAI,CACT,qCAAqC,EACrC,MAAM,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,EAClC,MAAM,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,CAClC,CAAC;IACF,MAAM,IAAI,CAAC,MAAM,CAAC,0EAA0E,CAAC,CAAC;AAChG,CAAC,CAAC,CAAC;AAEI,KAAK,UAAU,GAAG,CAAC,KAAe;IACvC,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAmB,CAAC,CAAC;AACtD,CAAC"}
@@ -37,74 +37,50 @@ exports.run = run;
37
37
  const guava = __importStar(require("@guava-ai/guava-sdk"));
38
38
  const openai_1 = require("@guava-ai/guava-sdk/helpers/openai");
39
39
  const example_data_1 = require("@guava-ai/guava-sdk/example-data");
40
- class SchedulingController extends guava.CallController {
41
- patientName;
42
- datetimeFilter;
43
- constructor(patientName) {
44
- super();
45
- this.patientName = patientName;
46
- // This is a basic appointment time selector that pulls from a mock list of appointments.
47
- // In production, you would likely replace this with your own agentic scheduling backend.
48
- this.datetimeFilter = new openai_1.DatetimeFilter({
49
- sourceList: (0, example_data_1.mockAppointmentsForFuture)(),
50
- });
51
- // Use setPersona to set basic information about the agent, as well as its high-level purpose.
52
- this.setPersona({
53
- organizationName: "Bright Smile Dental",
54
- agentName: "Grace",
55
- agentPurpose: `You are calling ${patientName} to help them schedule a dental appointment`,
56
- });
57
- // reachPerson is a convenience function to confirm that we are talking to the intended recipient.
58
- this.reachPerson(this.patientName, {
59
- onSuccess: () => this.scheduleRecipient(),
60
- onFailure: () => this.recipientUnavailable(),
61
- });
62
- }
63
- scheduleRecipient() {
64
- // We have now confirmed that we are talking to the patient.
65
- // Set the Agent's current task to collect the desired appointment time.
66
- this.setTask({
67
- // The check list is an ordered list of items for the agent to go through.
68
- // It can include short prompts as well as Fields to capture structured information.
40
+ const agent = new guava.Agent({
41
+ organization: "Bright Smile Dental",
42
+ purpose: "You are calling patients to help them schedule a dental appointment",
43
+ });
44
+ const datetimeFilter = new openai_1.DatetimeFilter({
45
+ sourceList: (0, example_data_1.mockAppointmentsForFuture)(),
46
+ });
47
+ agent.onCallStart(async (call) => {
48
+ await call.reachPerson(await call.getVariable("patientName"));
49
+ });
50
+ agent.onSearchQuery("appointment_time", async (_call, query) => {
51
+ return datetimeFilter.filter(query, { maxResults: 3 });
52
+ });
53
+ agent.onReachPerson(async (call, outcome) => {
54
+ if (outcome === "available") {
55
+ await call.setTask({
56
+ taskId: "schedule_appointment",
69
57
  checklist: [
70
- "tell them that it's been a while since their regular cleaning with Dr. Teeth, and ask if they would like to schedule an appointment now.",
71
- // We have one field to collect, which is the appointment_time.
58
+ "Tell them that it's been a while since their regular cleaning with Dr. Teeth.",
72
59
  guava.Field({
73
60
  key: "appointment_time",
74
61
  fieldType: "calendar_slot",
75
62
  description: "Find a time that works for the caller",
76
- // The choiceGenerator will be called when negotiating a calendar slot.
77
- // We respond with a list of datetime options based on the user's
78
- // criteria, which is summarized in the query string.
79
- choiceGenerator: async (query) => {
80
- // Query will have some natural language preferences like "early morning" or
81
- // "next week". The dateTime filter queries our calendar for matching slots.
82
- const result = await this.datetimeFilter.filter(query, { maxResults: 3 });
83
- this.logger.info("Appointment slot matches: %s", JSON.stringify(result));
84
- return result;
85
- },
63
+ searchable: true,
86
64
  }),
87
- "tell them their appointment has been confirmed and answer any questions before ending the call.",
65
+ "Tell them their appointment has been confirmed and answer any questions before ending the call.",
88
66
  ],
89
- }, () => this.hangup("Thank them for their time and hang up the call."));
90
- }
91
- recipientUnavailable() {
92
- this.hangup("Apologize for your mistake and hang up the call.");
67
+ });
93
68
  }
94
- onSessionDone() {
95
- // This callback is invoked at the end of the bot session.
96
- const selectedTime = this.getField("appointment_time");
97
- if (selectedTime) {
98
- this.logger.info(`Appointment confirmed for: ${selectedTime}`);
99
- }
69
+ else {
70
+ await call.hangup("Apologize for your mistake and hang up the call.");
100
71
  }
101
- }
72
+ });
73
+ agent.onTaskComplete("schedule_appointment", async (call) => {
74
+ await call.hangup("Thank them for their time and hang up the call.");
75
+ });
102
76
  async function run(args) {
103
77
  const [toNumber, patientName = "Benjamin Buttons"] = args;
104
78
  if (!toNumber) {
105
79
  console.error("Usage: guava-example scheduling-outbound <phone> [name]");
106
80
  process.exit(1);
107
81
  }
108
- new guava.Client().createOutbound(process.env.GUAVA_AGENT_NUMBER, toNumber, new SchedulingController(patientName));
82
+ agent.outboundPhone(process.env.GUAVA_AGENT_NUMBER, toNumber, {
83
+ patientName: patientName,
84
+ });
109
85
  }
110
86
  //# sourceMappingURL=scheduling-outbound.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"scheduling-outbound.js","sourceRoot":"","sources":["../../examples/scheduling-outbound.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+EA,kBAaC;AA5FD,2DAA6C;AAC7C,+DAAoE;AACpE,mEAA6E;AAE7E,MAAM,oBAAqB,SAAQ,KAAK,CAAC,cAAc;IACpC,WAAW,CAAS;IACpB,cAAc,CAAiB;IAEhD,YAAY,WAAmB;QAC7B,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAE/B,yFAAyF;QACzF,yFAAyF;QACzF,IAAI,CAAC,cAAc,GAAG,IAAI,uBAAc,CAAC;YACvC,UAAU,EAAE,IAAA,wCAAyB,GAAE;SACxC,CAAC,CAAC;QAEH,8FAA8F;QAC9F,IAAI,CAAC,UAAU,CAAC;YACd,gBAAgB,EAAE,qBAAqB;YACvC,SAAS,EAAE,OAAO;YAClB,YAAY,EAAE,mBAAmB,WAAW,6CAA6C;SAC1F,CAAC,CAAC;QAEH,k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ZodArray<z.ZodString>>;
12
12
  choiceGenerator: z.ZodOptional<z.ZodCustom<ChoiceGenerator, ChoiceGenerator>>;
13
+ searchable: z.ZodDefault<z.ZodBoolean>;
13
14
  }, z.core.$strip>;
14
15
  export type FieldItem = z.input<typeof FieldItem>;
15
16
  export declare const SerializableFieldItem: z.ZodObject<{
@@ -59,5 +60,6 @@ export declare function Field(options: {
59
60
  required?: boolean;
60
61
  choices?: string[];
61
62
  choiceGenerator?: ChoiceGenerator;
63
+ searchable?: boolean;
62
64
  }): FieldItem;
63
65
  export declare function Say(statement: string): SayItem;
@@ -47,6 +47,7 @@ exports.FieldItem = z
47
47
  required: z.boolean().default(true),
48
48
  choices: z.array(z.string()).default([]),
49
49
  choiceGenerator: z.custom((val) => typeof val === "function").optional(),
50
+ searchable: z.boolean().default(false),
50
51
  })
51
52
  .refine((field) => {
52
53
  if (field.field_type === "multiple_choice" && field.choices.length > 10) {
@@ -83,6 +84,7 @@ function Field(options) {
83
84
  required: options.required,
84
85
  choices: options.choices,
85
86
  choiceGenerator: options.choiceGenerator,
87
+ searchable: options.searchable,
86
88
  });
87
89
  }
88
90
  function Say(statement) {
@@ -91,4 +93,4 @@ function Say(statement) {
91
93
  statement: statement,
92
94
  });
93
95
  }
94
- //# sourceMappingURL=action_item.js.map
96
+ //# sourceMappingURL=action-item.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-item.js","sourceRoot":"","sources":["../../src/action-item.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,sBAmBC;AAED,kBAKC;AAvFD,uCAAyB;AAEZ,QAAA,aAAa,GAAG,CAAC,CAAC,KAAK,CACjC,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,iBAAiB,EAAE,eAAe,CAAW,CAAC,GAAG,CACxF,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CACxB,CACF,CAAC;AA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,UAAU,EAAE,OAAO,CAAC,UAAU;KAC/B,CAAC,CAAC;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"}
@@ -0,0 +1,72 @@
1
+ import WebSocket from "ws";
2
+ import { Call } from "./index.ts";
3
+ import { type CallerSpeechEvent, type AgentSpeechEvent } from "./events.ts";
4
+ export interface CallInfo {
5
+ caller_number?: string;
6
+ agent_number?: string;
7
+ }
8
+ export type IncomingCallAction = {
9
+ action: "accept";
10
+ } | {
11
+ action: "decline";
12
+ };
13
+ export interface SuggestedAction {
14
+ key: string;
15
+ description?: string;
16
+ }
17
+ export type InboundConnection = {
18
+ agent_number: string;
19
+ } | {
20
+ webrtc_code: string;
21
+ };
22
+ export declare class Agent {
23
+ private _name?;
24
+ private _organization?;
25
+ private _purpose?;
26
+ private _logger;
27
+ private _client;
28
+ private _onCallReceived;
29
+ private _onCallStart?;
30
+ private _onCallerSpeech?;
31
+ private _onAgentSpeech?;
32
+ private _onQuestion?;
33
+ private _onTaskCompleteGeneric?;
34
+ private _onTaskCompleteHandlers;
35
+ private _searchQueryHandlers;
36
+ private _onActionRequested?;
37
+ private _onActionGeneric?;
38
+ private _onActionHandlers;
39
+ private _onSessionEnd?;
40
+ constructor(args?: {
41
+ name?: string;
42
+ organization?: string;
43
+ purpose?: string;
44
+ });
45
+ onCallReceived(callback: (callInfo: CallInfo) => Promise<IncomingCallAction>): void;
46
+ onCallStart(callback: (call: Call) => Promise<void>): void;
47
+ onCallerSpeech(callback: (call: Call, event: CallerSpeechEvent) => Promise<void>): void;
48
+ onAgentSpeech(callback: (call: Call, event: AgentSpeechEvent) => Promise<void>): void;
49
+ onQuestion(callback: (call: Call, question: string) => Promise<string>): void;
50
+ onTaskComplete(callback: (call: Call, taskId: string) => Promise<void>): void;
51
+ onTaskComplete(taskName: string, callback: (call: Call) => Promise<void>): void;
52
+ onSearchQuery(fieldKey: string, callback: (call: Call, query: string) => Promise<[string[], string[]]>): void;
53
+ onActionRequest(callback: (call: Call, intentSummary: string) => Promise<SuggestedAction | undefined>): void;
54
+ onAction(callback: (call: Call, actionKey: string) => Promise<void>): void;
55
+ onAction(actionKey: string, callback: (call: Call) => Promise<void>): void;
56
+ onSessionEnd(callback: (call: Call) => Promise<void>): void;
57
+ onReachPerson(callback: (call: Call, availability: string) => Promise<void>): void;
58
+ inboundPhone(phoneNumber: string): InboundListener;
59
+ private _dispatchEvent;
60
+ _startCall(variables?: Record<string, any>): Promise<Call>;
61
+ _listenInbound(conn: InboundConnection): InboundListener;
62
+ /**
63
+ * @description use the Guava API to call out to a number
64
+ */
65
+ outboundPhone(fromNumber: string | undefined, toNumber: string, variables?: Record<string, any>): Promise<void>;
66
+ }
67
+ declare class InboundListener {
68
+ private ws;
69
+ constructor(ws: WebSocket);
70
+ close(): void;
71
+ }
72
+ export {};