Api.ai Multiple Items in Order System - dialogflow-es

I am creating a sample app in which multiple items as per categories can be chosen. Please see flow as below.
If i want to opt 3 items and all are falling in different categories. The configuration will like this.
A) Item 1
Category 1
Price1
ingrdient1
B) Item 2
Category 2
Price2
ingrdient3
C) Item 3
Category 3
Price3
ingrdient3
So to achieve this i have to create parameter1, parameter2, parameter3 and so on.
Is there any way in api.ai which supports collection concept like object[0], object[1], object[3] ....
here object[0] holds
A) Item 1
Category 1
Price1
ingrdient1
Thanks,
Dinesh

Not currently.
Api.ai are working on List entity, comment here on their forum. But currently they don't support objects or arrays being passed as parameters.
You would have set up entities and parameters for price, item, category, ingredient to be passed to your own webservice.
Try asking on their forum though, they're very open to suggestions and improvements for the platform.

Related

How can I compare the properties of a vertice, to the properties of another vertice

I'm using Gremlin to interact with a Graph in CosmosDB.
I have some data about employees, data they have access to and departments where both originate from. See below for an example.
I want to retrieve information from my graph about which employees have access to data, but doesn't belong in their department. Basically, I want to see where the department columns are not equal, but the column data_access and data_id are equal, for every database the employee has access to. From the example below I would return information employee_id 1 and 2.
employee_id
name
department
data_access
1
john
A
4
2
rick
B
5
3
nick
A
5
dataset_id
name
department
4
apples
B
5
oranges
A
So far I tried to construct queries using traversal steps like "has", "as", "where" but I couldn't achieve the result I want. I'm very new to Gremlin, so I have no idea if what I'm doing is even the right way to do it.

How do I pair actions and parameters from one user message

So i'm creating a chatbot, where users can ask faq's and place orders for items for loans. One bit i'm struggling with is how to pair paramaters and values when a user makes an order for multiple things in one sentence.
So for example:
User wants to order 5 items with varying quanititys:
"I'd like to order 3 phones, 2 cases, 3 power cables, 1 screen protector, and 1 bluetooth speaker".
I'd like it to do this and associate the quantity with the item. so something like:
3 - Phones
2 - Cases
3 - Power cables
1 - Screen protector
1 - Bluetooth speaker
Thanks!
One way to pair the amount and a product together would be by using composite entities.
https://cloud.google.com/dialogflow/docs/entities-developer#developer_composite
Composite entities allow you to pair to values together in a single entity. So in your case you could have a composite entity named order, which contains an amount (Number) entity and a product entity.
By giving the appropriate sample utterances, you can train your agent to recognize this order entity and by checking the "Is List" option in the parameters you should be able to get multiple orders and have their product with the paired amount in a single entity.
Hope that this helps.

handling concurrency for last item in inventory

We've 1 book left in the inventory. and two people are trying to get the same book ( say person x and person y ). Person x has added book to the cart and about to make payment and person y has also added book to the cart. How would you solve this concurrency problem ?
Based on your description, Looks like you are allowing users to add last item to cart that mean there is no hold on item while its in cart, Now you can add check during check out, checking for item availability like database constraint that stock can not be less than 0 in this case your database transaction will fail and would return error. You can reply back with message saying item out of stock.

Getting single SOLR document in multiple groups/categories it belongs to

We are using SOLR to index products for an eCommerce application, we have products grouped by category and subcategories and the same product can appear in more than one subcategory, We need to retrieve the products in all the subcategories it belongs to and would like to use one single query to achieve this objective. Any pointers would be really helpful. Example illustrated below -
Assume that a product p1 belongs to subcategory sc1 and sc2 which belongs to parent category c1
c1 ----- sc1 ----- p1
c1 ----- sc2 ----- p1
The way we have indexed the product is to have category path information in product p1,
p1 - Category path of (c1->sc1 and c1->sc2)
When the user browses through the category c1 the product should appear twice on the page grouped by subcategory sc1 and sc2 as shown below
c1 ----- sc1
p1
----- sc2
p1
We want to query from solr so that it returns the same product grouped in 2 different subcategories, effectively duplicating in the result. We could do it programatically after fetching the result from solr but we have pagination and sort order logic which would be hard to maintain in the code.
This is like tags. You know that when you tag things, a single item can have more than one tag. In SOLR you would represent that as a multivalued field, i.e. an array of values.
You need to make "subcategory" into a multivalued field. I think that your reference to path means that the same subcategory identifier is used in multiple unrelated categories thus you are combining category and subcategory together to get unique keys.
In that case you might have:
p1, [c1>sc1]
p2, [c1>sc2,c1>sc7]
p3, [c1>sc5]
p4, [c1>sc1,c1>sc5]
When you retrieve all products with subcategory matching c1
In order to actually return the product multiple times, you would need multiple records in your Solr index for that product. I suspect that would make updating individual product records a bit difficult however -- assuming you're using a unique key, you would need a key based on both product ID and subcategory.
I agree with Michael Dillon's suggestion of making "subcategory" a multiValued field and then formatting the results appropriately.

How to automatically sort SPListItems based on a field

I have a requirement that a SPList should be sorted by the "Priority" field (number field, no limits) when a ListItem is added or updated.
The sort should work as this:
Original Inserted item Modified
1 1
2 2 2
3 3 (old 2)
4 (old 3)
Edited: This behaviour is primary for improving the user experience when editing data in the data sheet view.
It is a sort of a poor mans AJAX style updates that I am trying to get.
The only solution I see right now is to use an event handler and update the ListItems that should be deprioritized, however that could be a fairly costly operation on a list with hundreds of items (unless there are gaps in the sequence).
Have I missed the obvious solution, or a far better scaling way?
tia
Wow, tough one. I do not like the idea of going back and doing updates to existing items from a EventReceiver. You are asking for trouble.
Here is my recomendation.
Use 2 fields for your sort.
1 your priorty field as you have it today (so someone says 1, 2 , 3, 4)...
2 the create date field (this is a builtin datetime field).
so your results would look something like this
1 1/1/2009
2 5/16/2009
2 5/11/2009
3 5/12/2009
If you want the items sorted in a view:
Set the sort order in the view.
If you want items sorted when using the SharePoint API:
Use a SPQuery with an OrderBy element. http://sharepointmagazine.net/technical/development/writing-caml-queries-for-retrieving-list-items-from-a-sharepoint-list

Resources