create-scout9 1.0.0-alpha.0.0.21 → 1.0.0-alpha.0.0.23

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.
@@ -1,7 +1,7 @@
1
1
  [
2
2
  {
3
3
  "name": "src/app.js",
4
- "contents": "\nimport PizzaOrder from './workflows/pizzaOrder/workflow.js';\n\n/**\n * @param {import('@scout9/app').WorkflowEvent} event - every workflow receives an event object\n * @returns {Promise<import('@scout9/app').WorkflowResponse>} - every workflow must return a WorkflowResponse\n */\nexport default async function Scout9App(event) {\n\n // If the user intent is pizzaOrder or the context has a pizza object, run the pizza order workflow\n if (event.intent === 'pizzaOrder' || event.context === 'pizza') {\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"
4
+ "contents": "\nimport PizzaOrder from './workflows/pizzaOrder/workflow.js';\n\n/**\n * @param {import('@scout9/app').WorkflowEvent} event - every workflow receives an event object\n * @returns {Promise<import('@scout9/app').WorkflowResponse>} - every workflow must return a WorkflowResponse\n */\nexport default async function Scout9App(event) {\n\n // If the user intent is pizzaOrder or the context has a pizza object, run the pizza order workflow\n if (event.intent.initial === 'pizzaOrder' || !!event.context.pizza) {\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",
@@ -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 * @param {import('@scout9/app').WorkflowEvent} event - the workflow event that every workflow must have\n * @returns {Promise<import('@scout9/app').WorkflowResponse>} - the response that every workflow must return\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.invoiceId && context.delivery_method) {\n const invoice = await createInvoice(context.pizza);\n const intro = `${context.delivery_method === 'delivery' ? 'Order will be sent over in 30 minutes' : 'Order will be ready for pickup in 30 minutes at 123 Nark Ave Seattle WA 98122'}.`;\n return {\n message: `${intro}.\\n\\nThe total is $${(invoice.total/100).toFixed(2)}, you can pay at this url: ${invoice.invoiceUrl}`,\n contextUpsert: {\n invoiceId: invoice.id,\n invoicePaid: false\n }\n }\n }\n\n if (!context.invoicePaid && context.invoiceId) {\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.delivery_method === '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.delivery_method === '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 if (!context.delivery_method) {\n return {\n instructions: `Ask ${customer.firstName || 'the customer'} if they want their pizza order for either pickup or delivery.`\n }\n }\n\n console.error('No where to go - view context:\\n', JSON.stringify(context, null, 2));\n return {\n forward: true,\n notes: 'No where to go, something happened'\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 {import('@scout9/app').WorkflowEvent} event - the workflow event that every workflow must have\n * @returns {Promise<import('@scout9/app').WorkflowResponse>} - the response that every workflow must return\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.invoiceId && context.delivery_method) {\n const invoice = await createInvoice(context.pizza);\n const intro = `${context.delivery_method === 'delivery' ? 'Order will be sent over in 30 minutes' : 'Order will be ready for pickup in 30 minutes at 123 Nark Ave Seattle WA 98122'}.`;\n return {\n message: `${intro}.\\n\\nThe total is $${(invoice.total/100).toFixed(2)}, you can pay at this url: ${invoice.invoiceUrl}`,\n contextUpsert: {\n invoiceId: invoice.id,\n invoicePaid: false\n }\n }\n }\n\n if (!context.invoicePaid && context.invoiceId) {\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.delivery_method === '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.delivery_method === '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 if (!context.delivery_method) {\n return {\n instructions: `Ask ${customer.firstName || 'the customer'} if they want their pizza order for either pickup or delivery.`\n }\n }\n\n console.error('No where to go - view context:\\n', JSON.stringify(context, null, 2));\n return {\n forward: true,\n notes: 'No where to go, something happened'\n }\n}\n"
45
45
  }
46
46
  ]
@@ -1,7 +1,7 @@
1
1
  [
2
2
  {
3
3
  "name": "src/app.js",
4
- "contents": "\nimport PizzaOrder from './workflows/pizzaOrder/workflow.js';\n\nexport default async function Scout9App(event) {\n\n // If the user intent is pizzaOrder or the context has a pizza object, run the pizza order workflow\n if (event.intent === 'pizzaOrder' || event.context === 'pizza') {\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"
4
+ "contents": "\nimport PizzaOrder from './workflows/pizzaOrder/workflow.js';\n\nexport default async function Scout9App(event) {\n\n // If the user intent is pizzaOrder or the context has a pizza object, run the pizza order workflow\n if (event.intent.initial === 'pizzaOrder' || !!event.context.pizza) {\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",
@@ -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.invoiceId && context.delivery_method) {\n const invoice = await createInvoice(context.pizza);\n const intro = `${context.delivery_method === 'delivery' ? 'Order will be sent over in 30 minutes' : 'Order will be ready for pickup in 30 minutes at 123 Nark Ave Seattle WA 98122'}.`;\n return {\n message: `${intro}.\\n\\nThe total is $${(invoice.total/100).toFixed(2)}, you can pay at this url: ${invoice.invoiceUrl}`,\n contextUpsert: {\n invoiceId: invoice.id,\n invoicePaid: false\n }\n }\n }\n\n if (!context.invoicePaid && context.invoiceId) {\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.delivery_method === '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.delivery_method === '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 if (!context.delivery_method) {\n return {\n instructions: `Ask ${customer.firstName || 'the customer'} if they want their pizza order for either pickup or delivery.`\n }\n }\n\n console.error('No where to go - view context:\\n', JSON.stringify(context, null, 2));\n return {\n forward: true,\n notes: 'No where to go, something happened'\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 */\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.invoiceId && context.delivery_method) {\n const invoice = await createInvoice(context.pizza);\n const intro = `${context.delivery_method === 'delivery' ? 'Order will be sent over in 30 minutes' : 'Order will be ready for pickup in 30 minutes at 123 Nark Ave Seattle WA 98122'}.`;\n return {\n message: `${intro}.\\n\\nThe total is $${(invoice.total/100).toFixed(2)}, you can pay at this url: ${invoice.invoiceUrl}`,\n contextUpsert: {\n invoiceId: invoice.id,\n invoicePaid: false\n }\n }\n }\n\n if (!context.invoicePaid && context.invoiceId) {\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.delivery_method === '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.delivery_method === '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 if (!context.delivery_method) {\n return {\n instructions: `Ask ${customer.firstName || 'the customer'} if they want their pizza order for either pickup or delivery.`\n }\n }\n\n console.error('No where to go - view context:\\n', JSON.stringify(context, null, 2));\n return {\n forward: true,\n notes: 'No where to go, something happened'\n }\n}\n"
45
45
  }
46
46
  ]
@@ -1,7 +1,7 @@
1
1
  [
2
2
  {
3
3
  "name": "src/app.js",
4
- "contents": "\nimport PizzaOrder from './workflows/pizzaOrder/workflow.js';\n\nexport default async function Scout9App(event) {\n\n // If the user intent is pizzaOrder or the context has a pizza object, run the pizza order workflow\n if (event.intent === 'pizzaOrder' || event.context === 'pizza') {\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"
4
+ "contents": "\nimport PizzaOrder from './workflows/pizzaOrder/workflow.js';\n\nexport default async function Scout9App(event) {\n\n // If the user intent is pizzaOrder or the context has a pizza object, run the pizza order workflow\n if (event.intent.initial === 'pizzaOrder' || !!event.context.pizza) {\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",
@@ -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.invoiceId && context.delivery_method) {\n const invoice = await createInvoice(context.pizza);\n const intro = `${context.delivery_method === 'delivery' ? 'Order will be sent over in 30 minutes' : 'Order will be ready for pickup in 30 minutes at 123 Nark Ave Seattle WA 98122'}.`;\n return {\n message: `${intro}.\\n\\nThe total is $${(invoice.total/100).toFixed(2)}, you can pay at this url: ${invoice.invoiceUrl}`,\n contextUpsert: {\n invoiceId: invoice.id,\n invoicePaid: false\n }\n }\n }\n\n if (!context.invoicePaid && context.invoiceId) {\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.delivery_method === '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.delivery_method === '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 if (!context.delivery_method) {\n return {\n instructions: `Ask ${customer.firstName || 'the customer'} if they want their pizza order for either pickup or delivery.`\n }\n }\n\n console.error('No where to go - view context:\\n', JSON.stringify(context, null, 2));\n return {\n forward: true,\n notes: 'No where to go, something happened'\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 */\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.invoiceId && context.delivery_method) {\n const invoice = await createInvoice(context.pizza);\n const intro = `${context.delivery_method === 'delivery' ? 'Order will be sent over in 30 minutes' : 'Order will be ready for pickup in 30 minutes at 123 Nark Ave Seattle WA 98122'}.`;\n return {\n message: `${intro}.\\n\\nThe total is $${(invoice.total/100).toFixed(2)}, you can pay at this url: ${invoice.invoiceUrl}`,\n contextUpsert: {\n invoiceId: invoice.id,\n invoicePaid: false\n }\n }\n }\n\n if (!context.invoicePaid && context.invoiceId) {\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.delivery_method === '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.delivery_method === '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 if (!context.delivery_method) {\n return {\n instructions: `Ask ${customer.firstName || 'the customer'} if they want their pizza order for either pickup or delivery.`\n }\n }\n\n console.error('No where to go - view context:\\n', JSON.stringify(context, null, 2));\n return {\n forward: true,\n notes: 'No where to go, something happened'\n }\n}\n"
45
45
  }
46
46
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-scout9",
3
- "version": "1.0.0-alpha.0.0.21",
3
+ "version": "1.0.0-alpha.0.0.23",
4
4
  "bin": "./bin.js",
5
5
  "main": "./index.js",
6
6
  "publishConfig": {