create-scout9 1.0.0-alpha.0.0.6 → 1.0.0-alpha.0.0.8

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/bin.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import fs from 'node:fs';
3
3
  import path from 'node:path';
4
4
  import * as p from '@clack/prompts';
5
- import { bold, cyan, grey, yellow } from 'kleur/colors';
5
+ import { bold, cyan, grey, yellow, green, magenta } from 'kleur/colors';
6
6
  import { create } from './index.js';
7
7
  import { dist, package_manager } from './utils.js';
8
8
 
@@ -151,7 +151,9 @@ if (relative !== '') {
151
151
  console.log(` ${i++}: ${bold(cyan(`${package_manager} install`))}`);
152
152
  // prettier-ignore
153
153
  console.log(` ${i++}: ${bold(cyan('git init && git add -A && git commit -m "Initial commit"'))} (optional)`);
154
+ console.log(` ${i++}: ${bold(magenta('Add SCOUT9_API_KEY to .env'))} (To get key https://scout9.com/b)`);
155
+ // console.log(` ${i++}: ${bold(cyan(`${package_manager} run dev`))}`);
154
156
  console.log(` ${i++}: ${bold(cyan(`${package_manager} run dev -- --open`))}`);
155
157
 
156
158
  // console.log(`\nTo close the dev server, hit ${bold(cyan('Ctrl-C'))}`);
157
- console.log(`\nStuck? Visit us at ${cyan('https://scout9.dev/chat')}`);
159
+ console.log(`\nStuck? Connect with us on ${bold('Discord')} ${cyan('https://discord.gg/kG8hZwc5sQ')}`);
package/dist/shared.json CHANGED
@@ -93,7 +93,7 @@
93
93
  "jest"
94
94
  ],
95
95
  "exclude": [],
96
- "contents": "import { createMockWorkflowEvent } from '../platform/src/index.js';\nimport Scout9App from './app.js';\n\ndescribe('Scout9App', () => {\n\n it('Should try to ask customer what type of pizza they want', async () => {\n const event = createMockWorkflowEvent('Hey I would like a pizza', 'pizzaOrder');\n\n // Alternatively you can run the app using sendEvent\n // const response = await sendEvent(event);\n\n const response = await Scout9App(event);\n expect(response.instructions).toEqual('Figure out what pizza sizes, toppings are needed for order');\n });\n\n});\n"
96
+ "contents": "import Scout9App from './app.js';\nimport { createMockWorkflowEvent } from '@scout9/app';\n\ndescribe('Scout9App', () => {\n\n it('Should try to ask customer what type of pizza they want', async () => {\n const event = createMockWorkflowEvent('Hey I would like a pizza', 'pizzaOrder');\n\n // Alternatively you can run the app using sendEvent\n // const response = await sendEvent(event);\n\n const response = await Scout9App(event);\n expect(response.instructions).toEqual('Figure out what pizza sizes, toppings are needed for order');\n });\n\n});\n"
97
97
  },
98
98
  {
99
99
  "name": "package.json",
@@ -9,11 +9,11 @@
9
9
  },
10
10
  {
11
11
  "name": "src/entities/customers/[customer]/api.js",
12
- "contents": "import { json } from '@scout9/app';\n\n// @TODO replace with your CRM api\nimport { customerMockDb } from '../../../lib/customer-mock-db';\n\n/**\n * Get customer info from your CRM\n * @returns {Promise<EventResponse<Customer>>}\n */\nexport const GET = async ({params}) => {\n return json(await customerMockDb.get(params.customer));\n};\n\n/**\n * When a customer is created on scout9's side\n *\n * Example:\n * A new or unrecognized customer has contacted an agent. Scout9 has captured some preliminary information\n * about them and sent this POST request. Take the information to either add a new customer record to your CRM\n * or return an existing customer id to map the correct customer document.\n *\n * @returns {Promise<EventResponse>}\n */\nexport const POST = async ({params, body: newCustomer}) => {\n // Scout9 will generate random id for new customers, but whatever id you return back will be used for the new customer\n const {id: crmId} = await customerMockDb.add(params.customer, newCustomer);\n return json({success: true, id: crmId}, {status: 200});\n};\n\n/**\n * New customer info revealed, use this to save the customer info to your CRM\n *\n * Example:\n * In a conversation, if any new data is found, Scout9 will send a PUT or PATCH request to allow for you to update\n * your CRM accordingly.\n *\n * @returns {Promise<EventResponse>}\n */\nexport const PUT = async ({params, body: updatedCustomer}) => {\n // const id = params.customer;\n\n console.log('updatedCustomer', updatedCustomer);\n // @TODO REST call to api to save customer info\n\n // @TODO REST call to api to save customer info\n return json({success: true}, {status: 200});\n};\n\n\n/**\n * Customer request to be removed from platform, use this to remove/update the customer info from your CRM\n *\n * Example:\n * A customer has opt-out of text messaging, Scout9 will send a DELETE message for you to remove any data, returning\n * back success: true will then have Scout9 delete any data on their end as well.\n *\n * @returns {Promise<EventResponse>}\n */\nexport const DELETE = async ({params, request}) => {\n await customerMockDb.remove(params.customer);\n return json({success: true}, {status: 200});\n};\n"
12
+ "contents": "import { json } from '@scout9/app';\n\n// @TODO replace with your CRM api\nimport { customerDb } from '../../../lib/customer-db.js';\n\n/**\n * Get customer info from your CRM\n * @returns {Promise<EventResponse<Customer>>}\n */\nexport const GET = async ({params}) => {\n return json(await customerDb.get(params.customer));\n};\n\n/**\n * When a customer is created on scout9's side\n *\n * Example:\n * A new or unrecognized customer has contacted an agent. Scout9 has captured some preliminary information\n * about them and sent this POST request. Take the information to either add a new customer record to your CRM\n * or return an existing customer id to map the correct customer document.\n *\n * @returns {Promise<EventResponse>}\n */\nexport const POST = async ({params, body: newCustomer}) => {\n // Scout9 will generate random id for new customers, but whatever id you return back will be used for the new customer\n const {id: crmId} = await customerDb.add({$id: params.customer, newCustomer});\n return json({success: true, id: crmId}, {status: 200});\n};\n\n/**\n * New customer info revealed, use this to save the customer info to your CRM\n *\n * Example:\n * In a conversation, if any new data is found, Scout9 will send a PUT or PATCH request to allow for you to update\n * your CRM accordingly.\n *\n * @returns {Promise<EventResponse>}\n */\nexport const PUT = async ({params, body: updatedCustomer}) => {\n // const id = params.customer;\n\n console.log('updatedCustomer', updatedCustomer);\n // @TODO REST call to api to save customer info\n\n // @TODO REST call to api to save customer info\n return json({success: true}, {status: 200});\n};\n\n\n/**\n * Customer request to be removed from platform, use this to remove/update the customer info from your CRM\n *\n * Example:\n * A customer has opt-out of text messaging, Scout9 will send a DELETE message for you to remove any data, returning\n * back success: true will then have Scout9 delete any data on their end as well.\n *\n * @returns {Promise<EventResponse>}\n */\nexport const DELETE = async ({params, request}) => {\n await customerDb.remove(params.customer);\n return json({success: true}, {status: 200});\n};\n"
13
13
  },
14
14
  {
15
15
  "name": "src/entities/customers/api.js",
16
- "contents": "import { customerMockDb } from '../../lib/customer-mock-db.js';\nimport { EventResponse } from '@scout9/app';\n\n/**\n * Required entity - use this to sync with your CRM\n *\n * Query customer info from your CRM\n * @returns {Promise<EventResponse<Array<Customer>>>}\n */\nexport const QUERY = async ({searchParams}) => {\n const {page, q, orderBy, endAt, startAt, limit} = searchParams;\n const customers = await customerMockDb.query(\n q,\n page ? parseInt(page) : undefined,\n limit ? parseInt(limit) : undefined,\n orderBy ? parseInt(orderBy) : undefined,\n endAt ? parseInt(endAt) : undefined,\n startAt ? parseInt(startAt) : undefined,\n );\n return EventResponse.json(customers, {status: 200});\n};\n"
16
+ "contents": "import { customerDb } from '../../lib/customer-db.js';\nimport { EventResponse } from '@scout9/app';\n\n/**\n * Required entity - use this to sync with your CRM\n *\n * Query customer info from your CRM\n * @returns {Promise<EventResponse<Array<Customer>>>}\n */\nexport const QUERY = async ({searchParams}) => {\n const {page, q, orderBy, endAt, startAt, limit} = searchParams;\n return\n const customers = await customerDb.query(\n q,\n page ? parseInt(page) : undefined,\n limit ? parseInt(limit) : undefined,\n orderBy ? parseInt(orderBy) : undefined,\n endAt ? parseInt(endAt) : undefined,\n startAt ? parseInt(startAt) : undefined,\n );\n return EventResponse.json(customers, {status: 200});\n};\n"
17
17
  },
18
18
  {
19
19
  "name": "src/entities/deliveryMethod/index.js",
@@ -28,8 +28,8 @@
28
28
  "contents": "/**\n * Configuration for the Scout9 project.\n * @type {Scout9ProjectConfig}\n */\nexport default {\n\n /**\n * Configure large language model (LLM) settings to generate auto replies\n */\n llm: {\n engine: 'openai',\n model: 'gpt-3.5-turbo',\n },\n /**\n * Configure personal model transformer (PMT) settings to align auto replies the agent's tone\n */\n pmt: {\n engine: 'scout9',\n model: 'orin-2.2'\n },\n}\n"
29
29
  },
30
30
  {
31
- "name": "src/lib/customer-mock-db.js",
32
- "contents": "/**\n * This an example adapter for a mock database to your CRM\n */\nexport const customerMockDb = {\n query: async (\n query,\n page,\n limit,\n orderBy,\n endAt,\n startAt,\n ) => Promise.resolve([{id: '1234', name: 'Test Customer', email: '', phone: ''}]),\n get: async (id) => Promise.resolve({id, name: 'Test Customer', email: '', phone: ''}),\n add: async (id, customer) => ({id}),\n update: async (id, updates) => true,\n remove: async (id) => true\n}\n"
31
+ "name": "src/lib/customer-db.js",
32
+ "contents": "import {Scout9CRM} from '@scout9/crm';\n\nconst crm = new Scout9CRM({apiKey: process.env.SCOUT9_API_KEY});\n\n/**\n * This an example adapter for a mock database to your CRM\n */\nexport const customerDb = {\n query: async (\n query,\n page,\n limit,\n orderBy,\n endAt,\n startAt,\n ) => crm.query(query, page, limit, orderBy, endAt, startAt),\n get: async (id) => crm.get(id),\n add: async (customer) => crm.add(customer),\n update: async (id, updates) => crm.update({...updates, $id: id}),\n remove: async (id) => crm.remove(id)\n}\n"
33
33
  },
34
34
  {
35
35
  "name": "src/lib/drivers.js",
@@ -9,11 +9,11 @@
9
9
  },
10
10
  {
11
11
  "name": "src/entities/customers/[customer]/api.js",
12
- "contents": "import { json } from '@scout9/app';\n\n// @TODO replace with your CRM api\nimport { customerMockDb } from '../../../lib/customer-mock-db';\n\n/**\n * Get customer info from your CRM\n */\nexport const GET = async ({params}) => {\n return json(await customerMockDb.get(params.customer));\n};\n\n/**\n * When a customer is created on scout9's side\n *\n * Example:\n * A new or unrecognized customer has contacted an agent. Scout9 has captured some preliminary information\n * about them and sent this POST request. Take the information to either add a new customer record to your CRM\n * or return an existing customer id to map the correct customer document.\n *\n */\nexport const POST = async ({params, body: newCustomer}) => {\n // Scout9 will generate random id for new customers, but whatever id you return back will be used for the new customer\n const {id: crmId} = await customerMockDb.add(params.customer, newCustomer);\n return json({success: true, id: crmId}, {status: 200});\n};\n\n/**\n * New customer info revealed, use this to save the customer info to your CRM\n *\n * Example:\n * In a conversation, if any new data is found, Scout9 will send a PUT or PATCH request to allow for you to update\n * your CRM accordingly.\n *\n */\nexport const PUT = async ({params, body: updatedCustomer}) => {\n // const id = params.customer;\n\n console.log('updatedCustomer', updatedCustomer);\n // @TODO REST call to api to save customer info\n\n // @TODO REST call to api to save customer info\n return json({success: true}, {status: 200});\n};\n\n\n/**\n * Customer request to be removed from platform, use this to remove/update the customer info from your CRM\n *\n * Example:\n * A customer has opt-out of text messaging, Scout9 will send a DELETE message for you to remove any data, returning\n * back success: true will then have Scout9 delete any data on their end as well.\n *\n */\nexport const DELETE = async ({params, request}) => {\n await customerMockDb.remove(params.customer);\n return json({success: true}, {status: 200});\n};\n"
12
+ "contents": "import { json } from '@scout9/app';\n\n// @TODO replace with your CRM api\nimport { customerDb } from '../../../lib/customer-db.js';\n\n/**\n * Get customer info from your CRM\n */\nexport const GET = async ({params}) => {\n return json(await customerDb.get(params.customer));\n};\n\n/**\n * When a customer is created on scout9's side\n *\n * Example:\n * A new or unrecognized customer has contacted an agent. Scout9 has captured some preliminary information\n * about them and sent this POST request. Take the information to either add a new customer record to your CRM\n * or return an existing customer id to map the correct customer document.\n *\n */\nexport const POST = async ({params, body: newCustomer}) => {\n // Scout9 will generate random id for new customers, but whatever id you return back will be used for the new customer\n const {id: crmId} = await customerDb.add({$id: params.customer, newCustomer});\n return json({success: true, id: crmId}, {status: 200});\n};\n\n/**\n * New customer info revealed, use this to save the customer info to your CRM\n *\n * Example:\n * In a conversation, if any new data is found, Scout9 will send a PUT or PATCH request to allow for you to update\n * your CRM accordingly.\n *\n */\nexport const PUT = async ({params, body: updatedCustomer}) => {\n // const id = params.customer;\n\n console.log('updatedCustomer', updatedCustomer);\n // @TODO REST call to api to save customer info\n\n // @TODO REST call to api to save customer info\n return json({success: true}, {status: 200});\n};\n\n\n/**\n * Customer request to be removed from platform, use this to remove/update the customer info from your CRM\n *\n * Example:\n * A customer has opt-out of text messaging, Scout9 will send a DELETE message for you to remove any data, returning\n * back success: true will then have Scout9 delete any data on their end as well.\n *\n */\nexport const DELETE = async ({params, request}) => {\n await customerDb.remove(params.customer);\n return json({success: true}, {status: 200});\n};\n"
13
13
  },
14
14
  {
15
15
  "name": "src/entities/customers/api.js",
16
- "contents": "import { customerMockDb } from '../../lib/customer-mock-db.js';\nimport { EventResponse } from '@scout9/app';\n\n/**\n * Required entity - use this to sync with your CRM\n *\n * Query customer info from your CRM\n */\nexport const QUERY = async ({searchParams}) => {\n const {page, q, orderBy, endAt, startAt, limit} = searchParams;\n const customers = await customerMockDb.query(\n q,\n page ? parseInt(page) : undefined,\n limit ? parseInt(limit) : undefined,\n orderBy ? parseInt(orderBy) : undefined,\n endAt ? parseInt(endAt) : undefined,\n startAt ? parseInt(startAt) : undefined,\n );\n return EventResponse.json(customers, {status: 200});\n};\n"
16
+ "contents": "import { customerDb } from '../../lib/customer-db.js';\nimport { EventResponse } from '@scout9/app';\n\n/**\n * Required entity - use this to sync with your CRM\n *\n * Query customer info from your CRM\n */\nexport const QUERY = async ({searchParams}) => {\n const {page, q, orderBy, endAt, startAt, limit} = searchParams;\n return\n const customers = await customerDb.query(\n q,\n page ? parseInt(page) : undefined,\n limit ? parseInt(limit) : undefined,\n orderBy ? parseInt(orderBy) : undefined,\n endAt ? parseInt(endAt) : undefined,\n startAt ? parseInt(startAt) : undefined,\n );\n return EventResponse.json(customers, {status: 200});\n};\n"
17
17
  },
18
18
  {
19
19
  "name": "src/entities/deliveryMethod/index.js",
@@ -28,8 +28,8 @@
28
28
  "contents": "/**\n * Configuration for the Scout9 project.\n */\nexport default {\n\n /**\n * Configure large language model (LLM) settings to generate auto replies\n */\n llm: {\n engine: 'openai',\n model: 'gpt-3.5-turbo',\n },\n /**\n * Configure personal model transformer (PMT) settings to align auto replies the agent's tone\n */\n pmt: {\n engine: 'scout9',\n model: 'orin-2.2'\n },\n}\n"
29
29
  },
30
30
  {
31
- "name": "src/lib/customer-mock-db.js",
32
- "contents": "/**\n * This an example adapter for a mock database to your CRM\n */\nexport const customerMockDb = {\n query: async (\n query,\n page,\n limit,\n orderBy,\n endAt,\n startAt,\n ) => Promise.resolve([{id: '1234', name: 'Test Customer', email: '', phone: ''}]),\n get: async (id) => Promise.resolve({id, name: 'Test Customer', email: '', phone: ''}),\n add: async (id, customer) => ({id}),\n update: async (id, updates) => true,\n remove: async (id) => true\n}\n"
31
+ "name": "src/lib/customer-db.js",
32
+ "contents": "import {Scout9CRM} from '@scout9/crm';\n\nconst crm = new Scout9CRM({apiKey: process.env.SCOUT9_API_KEY});\n\n/**\n * This an example adapter for a mock database to your CRM\n */\nexport const customerDb = {\n query: async (\n query,\n page,\n limit,\n orderBy,\n endAt,\n startAt,\n ) => crm.query(query, page, limit, orderBy, endAt, startAt),\n get: async (id) => crm.get(id),\n add: async (customer) => crm.add(customer),\n update: async (id, updates) => crm.update({...updates, $id: id}),\n remove: async (id) => crm.remove(id)\n}\n"
33
33
  },
34
34
  {
35
35
  "name": "src/lib/drivers.js",
@@ -9,11 +9,11 @@
9
9
  },
10
10
  {
11
11
  "name": "src/entities/customers/[customer]/api.js",
12
- "contents": "import { json } from '@scout9/app';\n\n// @TODO replace with your CRM api\nimport { customerMockDb } from '../../../lib/customer-mock-db';\n\n/**\n * Get customer info from your CRM\n */\nexport const GET = async ({params}) => {\n return json(await customerMockDb.get(params.customer));\n};\n\n/**\n * When a customer is created on scout9's side\n *\n * Example:\n * A new or unrecognized customer has contacted an agent. Scout9 has captured some preliminary information\n * about them and sent this POST request. Take the information to either add a new customer record to your CRM\n * or return an existing customer id to map the correct customer document.\n *\n */\nexport const POST = async ({params, body: newCustomer}) => {\n // Scout9 will generate random id for new customers, but whatever id you return back will be used for the new customer\n const {id: crmId} = await customerMockDb.add(params.customer, newCustomer);\n return json({success: true, id: crmId}, {status: 200});\n};\n\n/**\n * New customer info revealed, use this to save the customer info to your CRM\n *\n * Example:\n * In a conversation, if any new data is found, Scout9 will send a PUT or PATCH request to allow for you to update\n * your CRM accordingly.\n *\n */\nexport const PUT = async ({params, body: updatedCustomer}) => {\n // const id = params.customer;\n\n console.log('updatedCustomer', updatedCustomer);\n // @TODO REST call to api to save customer info\n\n // @TODO REST call to api to save customer info\n return json({success: true}, {status: 200});\n};\n\n\n/**\n * Customer request to be removed from platform, use this to remove/update the customer info from your CRM\n *\n * Example:\n * A customer has opt-out of text messaging, Scout9 will send a DELETE message for you to remove any data, returning\n * back success: true will then have Scout9 delete any data on their end as well.\n *\n */\nexport const DELETE = async ({params, request}) => {\n await customerMockDb.remove(params.customer);\n return json({success: true}, {status: 200});\n};\n"
12
+ "contents": "import { json } from '@scout9/app';\n\n// @TODO replace with your CRM api\nimport { customerDb } from '../../../lib/customer-db.js';\n\n/**\n * Get customer info from your CRM\n */\nexport const GET = async ({params}) => {\n return json(await customerDb.get(params.customer));\n};\n\n/**\n * When a customer is created on scout9's side\n *\n * Example:\n * A new or unrecognized customer has contacted an agent. Scout9 has captured some preliminary information\n * about them and sent this POST request. Take the information to either add a new customer record to your CRM\n * or return an existing customer id to map the correct customer document.\n *\n */\nexport const POST = async ({params, body: newCustomer}) => {\n // Scout9 will generate random id for new customers, but whatever id you return back will be used for the new customer\n const {id: crmId} = await customerDb.add({$id: params.customer, newCustomer});\n return json({success: true, id: crmId}, {status: 200});\n};\n\n/**\n * New customer info revealed, use this to save the customer info to your CRM\n *\n * Example:\n * In a conversation, if any new data is found, Scout9 will send a PUT or PATCH request to allow for you to update\n * your CRM accordingly.\n *\n */\nexport const PUT = async ({params, body: updatedCustomer}) => {\n // const id = params.customer;\n\n console.log('updatedCustomer', updatedCustomer);\n // @TODO REST call to api to save customer info\n\n // @TODO REST call to api to save customer info\n return json({success: true}, {status: 200});\n};\n\n\n/**\n * Customer request to be removed from platform, use this to remove/update the customer info from your CRM\n *\n * Example:\n * A customer has opt-out of text messaging, Scout9 will send a DELETE message for you to remove any data, returning\n * back success: true will then have Scout9 delete any data on their end as well.\n *\n */\nexport const DELETE = async ({params, request}) => {\n await customerDb.remove(params.customer);\n return json({success: true}, {status: 200});\n};\n"
13
13
  },
14
14
  {
15
15
  "name": "src/entities/customers/api.js",
16
- "contents": "import { customerMockDb } from '../../lib/customer-mock-db.js';\nimport { EventResponse } from '@scout9/app';\n\n/**\n * Required entity - use this to sync with your CRM\n *\n * Query customer info from your CRM\n */\nexport const QUERY = async ({searchParams}) => {\n const {page, q, orderBy, endAt, startAt, limit} = searchParams;\n const customers = await customerMockDb.query(\n q,\n page ? parseInt(page) : undefined,\n limit ? parseInt(limit) : undefined,\n orderBy ? parseInt(orderBy) : undefined,\n endAt ? parseInt(endAt) : undefined,\n startAt ? parseInt(startAt) : undefined,\n );\n return EventResponse.json(customers, {status: 200});\n};\n"
16
+ "contents": "import { customerDb } from '../../lib/customer-db.js';\nimport { EventResponse } from '@scout9/app';\n\n/**\n * Required entity - use this to sync with your CRM\n *\n * Query customer info from your CRM\n */\nexport const QUERY = async ({searchParams}) => {\n const {page, q, orderBy, endAt, startAt, limit} = searchParams;\n return\n const customers = await customerDb.query(\n q,\n page ? parseInt(page) : undefined,\n limit ? parseInt(limit) : undefined,\n orderBy ? parseInt(orderBy) : undefined,\n endAt ? parseInt(endAt) : undefined,\n startAt ? parseInt(startAt) : undefined,\n );\n return EventResponse.json(customers, {status: 200});\n};\n"
17
17
  },
18
18
  {
19
19
  "name": "src/entities/deliveryMethod/index.js",
@@ -28,8 +28,8 @@
28
28
  "contents": "/**\n * Configuration for the Scout9 project.\n */\nexport default {\n\n /**\n * Configure large language model (LLM) settings to generate auto replies\n */\n llm: {\n engine: 'openai',\n model: 'gpt-3.5-turbo',\n },\n /**\n * Configure personal model transformer (PMT) settings to align auto replies the agent's tone\n */\n pmt: {\n engine: 'scout9',\n model: 'orin-2.2'\n },\n}\n"
29
29
  },
30
30
  {
31
- "name": "src/lib/customer-mock-db.js",
32
- "contents": "/**\n * This an example adapter for a mock database to your CRM\n */\nexport const customerMockDb = {\n query: async (\n query,\n page,\n limit,\n orderBy,\n endAt,\n startAt,\n ) => Promise.resolve([{id: '1234', name: 'Test Customer', email: '', phone: ''}]),\n get: async (id) => Promise.resolve({id, name: 'Test Customer', email: '', phone: ''}),\n add: async (id, customer) => ({id}),\n update: async (id, updates) => true,\n remove: async (id) => true\n}\n"
31
+ "name": "src/lib/customer-db.js",
32
+ "contents": "import {Scout9CRM} from '@scout9/crm';\n\nconst crm = new Scout9CRM({apiKey: process.env.SCOUT9_API_KEY});\n\n/**\n * This an example adapter for a mock database to your CRM\n */\nexport const customerDb = {\n query: async (\n query,\n page,\n limit,\n orderBy,\n endAt,\n startAt,\n ) => crm.query(query, page, limit, orderBy, endAt, startAt),\n get: async (id) => crm.get(id),\n add: async (customer) => crm.add(customer),\n update: async (id, updates) => crm.update({...updates, $id: id}),\n remove: async (id) => crm.remove(id)\n}\n"
33
33
  },
34
34
  {
35
35
  "name": "src/lib/drivers.js",
@@ -4,10 +4,12 @@
4
4
  "scripts": {
5
5
  "deploy": "scout9 deploy",
6
6
  "build": "scout9 build",
7
- "test": "scout9 test"
7
+ "sync": "scout9 sync",
8
+ "dev": "scout9 dev"
8
9
  },
9
10
  "dependencies": {
10
- "@scout9/app": "latest"
11
+ "@scout9/app": "latest",
12
+ "@scout9/crm": "latest"
11
13
  },
12
14
  "type": "module"
13
15
  }
@@ -9,19 +9,19 @@
9
9
  },
10
10
  {
11
11
  "name": "src/entities/customers/[customer]/api.js",
12
- "contents": "import { json } from '@scout9/app';\n\n// @TODO replace with your CRM api\nimport { customerMockDb } from '../../../lib/customer-mock-db';\n\n/**\n * Get customer info from your CRM\n * @returns {Promise<EventResponse<Customer>>}\n */\nexport const GET = async ({params}) => {\n return json(await customerMockDb.get(params.customer));\n};\n\n/**\n * When a customer is created on scout9's side\n *\n * Example:\n * A new or unrecognized customer has contacted an agent. Scout9 has captured some preliminary information\n * about them and sent this POST request. Take the information to either add a new customer record to your CRM\n * or return an existing customer id to map the correct customer document.\n *\n * @returns {Promise<EventResponse>}\n */\nexport const POST = async ({params, body: newCustomer}) => {\n // Scout9 will generate random id for new customers, but whatever id you return back will be used for the new customer\n const {id: crmId} = await customerMockDb.add(params.customer, newCustomer);\n return json({success: true, id: crmId}, {status: 200});\n};\n\n/**\n * New customer info revealed, use this to save the customer info to your CRM\n *\n * Example:\n * In a conversation, if any new data is found, Scout9 will send a PUT or PATCH request to allow for you to update\n * your CRM accordingly.\n *\n * @returns {Promise<EventResponse>}\n */\nexport const PUT = async ({params, body: updatedCustomer}) => {\n // const id = params.customer;\n\n console.log('updatedCustomer', updatedCustomer);\n // @TODO REST call to api to save customer info\n\n // @TODO REST call to api to save customer info\n return json({success: true}, {status: 200});\n};\n\n\n/**\n * Customer request to be removed from platform, use this to remove/update the customer info from your CRM\n *\n * Example:\n * A customer has opt-out of text messaging, Scout9 will send a DELETE message for you to remove any data, returning\n * back success: true will then have Scout9 delete any data on their end as well.\n *\n * @returns {Promise<EventResponse>}\n */\nexport const DELETE = async ({params, request}) => {\n await customerMockDb.remove(params.customer);\n return json({success: true}, {status: 200});\n};\n"
12
+ "contents": "import { json } from '@scout9/app';\n\n// @TODO replace with your CRM api\nimport { customerDb } from '../../../lib/customer-db.js';\n\n/**\n * Get customer info from your CRM\n * @returns {Promise<EventResponse<Customer>>}\n */\nexport const GET = async ({params}) => {\n return json(await customerDb.get(params.customer));\n};\n\n/**\n * When a customer is created on scout9's side\n *\n * Example:\n * A new or unrecognized customer has contacted an agent. Scout9 has captured some preliminary information\n * about them and sent this POST request. Take the information to either add a new customer record to your CRM\n * or return an existing customer id to map the correct customer document.\n *\n * @returns {Promise<EventResponse>}\n */\nexport const POST = async ({params, body: newCustomer}) => {\n // Scout9 will generate random id for new customers, but whatever id you return back will be used for the new customer\n const {id: crmId} = await customerDb.add({$id: params.customer, newCustomer});\n return json({success: true, id: crmId}, {status: 200});\n};\n\n/**\n * New customer info revealed, use this to save the customer info to your CRM\n *\n * Example:\n * In a conversation, if any new data is found, Scout9 will send a PUT or PATCH request to allow for you to update\n * your CRM accordingly.\n *\n * @returns {Promise<EventResponse>}\n */\nexport const PUT = async ({params, body: updatedCustomer}) => {\n // const id = params.customer;\n\n console.log('updatedCustomer', updatedCustomer);\n // @TODO REST call to api to save customer info\n\n // @TODO REST call to api to save customer info\n return json({success: true}, {status: 200});\n};\n\n\n/**\n * Customer request to be removed from platform, use this to remove/update the customer info from your CRM\n *\n * Example:\n * A customer has opt-out of text messaging, Scout9 will send a DELETE message for you to remove any data, returning\n * back success: true will then have Scout9 delete any data on their end as well.\n *\n * @returns {Promise<EventResponse>}\n */\nexport const DELETE = async ({params, request}) => {\n await customerDb.remove(params.customer);\n return json({success: true}, {status: 200});\n};\n"
13
13
  },
14
14
  {
15
15
  "name": "src/entities/customers/api.js",
16
- "contents": "import { customerMockDb } from '../../lib/customer-mock-db.js';\nimport { EventResponse } from '@scout9/app';\n\n/**\n * Required entity - use this to sync with your CRM\n *\n * Query customer info from your CRM\n * @returns {Promise<EventResponse<Array<Customer>>>}\n */\nexport const QUERY = async ({searchParams}) => {\n const {page, q, orderBy, endAt, startAt, limit} = searchParams;\n const customers = await customerMockDb.query(\n q,\n page ? parseInt(page) : undefined,\n limit ? parseInt(limit) : undefined,\n orderBy ? parseInt(orderBy) : undefined,\n endAt ? parseInt(endAt) : undefined,\n startAt ? parseInt(startAt) : undefined,\n );\n return EventResponse.json(customers, {status: 200});\n};\n"
16
+ "contents": "import { customerDb } from '../../lib/customer-db.js';\nimport { EventResponse } from '@scout9/app';\n\n/**\n * Required entity - use this to sync with your CRM\n *\n * Query customer info from your CRM\n * @returns {Promise<EventResponse<Array<Customer>>>}\n */\nexport const QUERY = async ({searchParams}) => {\n const {page, q, orderBy, endAt, startAt, limit} = searchParams;\n const customers = await customerDb.query(\n q,\n page ? parseInt(page) : undefined,\n limit ? parseInt(limit) : undefined,\n orderBy ? parseInt(orderBy) : undefined,\n endAt ? parseInt(endAt) : undefined,\n startAt ? parseInt(startAt) : undefined,\n );\n return EventResponse.json(customers, {status: 200});\n};\n"
17
17
  },
18
18
  {
19
19
  "name": "src/index.js",
20
20
  "contents": "/**\n * Configuration for the Scout9 project.\n * @type {Scout9ProjectConfig}\n */\nexport default {\n\n /**\n * Configure large language model (LLM) settings to generate auto replies\n */\n llm: {\n engine: 'openai',\n model: 'gpt-3.5-turbo',\n },\n /**\n * Configure personal model transformer (PMT) settings to align auto replies the agent's tone\n */\n pmt: {\n engine: 'scout9',\n model: 'orin-2.2'\n },\n}\n"
21
21
  },
22
22
  {
23
- "name": "src/lib/customer-mock-db.js",
24
- "contents": "/**\n * This an example adapter for a mock database to your CRM\n */\nexport const customerMockDb = {\n query: async (\n query,\n page,\n limit,\n orderBy,\n endAt,\n startAt,\n ) => Promise.resolve([{id: '1234', name: 'Test Customer', email: '', phone: ''}]),\n get: async (id) => Promise.resolve({id, name: 'Test Customer', email: '', phone: ''}),\n add: async (id, customer) => ({id}),\n update: async (id, updates) => true,\n remove: async (id) => true\n}\n"
23
+ "name": "src/lib/customer-db.js",
24
+ "contents": "import {Scout9CRM} from '@scout9/crm';\n\nconst crm = new Scout9CRM({apiKey: process.env.SCOUT9_API_KEY});\n\n/**\n * This an example adapter for a mock database to your CRM\n */\nexport const customerDb = {\n query: async (\n query,\n page,\n limit,\n orderBy,\n endAt,\n startAt,\n ) => crm.query(query, page, limit, orderBy, endAt, startAt),\n get: async (id) => crm.get(id),\n add: async (customer) => crm.add(customer),\n update: async (id, updates) => crm.update({...updates, $id: id}),\n remove: async (id) => crm.remove(id)\n}\n"
25
25
  },
26
26
  {
27
27
  "name": "src/workflows/default/workflow.js",
@@ -9,19 +9,19 @@
9
9
  },
10
10
  {
11
11
  "name": "src/entities/customers/[customer]/api.js",
12
- "contents": "import { json } from '@scout9/app';\n\n// @TODO replace with your CRM api\nimport { customerMockDb } from '../../../lib/customer-mock-db';\n\n/**\n * Get customer info from your CRM\n */\nexport const GET = async ({params}) => {\n return json(await customerMockDb.get(params.customer));\n};\n\n/**\n * When a customer is created on scout9's side\n *\n * Example:\n * A new or unrecognized customer has contacted an agent. Scout9 has captured some preliminary information\n * about them and sent this POST request. Take the information to either add a new customer record to your CRM\n * or return an existing customer id to map the correct customer document.\n *\n */\nexport const POST = async ({params, body: newCustomer}) => {\n // Scout9 will generate random id for new customers, but whatever id you return back will be used for the new customer\n const {id: crmId} = await customerMockDb.add(params.customer, newCustomer);\n return json({success: true, id: crmId}, {status: 200});\n};\n\n/**\n * New customer info revealed, use this to save the customer info to your CRM\n *\n * Example:\n * In a conversation, if any new data is found, Scout9 will send a PUT or PATCH request to allow for you to update\n * your CRM accordingly.\n *\n */\nexport const PUT = async ({params, body: updatedCustomer}) => {\n // const id = params.customer;\n\n console.log('updatedCustomer', updatedCustomer);\n // @TODO REST call to api to save customer info\n\n // @TODO REST call to api to save customer info\n return json({success: true}, {status: 200});\n};\n\n\n/**\n * Customer request to be removed from platform, use this to remove/update the customer info from your CRM\n *\n * Example:\n * A customer has opt-out of text messaging, Scout9 will send a DELETE message for you to remove any data, returning\n * back success: true will then have Scout9 delete any data on their end as well.\n *\n */\nexport const DELETE = async ({params, request}) => {\n await customerMockDb.remove(params.customer);\n return json({success: true}, {status: 200});\n};\n"
12
+ "contents": "import { json } from '@scout9/app';\n\n// @TODO replace with your CRM api\nimport { customerDb } from '../../../lib/customer-db.js';\n\n/**\n * Get customer info from your CRM\n */\nexport const GET = async ({params}) => {\n return json(await customerDb.get(params.customer));\n};\n\n/**\n * When a customer is created on scout9's side\n *\n * Example:\n * A new or unrecognized customer has contacted an agent. Scout9 has captured some preliminary information\n * about them and sent this POST request. Take the information to either add a new customer record to your CRM\n * or return an existing customer id to map the correct customer document.\n *\n */\nexport const POST = async ({params, body: newCustomer}) => {\n // Scout9 will generate random id for new customers, but whatever id you return back will be used for the new customer\n const {id: crmId} = await customerDb.add({$id: params.customer, newCustomer});\n return json({success: true, id: crmId}, {status: 200});\n};\n\n/**\n * New customer info revealed, use this to save the customer info to your CRM\n *\n * Example:\n * In a conversation, if any new data is found, Scout9 will send a PUT or PATCH request to allow for you to update\n * your CRM accordingly.\n *\n */\nexport const PUT = async ({params, body: updatedCustomer}) => {\n // const id = params.customer;\n\n console.log('updatedCustomer', updatedCustomer);\n // @TODO REST call to api to save customer info\n\n // @TODO REST call to api to save customer info\n return json({success: true}, {status: 200});\n};\n\n\n/**\n * Customer request to be removed from platform, use this to remove/update the customer info from your CRM\n *\n * Example:\n * A customer has opt-out of text messaging, Scout9 will send a DELETE message for you to remove any data, returning\n * back success: true will then have Scout9 delete any data on their end as well.\n *\n */\nexport const DELETE = async ({params, request}) => {\n await customerDb.remove(params.customer);\n return json({success: true}, {status: 200});\n};\n"
13
13
  },
14
14
  {
15
15
  "name": "src/entities/customers/api.js",
16
- "contents": "import { customerMockDb } from '../../lib/customer-mock-db.js';\nimport { EventResponse } from '@scout9/app';\n\n/**\n * Required entity - use this to sync with your CRM\n *\n * Query customer info from your CRM\n */\nexport const QUERY = async ({searchParams}) => {\n const {page, q, orderBy, endAt, startAt, limit} = searchParams;\n const customers = await customerMockDb.query(\n q,\n page ? parseInt(page) : undefined,\n limit ? parseInt(limit) : undefined,\n orderBy ? parseInt(orderBy) : undefined,\n endAt ? parseInt(endAt) : undefined,\n startAt ? parseInt(startAt) : undefined,\n );\n return EventResponse.json(customers, {status: 200});\n};\n"
16
+ "contents": "import { customerDb } from '../../lib/customer-db.js';\nimport { EventResponse } from '@scout9/app';\n\n/**\n * Required entity - use this to sync with your CRM\n *\n * Query customer info from your CRM\n */\nexport const QUERY = async ({searchParams}) => {\n const {page, q, orderBy, endAt, startAt, limit} = searchParams;\n const customers = await customerDb.query(\n q,\n page ? parseInt(page) : undefined,\n limit ? parseInt(limit) : undefined,\n orderBy ? parseInt(orderBy) : undefined,\n endAt ? parseInt(endAt) : undefined,\n startAt ? parseInt(startAt) : undefined,\n );\n return EventResponse.json(customers, {status: 200});\n};\n"
17
17
  },
18
18
  {
19
19
  "name": "src/index.js",
20
20
  "contents": "/**\n * Configuration for the Scout9 project.\n */\nexport default {\n\n /**\n * Configure large language model (LLM) settings to generate auto replies\n */\n llm: {\n engine: 'openai',\n model: 'gpt-3.5-turbo',\n },\n /**\n * Configure personal model transformer (PMT) settings to align auto replies the agent's tone\n */\n pmt: {\n engine: 'scout9',\n model: 'orin-2.2'\n },\n}\n"
21
21
  },
22
22
  {
23
- "name": "src/lib/customer-mock-db.js",
24
- "contents": "/**\n * This an example adapter for a mock database to your CRM\n */\nexport const customerMockDb = {\n query: async (\n query,\n page,\n limit,\n orderBy,\n endAt,\n startAt,\n ) => Promise.resolve([{id: '1234', name: 'Test Customer', email: '', phone: ''}]),\n get: async (id) => Promise.resolve({id, name: 'Test Customer', email: '', phone: ''}),\n add: async (id, customer) => ({id}),\n update: async (id, updates) => true,\n remove: async (id) => true\n}\n"
23
+ "name": "src/lib/customer-db.js",
24
+ "contents": "import {Scout9CRM} from '@scout9/crm';\n\nconst crm = new Scout9CRM({apiKey: process.env.SCOUT9_API_KEY});\n\n/**\n * This an example adapter for a mock database to your CRM\n */\nexport const customerDb = {\n query: async (\n query,\n page,\n limit,\n orderBy,\n endAt,\n startAt,\n ) => crm.query(query, page, limit, orderBy, endAt, startAt),\n get: async (id) => crm.get(id),\n add: async (customer) => crm.add(customer),\n update: async (id, updates) => crm.update({...updates, $id: id}),\n remove: async (id) => crm.remove(id)\n}\n"
25
25
  },
26
26
  {
27
27
  "name": "src/workflows/default/workflow.js",
@@ -9,19 +9,19 @@
9
9
  },
10
10
  {
11
11
  "name": "src/entities/customers/[customer]/api.js",
12
- "contents": "import { json } from '@scout9/app';\n\n// @TODO replace with your CRM api\nimport { customerMockDb } from '../../../lib/customer-mock-db';\n\n/**\n * Get customer info from your CRM\n */\nexport const GET = async ({params}) => {\n return json(await customerMockDb.get(params.customer));\n};\n\n/**\n * When a customer is created on scout9's side\n *\n * Example:\n * A new or unrecognized customer has contacted an agent. Scout9 has captured some preliminary information\n * about them and sent this POST request. Take the information to either add a new customer record to your CRM\n * or return an existing customer id to map the correct customer document.\n *\n */\nexport const POST = async ({params, body: newCustomer}) => {\n // Scout9 will generate random id for new customers, but whatever id you return back will be used for the new customer\n const {id: crmId} = await customerMockDb.add(params.customer, newCustomer);\n return json({success: true, id: crmId}, {status: 200});\n};\n\n/**\n * New customer info revealed, use this to save the customer info to your CRM\n *\n * Example:\n * In a conversation, if any new data is found, Scout9 will send a PUT or PATCH request to allow for you to update\n * your CRM accordingly.\n *\n */\nexport const PUT = async ({params, body: updatedCustomer}) => {\n // const id = params.customer;\n\n console.log('updatedCustomer', updatedCustomer);\n // @TODO REST call to api to save customer info\n\n // @TODO REST call to api to save customer info\n return json({success: true}, {status: 200});\n};\n\n\n/**\n * Customer request to be removed from platform, use this to remove/update the customer info from your CRM\n *\n * Example:\n * A customer has opt-out of text messaging, Scout9 will send a DELETE message for you to remove any data, returning\n * back success: true will then have Scout9 delete any data on their end as well.\n *\n */\nexport const DELETE = async ({params, request}) => {\n await customerMockDb.remove(params.customer);\n return json({success: true}, {status: 200});\n};\n"
12
+ "contents": "import { json } from '@scout9/app';\n\n// @TODO replace with your CRM api\nimport { customerDb } from '../../../lib/customer-db.js';\n\n/**\n * Get customer info from your CRM\n */\nexport const GET = async ({params}) => {\n return json(await customerDb.get(params.customer));\n};\n\n/**\n * When a customer is created on scout9's side\n *\n * Example:\n * A new or unrecognized customer has contacted an agent. Scout9 has captured some preliminary information\n * about them and sent this POST request. Take the information to either add a new customer record to your CRM\n * or return an existing customer id to map the correct customer document.\n *\n */\nexport const POST = async ({params, body: newCustomer}) => {\n // Scout9 will generate random id for new customers, but whatever id you return back will be used for the new customer\n const {id: crmId} = await customerDb.add({$id: params.customer, newCustomer});\n return json({success: true, id: crmId}, {status: 200});\n};\n\n/**\n * New customer info revealed, use this to save the customer info to your CRM\n *\n * Example:\n * In a conversation, if any new data is found, Scout9 will send a PUT or PATCH request to allow for you to update\n * your CRM accordingly.\n *\n */\nexport const PUT = async ({params, body: updatedCustomer}) => {\n // const id = params.customer;\n\n console.log('updatedCustomer', updatedCustomer);\n // @TODO REST call to api to save customer info\n\n // @TODO REST call to api to save customer info\n return json({success: true}, {status: 200});\n};\n\n\n/**\n * Customer request to be removed from platform, use this to remove/update the customer info from your CRM\n *\n * Example:\n * A customer has opt-out of text messaging, Scout9 will send a DELETE message for you to remove any data, returning\n * back success: true will then have Scout9 delete any data on their end as well.\n *\n */\nexport const DELETE = async ({params, request}) => {\n await customerDb.remove(params.customer);\n return json({success: true}, {status: 200});\n};\n"
13
13
  },
14
14
  {
15
15
  "name": "src/entities/customers/api.js",
16
- "contents": "import { customerMockDb } from '../../lib/customer-mock-db.js';\nimport { EventResponse } from '@scout9/app';\n\n/**\n * Required entity - use this to sync with your CRM\n *\n * Query customer info from your CRM\n */\nexport const QUERY = async ({searchParams}) => {\n const {page, q, orderBy, endAt, startAt, limit} = searchParams;\n const customers = await customerMockDb.query(\n q,\n page ? parseInt(page) : undefined,\n limit ? parseInt(limit) : undefined,\n orderBy ? parseInt(orderBy) : undefined,\n endAt ? parseInt(endAt) : undefined,\n startAt ? parseInt(startAt) : undefined,\n );\n return EventResponse.json(customers, {status: 200});\n};\n"
16
+ "contents": "import { customerDb } from '../../lib/customer-db.js';\nimport { EventResponse } from '@scout9/app';\n\n/**\n * Required entity - use this to sync with your CRM\n *\n * Query customer info from your CRM\n */\nexport const QUERY = async ({searchParams}) => {\n const {page, q, orderBy, endAt, startAt, limit} = searchParams;\n const customers = await customerDb.query(\n q,\n page ? parseInt(page) : undefined,\n limit ? parseInt(limit) : undefined,\n orderBy ? parseInt(orderBy) : undefined,\n endAt ? parseInt(endAt) : undefined,\n startAt ? parseInt(startAt) : undefined,\n );\n return EventResponse.json(customers, {status: 200});\n};\n"
17
17
  },
18
18
  {
19
19
  "name": "src/index.js",
20
20
  "contents": "/**\n * Configuration for the Scout9 project.\n */\nexport default {\n\n /**\n * Configure large language model (LLM) settings to generate auto replies\n */\n llm: {\n engine: 'openai',\n model: 'gpt-3.5-turbo',\n },\n /**\n * Configure personal model transformer (PMT) settings to align auto replies the agent's tone\n */\n pmt: {\n engine: 'scout9',\n model: 'orin-2.2'\n },\n}\n"
21
21
  },
22
22
  {
23
- "name": "src/lib/customer-mock-db.js",
24
- "contents": "/**\n * This an example adapter for a mock database to your CRM\n */\nexport const customerMockDb = {\n query: async (\n query,\n page,\n limit,\n orderBy,\n endAt,\n startAt,\n ) => Promise.resolve([{id: '1234', name: 'Test Customer', email: '', phone: ''}]),\n get: async (id) => Promise.resolve({id, name: 'Test Customer', email: '', phone: ''}),\n add: async (id, customer) => ({id}),\n update: async (id, updates) => true,\n remove: async (id) => true\n}\n"
23
+ "name": "src/lib/customer-db.js",
24
+ "contents": "import {Scout9CRM} from '@scout9/crm';\n\nconst crm = new Scout9CRM({apiKey: process.env.SCOUT9_API_KEY});\n\n/**\n * This an example adapter for a mock database to your CRM\n */\nexport const customerDb = {\n query: async (\n query,\n page,\n limit,\n orderBy,\n endAt,\n startAt,\n ) => crm.query(query, page, limit, orderBy, endAt, startAt),\n get: async (id) => crm.get(id),\n add: async (customer) => crm.add(customer),\n update: async (id, updates) => crm.update({...updates, $id: id}),\n remove: async (id) => crm.remove(id)\n}\n"
25
25
  },
26
26
  {
27
27
  "name": "src/workflows/default/workflow.js",
@@ -5,10 +5,12 @@
5
5
  "scripts": {
6
6
  "deploy": "scout9 deploy",
7
7
  "build": "scout9 build",
8
- "test": "scout9 test"
8
+ "sync": "scout9 sync",
9
+ "dev": "scout9 dev"
9
10
  },
10
11
  "dependencies": {
11
- "@scout9/app": "latest"
12
+ "@scout9/app": "latest",
13
+ "@scout9/crm": "latest"
12
14
  },
13
15
  "type": "module"
14
16
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-scout9",
3
- "version": "1.0.0-alpha.0.0.6",
3
+ "version": "1.0.0-alpha.0.0.8",
4
4
  "bin": "./bin.js",
5
5
  "main": "./index.js",
6
6
  "publishConfig": {