create-scout9 1.0.0-alpha.0.0.1 → 1.0.0-alpha.0.0.3
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/dist/templates/default/files.types=checkjs.json +8 -8
- package/dist/templates/default/files.types=null.json +4 -4
- package/dist/templates/default/files.types=typescript.json +4 -4
- package/dist/templates/default/package.json +1 -1
- package/dist/templates/skeleton/files.types=checkjs.json +9 -5
- package/dist/templates/skeleton/files.types=null.json +6 -2
- package/dist/templates/skeleton/files.types=typescript.json +6 -2
- package/dist/templates/skeleton/package.json +1 -1
- package/package.json +1 -1
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
3
|
"name": "src/app.js",
|
|
4
|
-
"contents": "
|
|
4
|
+
"contents": "\nimport PizzaOrder from './workflows/pizzaOrder/workflow.js';\n\n/**\n * @param {WorkflowEvent} event - every workflow receives an event object\n * @returns {Promise<WorkflowResponse>} - every workflow must return a WorkflowResponse\n */\nexport default async function Scout9App(event) {\n\n if (event.intent === 'pizzaOrder') {\n // run pizza order workflow\n return PizzaOrder(event);\n } else {\n if (event.stagnationCount < 2) {\n return {\n instructions: 'Double check if the user is looking to order a pizza'\n }\n } else {\n // End auto replies, forward to agent for manual intervention\n return {\n forward: true,\n }\n }\n }\n\n}\n"
|
|
5
5
|
},
|
|
6
6
|
{
|
|
7
7
|
"name": "src/entities/agents/index.js",
|
|
8
|
-
"contents": "/**\n * Required core entity type: Agents represents you and your team\n */\nexport default function Agents() {\n return [\n {\n id: 'agent-1',\n firstName: 'Agent',\n lastName: 'Smith',\n forwardPhone: '+15555555555',\n forwardEmail: '',\n programmablePhoneNumber: '+15555555555',\n }\n ];\n}\n"
|
|
8
|
+
"contents": "/**\n * Required core entity type: Agents represents you and your team\n * @returns {Array<Agent>}\n */\nexport default function Agents() {\n return [\n {\n id: 'agent-1',\n firstName: 'Agent',\n lastName: 'Smith',\n forwardPhone: '+15555555555',\n forwardEmail: '',\n programmablePhoneNumber: '+15555555555',\n }\n ];\n}\n"
|
|
9
9
|
},
|
|
10
10
|
{
|
|
11
11
|
"name": "src/entities/customers/[customer]/api.js",
|
|
12
|
-
"contents": "import { json } from '
|
|
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"
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
15
|
"name": "src/entities/customers/api.js",
|
|
16
|
-
"contents": "import {
|
|
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"
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
19
|
"name": "src/entities/deliveryMethod/index.js",
|
|
20
|
-
"contents": "// import { EntityRootConfiguration } from '../../../platform/src/runtime/client/entity';\n\n// export type DeliveryMethod = {\n// deliveryMethod: 'pickup' | 'delivery';\n// }\n\n/**\n * Example entity to help us differentiate if a user wants a delivery or pickup order\n */\nexport default function () {\n return {\n definitions: [\n {\n value: 'delivery',\n text: [\n 'delivery',\n 'deliver',\n 'delivered',\n 'dropped off',\n 'drop off',\n ]\n },\n {\n value: 'pickup',\n text: [\n 'pickup',\n 'pick this one up',\n 'pick up',\n ]\n },\n ],\n training:\n [\n ...[\n 'I\\'ll have my order %delivery_method%',\n 'I\\'ll do a %delivery_method% order',\n '%delivery_method% please',\n ].map((text) => ({text, intent: 'delivery_method'})),\n ],\n tests: [\n {\n text: 'drop off order please',\n expected: {\n intent: 'deliveryMethod',\n context: {\n 'deliveryMethod': 'delivery'\n }\n },\n },\n {\n text: 'I\\'ll pick this one up',\n expected: {\n intent: 'deliveryMethod',\n context: {\n 'deliveryMethod': 'pickup'\n }\n },\n }\n ],\n }\n}\n"
|
|
20
|
+
"contents": "// import { EntityRootConfiguration } from '../../../platform/src/runtime/client/entity';\n\n// export type DeliveryMethod = {\n// deliveryMethod: 'pickup' | 'delivery';\n// }\n\n/**\n * Example entity to help us differentiate if a user wants a delivery or pickup order\n * @returns {IEntityBuildConfig}\n */\nexport default function () {\n return {\n definitions: [\n {\n value: 'delivery',\n text: [\n 'delivery',\n 'deliver',\n 'delivered',\n 'dropped off',\n 'drop off',\n ]\n },\n {\n value: 'pickup',\n text: [\n 'pickup',\n 'pick this one up',\n 'pick up',\n ]\n },\n ],\n training:\n [\n ...[\n 'I\\'ll have my order %delivery_method%',\n 'I\\'ll do a %delivery_method% order',\n '%delivery_method% please',\n ].map((text) => ({text, intent: 'delivery_method'})),\n ],\n tests: [\n {\n text: 'drop off order please',\n expected: {\n intent: 'deliveryMethod',\n context: {\n 'deliveryMethod': 'delivery'\n }\n },\n },\n {\n text: 'I\\'ll pick this one up',\n expected: {\n intent: 'deliveryMethod',\n context: {\n 'deliveryMethod': 'pickup'\n }\n },\n }\n ],\n }\n}\n"
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
23
|
"name": "src/entities/pizza/index.js",
|
|
24
|
-
"contents": "/**\n * Example entity that breaks down the pizza the user wants to order\n */\nexport default async function () {\n\n return {\n definitions: [\n {\n utterance: 'quantity',\n value: 'number',\n text: []\n },\n {\n utterance: 'size',\n value: 'small',\n text: ['small', 'sm', '6 inch', '6-inch', '6in', '6 in', '6\"']\n },\n {\n utterance: 'size',\n value: 'medium',\n text: ['medium', 'med', 'md', '8 inch', '8-inch', '8in', '8 in', '8\"']\n },\n {\n utterance: 'size',\n value: 'large',\n text: ['large', 'lg', '12 inch', '12-inch', '12in', '12 in', '12\"']\n },\n {\n utterance: 'size',\n value: 'x-large',\n text: ['extra large', 'x-large', 'xlarge', 'xl', '16 inch', '16-inch', '16in', '16 in', '16\"']\n },\n {\n utterance: 'topping',\n value: 'pepperoni',\n text: ['pepperoni']\n },\n {\n utterance: 'topping',\n value: 'sausage',\n text: ['sausage', 'italian sausage']\n },\n {\n utterance: 'topping',\n value: 'mushroom',\n text: ['mushroom', 'mushrooms', 'mush']\n },\n {\n utterance: 'topping',\n value: 'cheese',\n text: ['cheese', 'cheesy', 'cheez', 'mozarella', 'mozzarella', 'mozz']\n }\n ],\n training: [\n ...[\n '{{quantity:number}} %topping% %size%',\n '{{quantity:number}} %topping% %size%, {{quantity:number}} %topping% %size%, and {{quantity:number}} %topping% %size% and that should be all',\n 'Hey I would like {{quantity:number}} %topping% %size%',\n 'Hey I would like {{quantity:number}} %topping% and %topping%',\n 'Hey I would like {{quantity:number}} %topping%, %topping%, and extra %topping%', // @TODO extra would need to be a separate topping\n 'Hey I would like {{quantity:number}} %size% %topping%, %topping%, and %topping%',\n 'Could I get a %topping% pizza please?',\n 'Could I get {{quantity:number}} %size% %topping%, %topping%, and %topping%?',\n 'Can I order a {{quantity:number}} %size% %topping%, %topping%, and %topping%',\n ].map((text) => ({text, intent: 'pizza'})),\n ...[\n 'Can you remove that %size% %topping% pizza',\n 'Can you remove that %topping% %size% pizza',\n 'Can you cancel that %size% %topping%',\n 'Let\\'s remove that %size% %topping% pizza',\n 'Let\\'s get rid of that %size% %topping%',\n 'Let\\'s remove the %size% %topping% pizza',\n ].map((text) => ({text, intent: 'remove_pizza'})),\n ...[\n 'Can you remove those %topping%?',\n 'Can you remove that %topping%?',\n 'Actually, no %topping%?',\n 'Sorry, I don\\'t want %topping%?',\n ].map((text) => ({text, intent: 'remove_topping'})),\n ...[\n 'Do you have %topping%?',\n ].map((text) => ({text, intent: 'pizza_question'})),\n ],\n tests: [\n {\n text: 'I would like 3 pepperoni medium, 2 cheese medium, and 3 sausage mushroom',\n expected: {\n intent: 'pizza',\n context: {\n pizza: [\n {\n quantity: 3,\n topping: 'pepperoni',\n size: 'medium'\n },\n {\n quantity: 2,\n topping: 'cheese',\n size: 'medium'\n },\n {\n quantity: 3,\n topping: ['sausage', 'mushroom'],\n }\n ]\n },\n },\n },\n {\n text: 'Hey I would like 3 medium pepperoni, sausage, and extra cheese',\n expected: {\n intent: 'pizza',\n context: {\n pizza: [\n {\n quantity: 3,\n topping: ['pepperoni', 'sausage', 'cheese'],\n size: 'medium'\n }\n ]\n }\n }\n }\n ]\n };\n}\n\n"
|
|
24
|
+
"contents": "/**\n * Example entity that breaks down the pizza the user wants to order\n * @returns {IEntityBuildConfig}\n */\nexport default async function () {\n\n return {\n definitions: [\n {\n utterance: 'quantity',\n value: 'number',\n text: []\n },\n {\n utterance: 'size',\n value: 'small',\n text: ['small', 'sm', '6 inch', '6-inch', '6in', '6 in', '6\"']\n },\n {\n utterance: 'size',\n value: 'medium',\n text: ['medium', 'med', 'md', '8 inch', '8-inch', '8in', '8 in', '8\"']\n },\n {\n utterance: 'size',\n value: 'large',\n text: ['large', 'lg', '12 inch', '12-inch', '12in', '12 in', '12\"']\n },\n {\n utterance: 'size',\n value: 'x-large',\n text: ['extra large', 'x-large', 'xlarge', 'xl', '16 inch', '16-inch', '16in', '16 in', '16\"']\n },\n {\n utterance: 'topping',\n value: 'pepperoni',\n text: ['pepperoni']\n },\n {\n utterance: 'topping',\n value: 'sausage',\n text: ['sausage', 'italian sausage']\n },\n {\n utterance: 'topping',\n value: 'mushroom',\n text: ['mushroom', 'mushrooms', 'mush']\n },\n {\n utterance: 'topping',\n value: 'cheese',\n text: ['cheese', 'cheesy', 'cheez', 'mozarella', 'mozzarella', 'mozz']\n }\n ],\n training: [\n ...[\n '{{quantity:number}} %topping% %size%',\n '{{quantity:number}} %topping% %size%, {{quantity:number}} %topping% %size%, and {{quantity:number}} %topping% %size% and that should be all',\n 'Hey I would like {{quantity:number}} %topping% %size%',\n 'Hey I would like {{quantity:number}} %topping% and %topping%',\n 'Hey I would like {{quantity:number}} %topping%, %topping%, and extra %topping%', // @TODO extra would need to be a separate topping\n 'Hey I would like {{quantity:number}} %size% %topping%, %topping%, and %topping%',\n 'Could I get a %topping% pizza please?',\n 'Could I get {{quantity:number}} %size% %topping%, %topping%, and %topping%?',\n 'Can I order a {{quantity:number}} %size% %topping%, %topping%, and %topping%',\n ].map((text) => ({text, intent: 'pizza'})),\n ...[\n 'Can you remove that %size% %topping% pizza',\n 'Can you remove that %topping% %size% pizza',\n 'Can you cancel that %size% %topping%',\n 'Let\\'s remove that %size% %topping% pizza',\n 'Let\\'s get rid of that %size% %topping%',\n 'Let\\'s remove the %size% %topping% pizza',\n ].map((text) => ({text, intent: 'remove_pizza'})),\n ...[\n 'Can you remove those %topping%?',\n 'Can you remove that %topping%?',\n 'Actually, no %topping%?',\n 'Sorry, I don\\'t want %topping%?',\n ].map((text) => ({text, intent: 'remove_topping'})),\n ...[\n 'Do you have %topping%?',\n ].map((text) => ({text, intent: 'pizza_question'})),\n ],\n tests: [\n {\n text: 'I would like 3 pepperoni medium, 2 cheese medium, and 3 sausage mushroom',\n expected: {\n intent: 'pizza',\n context: {\n pizza: [\n {\n quantity: 3,\n topping: 'pepperoni',\n size: 'medium'\n },\n {\n quantity: 2,\n topping: 'cheese',\n size: 'medium'\n },\n {\n quantity: 3,\n topping: ['sausage', 'mushroom'],\n }\n ]\n },\n },\n },\n {\n text: 'Hey I would like 3 medium pepperoni, sausage, and extra cheese',\n expected: {\n intent: 'pizza',\n context: {\n pizza: [\n {\n quantity: 3,\n topping: ['pepperoni', 'sausage', 'cheese'],\n size: 'medium'\n }\n ]\n }\n }\n }\n ]\n };\n}\n\n"
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
"name": "src/index.js",
|
|
28
|
-
"contents": "
|
|
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
31
|
"name": "src/lib/customer-mock-db.js",
|
|
@@ -41,6 +41,6 @@
|
|
|
41
41
|
},
|
|
42
42
|
{
|
|
43
43
|
"name": "src/workflows/pizzaOrder/workflow.js",
|
|
44
|
-
"contents": "import moment from 'moment';\nimport { getAvailableDriver } from '../../lib/drivers.js';\nimport { createInvoice, getInvoice } from '../../lib/invoice.js';\n\n/**\n * Example PizzaOrder workflow - this is a simple example of a workflow that can be used to order a pizza\n */\nexport default async function PizzaOrder(\n {\n context,\n customer\n }) {\n\n if (!context.pizza) {\n return {\n instructions: 'Figure out what pizza sizes, toppings are needed for order'\n };\n }\n\n if (!context.deliveryMethod) {\n return {\n instructions: `Determine if ${customer?.firstName || 'the customer'} is doing a delivery or pickup and determine time of pickup/delivery`\n };\n }\n\n if (!context.invoiceId) {\n const invoice = await createInvoice(context.pizza);\n return {\n instructions: `Send invoice to customer`,\n message: `Order created - $${(invoice.total/100).toFixed(2)} you can pay at ${invoice.invoiceUrl}`,\n contextUpsert: {\n invoiceId: invoice.id,\n invoicePaid: false\n }\n }\n }\n\n if (!context.invoicePaid) {\n if (!context.invoiceId) {\n return {forward: true};\n }\n const invoice = await getInvoice(context.invoiceId || '');\n return {\n instructions: `Let user know order is ready for payment at ${invoice.invoiceUrl}`\n }\n }\n\n if (context.deliveryMethod === 'pickup') {\n return [\n {\n instructions: `Let user know their order will be ready at ${moment().add(30, 'minutes').format('h:mm a')}`\n },\n {\n instructions: `Find out if everything was delivered, and let the user know to contact if there are any issues`,\n forward: {\n mode: 'after-reply'\n },\n scheduled: moment().add(30, 'minutes').unix()\n }\n ];\n // @TODO - delay and notify user for feedback and if they got their pizza\n }\n\n if (!context.address && context.deliveryMethod === 'delivery') {\n return {\n instructions: `Ask ${customer.firstName || 'the customer'} for their delivery address`\n };\n }\n\n if (context.address && !context.driver && !context.deliveryTime) {\n const {driver, deliveryEstimate} = await getAvailableDriver(context.address);\n return {\n instructions: `Let ${customer.firstName || 'the customer'} know the pizza order should arrive at ${deliveryEstimate.format(\n 'h:mm a')}`,\n contextUpsert: {\n driver: {\n ...driver\n },\n deliveryTime: deliveryEstimate.unix()\n }\n };\n }\n\n return {\n forward: true\n }\n}\n"
|
|
44
|
+
"contents": "import moment from 'moment';\nimport { getAvailableDriver } from '../../lib/drivers.js';\nimport { createInvoice, getInvoice } from '../../lib/invoice.js';\n\n/**\n * Example PizzaOrder workflow - this is a simple example of a workflow that can be used to order a pizza\n * @param {WorkflowEvent} event - every workflow receives an event object\n * @returns {Promise<WorkflowResponse>} - every workflow must return a WorkflowResponse\n */\nexport default async function PizzaOrder(\n {\n context,\n customer\n }) {\n\n if (!context.pizza) {\n return {\n instructions: 'Figure out what pizza sizes, toppings are needed for order'\n };\n }\n\n if (!context.deliveryMethod) {\n return {\n instructions: `Determine if ${customer?.firstName || 'the customer'} is doing a delivery or pickup and determine time of pickup/delivery`\n };\n }\n\n if (!context.invoiceId) {\n const invoice = await createInvoice(context.pizza);\n return {\n instructions: `Send invoice to customer`,\n message: `Order created - $${(invoice.total/100).toFixed(2)} you can pay at ${invoice.invoiceUrl}`,\n contextUpsert: {\n invoiceId: invoice.id,\n invoicePaid: false\n }\n }\n }\n\n if (!context.invoicePaid) {\n if (!context.invoiceId) {\n return {forward: true};\n }\n const invoice = await getInvoice(context.invoiceId || '');\n return {\n instructions: `Let user know order is ready for payment at ${invoice.invoiceUrl}`\n }\n }\n\n if (context.deliveryMethod === 'pickup') {\n return [\n {\n instructions: `Let user know their order will be ready at ${moment().add(30, 'minutes').format('h:mm a')}`\n },\n {\n instructions: `Find out if everything was delivered, and let the user know to contact if there are any issues`,\n forward: {\n mode: 'after-reply'\n },\n scheduled: moment().add(30, 'minutes').unix()\n }\n ];\n // @TODO - delay and notify user for feedback and if they got their pizza\n }\n\n if (!context.address && context.deliveryMethod === 'delivery') {\n return {\n instructions: `Ask ${customer.firstName || 'the customer'} for their delivery address`\n };\n }\n\n if (context.address && !context.driver && !context.deliveryTime) {\n const {driver, deliveryEstimate} = await getAvailableDriver(context.address);\n return {\n instructions: `Let ${customer.firstName || 'the customer'} know the pizza order should arrive at ${deliveryEstimate.format(\n 'h:mm a')}`,\n contextUpsert: {\n driver: {\n ...driver\n },\n deliveryTime: deliveryEstimate.unix()\n }\n };\n }\n\n return {\n forward: true\n }\n}\n"
|
|
45
45
|
}
|
|
46
46
|
]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
3
|
"name": "src/app.js",
|
|
4
|
-
"contents": "
|
|
4
|
+
"contents": "\nimport PizzaOrder from './workflows/pizzaOrder/workflow.js';\n\nexport default async function Scout9App(event) {\n\n if (event.intent === 'pizzaOrder') {\n // run pizza order workflow\n return PizzaOrder(event);\n } else {\n if (event.stagnationCount < 2) {\n return {\n instructions: 'Double check if the user is looking to order a pizza'\n }\n } else {\n // End auto replies, forward to agent for manual intervention\n return {\n forward: true,\n }\n }\n }\n\n}\n"
|
|
5
5
|
},
|
|
6
6
|
{
|
|
7
7
|
"name": "src/entities/agents/index.js",
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
},
|
|
10
10
|
{
|
|
11
11
|
"name": "src/entities/customers/[customer]/api.js",
|
|
12
|
-
"contents": "import { json } from '
|
|
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"
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
15
|
"name": "src/entities/customers/api.js",
|
|
16
|
-
"contents": "import {
|
|
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"
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
19
|
"name": "src/entities/deliveryMethod/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
"name": "src/index.js",
|
|
28
|
-
"contents": "
|
|
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
31
|
"name": "src/lib/customer-mock-db.js",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
3
|
"name": "src/app.js",
|
|
4
|
-
"contents": "
|
|
4
|
+
"contents": "\nimport PizzaOrder from './workflows/pizzaOrder/workflow.js';\n\nexport default async function Scout9App(event) {\n\n if (event.intent === 'pizzaOrder') {\n // run pizza order workflow\n return PizzaOrder(event);\n } else {\n if (event.stagnationCount < 2) {\n return {\n instructions: 'Double check if the user is looking to order a pizza'\n }\n } else {\n // End auto replies, forward to agent for manual intervention\n return {\n forward: true,\n }\n }\n }\n\n}\n"
|
|
5
5
|
},
|
|
6
6
|
{
|
|
7
7
|
"name": "src/entities/agents/index.js",
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
},
|
|
10
10
|
{
|
|
11
11
|
"name": "src/entities/customers/[customer]/api.js",
|
|
12
|
-
"contents": "import { json } from '
|
|
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"
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
15
|
"name": "src/entities/customers/api.js",
|
|
16
|
-
"contents": "import {
|
|
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"
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
19
|
"name": "src/entities/deliveryMethod/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
"name": "src/index.js",
|
|
28
|
-
"contents": "
|
|
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
31
|
"name": "src/lib/customer-mock-db.js",
|
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
[
|
|
2
2
|
{
|
|
3
3
|
"name": "src/app.js",
|
|
4
|
-
"contents": "import DefaultWorkflow from './workflows/default/workflow.js';\n\nexport default async function Scout9App(event) {\n return DefaultWorkflow(event);\n}\n"
|
|
4
|
+
"contents": "import DefaultWorkflow from './workflows/default/workflow.js';\n\n/**\n * @param {WorkflowEvent} event - every workflow receives an event object\n * @returns {Promise<WorkflowResponse>} - every workflow must return a WorkflowResponse\n */\nexport default async function Scout9App(event) {\n return DefaultWorkflow(event);\n}\n"
|
|
5
5
|
},
|
|
6
6
|
{
|
|
7
7
|
"name": "src/entities/agents/index.js",
|
|
8
|
-
"contents": "/**\n * Required core entity type: Agents represents you and your team\n */\nexport default function Agents() {\n return [\n {\n id: 'agent-1',\n firstName: 'Agent',\n lastName: 'Smith',\n forwardPhone: '+15555555555',\n forwardEmail: '',\n programmablePhoneNumber: '+15555555555',\n }\n ];\n}\n"
|
|
8
|
+
"contents": "/**\n * Required core entity type: Agents represents you and your team\n * @returns {Array<Agent>}\n */\nexport default function Agents() {\n return [\n {\n id: 'agent-1',\n firstName: 'Agent',\n lastName: 'Smith',\n forwardPhone: '+15555555555',\n forwardEmail: '',\n programmablePhoneNumber: '+15555555555',\n }\n ];\n}\n"
|
|
9
9
|
},
|
|
10
10
|
{
|
|
11
11
|
"name": "src/entities/customers/[customer]/api.js",
|
|
12
|
-
"contents": "import { json } from '
|
|
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"
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
15
|
"name": "src/entities/customers/api.js",
|
|
16
|
-
"contents": "import {
|
|
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"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "src/index.js",
|
|
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"
|
|
17
21
|
},
|
|
18
22
|
{
|
|
19
23
|
"name": "src/lib/customer-mock-db.js",
|
|
@@ -21,6 +25,6 @@
|
|
|
21
25
|
},
|
|
22
26
|
{
|
|
23
27
|
"name": "src/workflows/default/workflow.js",
|
|
24
|
-
"contents": "
|
|
28
|
+
"contents": "/**\n * @param {WorkflowEvent} event - every workflow receives an event object\n * @returns {Promise<WorkflowResponse>} - every workflow must return a WorkflowResponse\n */\nexport default async function DefaultWorkflow(\n {\n context,\n customer\n }) {\n return {\n forward: true,\n };\n}\n"
|
|
25
29
|
}
|
|
26
30
|
]
|
|
@@ -9,11 +9,15 @@
|
|
|
9
9
|
},
|
|
10
10
|
{
|
|
11
11
|
"name": "src/entities/customers/[customer]/api.js",
|
|
12
|
-
"contents": "import { json } from '
|
|
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"
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
15
|
"name": "src/entities/customers/api.js",
|
|
16
|
-
"contents": "import {
|
|
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"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "src/index.js",
|
|
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"
|
|
17
21
|
},
|
|
18
22
|
{
|
|
19
23
|
"name": "src/lib/customer-mock-db.js",
|
|
@@ -9,11 +9,15 @@
|
|
|
9
9
|
},
|
|
10
10
|
{
|
|
11
11
|
"name": "src/entities/customers/[customer]/api.js",
|
|
12
|
-
"contents": "import { json } from '
|
|
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"
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
15
|
"name": "src/entities/customers/api.js",
|
|
16
|
-
"contents": "import {
|
|
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"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"name": "src/index.js",
|
|
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"
|
|
17
21
|
},
|
|
18
22
|
{
|
|
19
23
|
"name": "src/lib/customer-mock-db.js",
|