Pronoun support in wit.ai? - wit.ai

Currently I have two stories. Something like this:
Story #1
User: How much is Widget X 2000?
Bot: It costs $30.
Story #2
User: Where can I buy Widget X 2000?
Bot: At your local Best Buy.
The problem: If a user triggers story #1, they still must explicitly say the name of the product (instead of it) to trigger story #2. This is what happens:
User: How much is Widget X 2000?
Bot: It costs $30.
User: Where can I buy it?
--error--
These answers should not be combined into one story because the order of the questions is never the same. Can Wit.Ai understand pronouns somehow?

Wit.ai doesn't provide automatic pronoun resolution at the moment.
Typically you should use the context to store the product the user is talking about, something like:
User: How much is Widget X 2000?
Bot-action: context.item = "Widget X 2000"
Bot-send: It costs $30.
User: Where can I buy it?
[here the next bot action will use context.item if no item entity is detected in the sentence]

The problem is that you are not using any context, so for the agent is not possible to associate "it" with "Widget X 2000".

Related

RESTful API for large "mash up" data pulls?

I have recently been tasked with a small project of setting up a periodic (somewhere between daily & weekly) data dump from an internal database to a 3rd party product. This project dovetails nicely with my company's desire (one which I share) to start standing up a formal service layer/API over the top of our data.
My personal preference is that those APIs should take on the form of RESTful endpoints - however, now I have what I think is a big design question - let me explain...
Looking at the data pull in question, it's hardly complicated. If I were just going to construct a one-off query, it would conceptually look a little something like:
select o.order_num, o.order_date, p.product_description, sr.sales_rep_name
from order o, line_item li, product p, sales_rep sr
where li.order_num = o.order_num
and li.product_id = p.product_id
and sr.sales_rep_id = o.sales_rep_id
and o.order_date >= [some arbitrary date]
Flipping my brain into "Resource Mode", I can think about how to convert this basic data model into URI's/payloads without too much trouble:
GET /orders/123
{
"order_num": 59324,
"order_date": "2014-07-07",
"sales_rep_uri": "/salesRep/34",
"line_items_uri": "/order/123/lineItems"
}
Getting more information about the sales rep:
GET /salesRep/34
{
"sales_rep_name": "Jane Doe",
"open_orders_uri": "/salesRep/34/orders"
}
Getting more information about line items:
GET /orders/123/lineItems
{
"line_items": [
{"order_uri": "/order/123", "product_uri": "/products/68"},
{"order_uri": "/order/123", "product_uri": "/products/99"}
]
}
And so on. I'm not saying it's a perfect API, I'm just trying to demonstrate it's not exactly rocket science to go about thinking how you might express the data model in a nicely normalized, resource-oriented type of way via RESTful URIs. But that is exactly where the design question comes into play...
On one hand, I can crank out a query to solve the problem very easily, but the very nature of queries requires the various domain concepts to be tightly coupled (in other words, utilizing joins to bring all of the normalized data together into one nice, custom-purpose de-normalized structure).
On the other hand, going through the mental process of thinking out a RESTful API leads me right back down that road of keeping things nicely compartmentalized - e.g. asking for "Order 123" shouldn't send me back this huge graph where I can see the full product description, the sales rep's phone number, etc, etc. The concept of a full blown HATEOAS-level RESTful API dictates consumers should be making subsequent GETs to drill down for that kind of detail only as-needed.
My question boils down to this: solving this use case seems really easy to do with a direct query and really difficult to do against a nice & tidy RESTful API (I'm picturing the literally 1000's of individual GETs it would take for me to assemble a weeks worth of data vs the few seconds it would take for the query to run). Is there some elegant subtlety of good RESTful design that I don't understand that would prevent me from seeing a good solution, or am I trying to fit a round peg into a square hole (i.e. REST is not good at pulling big data batches across multiple resources)?
I'm just going to throw this out there as a potential solution:
Conceptually, I treat the results of this query as a resource unto itself - like "orderReport".
Treating this as it's own resource, the API could behave something like:
GET /orderReport/[some arbitrary date]
You could then send back either a 201 Created (if the query is relatively quick running) with a location header like Location: /orderReport/[GUID]. Alternatively, if the query takes a while to run (I honestly don't know if it does or not off the top of my head), you could send back a 202 Accepted with a location header of Location: /orderReport/[GUID]/status.
You could then do follow up GETs against those URLs to get either the report status (200 OK if still processing without error, 201 Created with location header pointing to the report URL if its done) or the report itself.
There's nothing to say the report data couldn't also incorporate HATEOAS in addition to the data strictly needed to fulfill the use case requirements, like:
{
[
{
"order_num": 123,
"order_uri": "/orders/123",
"order_date": 2014-07-03,
"product_description": "widget",
"sales_rep_name": "Jane Doe",
"sales_rep_uri": "/salesRep/34"
},
{
"order_num": 456,
"order_uri": "/orders/456",
"order_date": 2014-07-04,
"product_description": "gadget",
"sales_rep_name": "Frank Smith",
"sales_rep_uri": "/salesRep/53"
}
]
}

REST API sub resources

Creating my first REST API and I have a question. I have a resource venue:
/venues
each venue has guests:
/venues/1/guests
This is where I am confused about. If I want to update a guest resource, is it better to do this:
POST /venue/1/guests/1/
or
POST /guests/1
The second option is shorter and since guests ids are unique, the 2nd one works just fine. But first is more explicit.
So I am stuck on which route to take from here.
Thanks
Both are pretty much the right approaches although, if you guarantee the clients (client developers) that the guest ids are always going to be unique regardless of the venue they visit, I will go with
POST /guests/{guestId}
I will normally use this:
POST /venues/{venueId}/guests/{guestId}
when I have to change the status of that guest for that given venue. For example, Guest John Doe with id 1 has RSVP'ed "yes" for the venue with venueId 1 then I will POST the data to the following url (this is just an example where it is assumed that the only thing you can add/update for a given guest for a given venue is the RSVP data):
POST /venues/1/guests/1
request body: {"RSVP", true}
but if I want to update John Doe's name to John Foo, I will probably do
PUT /guests/1
request body: {"firstName":"John","lastName":"Foo"}
I hope that helps!
You can think of you having two RESTful resources to manage
A) Venues and
B) Guests
These resources can be independently managed using POST/GET/DELETE/PUT (CRUD operations)
POST /venues/
GET /venues/
POST /guests/
GET /guests/
Also you can use CRUD to map one resource to another like
POST /venues/[venue-id]/guests/[guest-id]/

Prestashop Multiple customer id with same email-id

I'm using PrestaShop 1.5.5.0.
My website is www.allworldfurniture.com and live now. I saw that one customer has registered 3 times with same name, same age and same mail id. How is it possible ? is there any hacker trying to do so ?
Name, age and other stuff can be identical but how one mailid is registered multiple time ? any idea friends ? Shall I change something ?
This is not likely a hacker. This is probably just someone who put their information into your form and accidentally submitted it three times. They probably thought their information hadn't submitted (possibly because of a slow network) and click submit again.
You should only allow users to send form data once every minute, for example, so that that doesn't happen again.
Solution
Hello everyone
to stop multiple customer id / Guest id with same email  PRESTASHOP 1.6
Go in this file \publicHTML\classes\Customer.php
remplace variable $ignore_guest true to false in function parameters like this 
 Lines 392-393 
// public static function customerExists($email, $return_id = false, $ignore_guest = true)
   public static function customerExists($email, $return_id = false, $ignore_guest = false)
Enjoy

Rails session variables aren't getting set/passed as expected

Thanks for taking a look at this relatively nu-b question.
I have a web app built on Rails 3 that allows users to view multiple stories at a time, with each story having multiple posts. I use JS to poll the server at regular intervals so to search for new posts on all of the open stories. I use session variables so to keep track of where I ended my last search for each of those open stories so that I don't have to search the entire table of posts from scratch each time I poll the server.
Here is the action for when a user first opens a story:
def open_story
story = Story.find(params[:story_id])
#keep track of the last post searched for each open story so to assist when we poll for new posts to that story
last_post_searched = Post.last.id
session["last_post_searched_for_story_#{story.id}"] = last_post_searched
#posts = story.posts.where("posts.id <= ?", last_post_searched)
respond_with #posts
end
Here is the action for when the client polls the server for new post updates on an array of open stories:
def update_stories
open_stories_id_array = params[:open_stories]
open_stories_id_array.each { |open_story_id|
debugger
start_search_at_post_id = session["last_post_searched_for_story_#{open_story_id}"] + 1
session["last_post_searched_for_story_#{open_story_id}"] = Post.last.id
story = Story.find(open_story_id)
updates = story.posts.where("posts.id between ? AND ?",
start_search_at_post_id, session["last_post_searched_for_story_#{open_story_id}"])
results[open_story_id] = updates
}
respond_with(results)
end
For reasons that I can't figure out, my session variables don't increment to the new Post.last.id in my update_stories action in a timely fashion. Here is how I can recreate the problem:
Say I have 30 posts in my db to various different stories.
I call open_story on story 1. This sets session["last_post_searched_for_story_1"] to 30.
I then make a new post to story 1 (post 31).
My client polls the update_stories action to get new posts for story 1.
update_stories searches for posts with ids between 31 and 31 for story with id of 1, and returns the post that I just made.
Then, a little while later my client automatically polls update_stories again to check for any new posts on story 1. This is where the problem occurs.
Instead of session["last_post_searched_for_story_1"] containing the value, 31, it retains its previous value of 30 so that my db search returns my original new post for a second time. Often, my client will call update_stories several times before session["last_post_searched_for_story_1"] increments to 31. It's almost as if the session variable is very slow to save its new value, or I'm experiencing some sort of lazy loading problem.
Any help figuring this problem out would be greatly appreciated and eagerly accepted.
Thanks
BTW, as I still have a lot to learn, feel free to give feedback on better ways to handle this issue or if I am violating any rails best practices.
I see 2 problems with your code:
You may want to order your results first before applying last method. The last record returned by the database is not necessarily the last one to be created.
Secondly, to select the last post, you should apply the last criterion to only the posts for that story and then select the last post for that story.
So, instead of this:
story = Story.find(params[:story_id])
#keep track of the last post searched for each open story so to assist when we poll for new posts to that story
last_post_searched = Post.last.id
You could have it like this:
story = Story.find(params[:story_id])
last_post_searched = Post.joins(:stories).where("stories.id = ?", story.id).order("posts.created_on DESC").first

Siebel - How to get all accounts of an employee with eScript?

how can I get all accounts of am employee?
In the "Siebel Object Interaces Reference" I found an example, how to get all industries of an account:
var myAccountBO = TheApplication().GetBusObject("Account");
var myAccountBC = myAccountBO.GetBusComp("Account");
var myAssocBC = myAccountBC.GetMVGBusComp("Industry");
So I would like to do something like:
var myEmployeeBO = TheApplication().GetBusObject("Employee");
var myEmployeeBC = myAccountBO.GetBusComp("Employee");
var myAssocBC = myAccountBC.GetMVGBusComp("Account");
But I get an error
Semantic Warning around line 23:No such predefined property Account in class BusComp[Employee].MVGFields.
I can see in Tools that there is no Multi Value Link called "Account" in Business Component "Employee", so I can actually understand the error message.
So I wonder how I can get all accounts of an employee.
I found the Business Component "User" which has a Multi Value Link to "Organisation" and another link "User/Account".
Is this what I am looking for?
How can I know? Where is documentation which tells me about the semantics of links? (Is this described in "Siebel data model reference"? I cannot download this document, although I have signed in...) This link could also link a user to the organization it belongs to.
If one of these links IS what I am looking for, what would be the way to go to get the "User" Business Component of a corresponding "Employee" Business Component?
Many questions of a Siebel newb...Thanks for your patience.
Nang. An easy way to approach this (and to learn it) is to figure out how you'd do it in the UI. Then move onto figuring out how to do the same thing in script.
When you say, "get all account of an employee," do you really mean get all accounts where a particular employee is on the account team? In the UI, that would be done by going to: Accounts > All Accounts Across Organizations, and querying for that specific user in the "Account Team" multi-value field.
From that same view, go to Help > About View in the application menu. You'll see in the popup that the view uses the Account business object and the Account business component. A quick examination of the applet you queried on will show you that the "Account Team" field on the applet is really the "Sales Rep" field on the Account business component. Here's how to mimic what we did in the UI, in script:
var boAccount = TheApplication().GetBusObject("Account");
var bcAccount = boAccount.GetBusComp("Account");
bcAccount.SetViewMode(AllView); // like All .. Across Orgs
bcAccount.ClearToQuery();
bcAccount.SetSearchSpec("Sales Rep", "NANG");
bcAccount.ExecuteQuery();
Then you can walk through the list of accounts and do something with each one like this:
// for each account
for (var bIsRowActive = bcAccount.FirstRecord();
bIsRowActive; b = bcAccount.NextRecord())
{
// do something here
}
I hope you're enjoying Siebel.