What expression can I use in Watson Assistant for opening times on certain dates? - ibm-watson

I have a Watson bot i'm trying to program for reserving tables. I'd like to know the expression I could use to implement my opening times.
For example the restaurant has the following hours:
Monday-Friday 11:30AM until 10:30PM, last reservation can is 9:30PM.
Saturday-Sunday 5PM until 10:30PM
I don't want Watson to take reservations outside those hours. How code I implement this in slots?

You can use methods of the expession language to evaluate the input.
For example a condition to check if it is a valid weekday reservation could be :
#sys-date.reformatDateTime('u')<6 AND #sys-time.before('21:30:01') AND #sys-time.after('11:29:59')
I would not recommend to to do the check in slots.
Easier would be to do the check after slot-filling.
If it is no valid reservation you can offer the client to just try again.

I don't think there's any way to do this in Watson Assistant directly. You can do conditional evaluation (check if a number if greater than or less than another number), but your needs are a little more complex (with time involved, and even dates too).
I'd suggest handling your reservation validation process externally using the webhook feature. Collect your reservation date and time, and then send those to your webhook as parameters. The webhook can then respond with a confirmation that the reservation is OK, or it could reject it (and provide a reason). When your dialog node that calls the webhook gets the response, if it sees a rejection based on operating hours, it could inform the user that they need to select a time that the restaurant is open, remind them of the hours, and then go back to the node that collects the reservation info.

Related

How to know a Salesforce table field is auto-calculated?

Salesforce provides CaseMilestone table. Each time I call the API to get a same object, I noticed that TimeRemainingInMins field has a different value. So I guessed this field is auto-calculated each time I call the API.
Is there a way to know what fields in a table are auto-calculated ?
Note : I am using python simple-salesforce library.
Case milestone is special because it's used as countdown to service level agreement (SLA) violation, drives some escalation rules. Depending on how admin configured the clock you may notice it stops for weekends, bank holidays or maybe count only Mon-Fri 9-17...
Out of the box other place that may have similar functionality is OpportunityHistory table. Don't remember exactly but it's used by SF for for duration reporting, how long oppty spent in each stage.
That's standard. For custom fields that change every time you read them despite nothing actually changing the record (lastmodifiedate staying same) - your admin could have created formula fields based on "NOW()" or "TODAY()", these would also recalculate every time you read them. You'd need some "describe" calls to get the field types and the formula itself.

How to disregard the #sys-number to words

How can I do watson conversation to ignore a number written in a sentence don't converting to #sys-number?
Ex.: I want to give you A call.
In the case, the Watson understends 'A' with '1'. But I don't have this.
When you're using this example to send the message, Watson Conversation shown to you what they understand (Intent, entities, etc).
You can use .literal method and show the number in the cardinal form, and you can use the #sys-number for getting this number in another answer, or in your application with one custom code.
Example:
I want to give you #sys-number.literal call.
In this case, you can check in this table how System entity #sys-number works:
Obs.: You can disable the #sys-number inside the System Entities and Watson won't try to identify the number inside your Conversation.
See the Official documentation talking about System Entities within Watson Conversation.
I am not seeing the same behavior. I have sys-number turned on but it is not matching to the letter A.

Amazon MWS determine if product is in BuyBox

I am integrating MWS Amazon API. For importing product I need one important field like whether the seller product is buybox winner or not. I need to set flag in our DB.
I have check all the possible API of product in Amazon scratchpad but not get luck how to get this information.
The winner of the buy box can (and does) change very frequently, depending on the number of sellers for the product. The best way to get up-to-the-minute notifications of a product's buy box status is to subscribe to the AnyOfferChangedNotification: https://docs.developer.amazonservices.com/en_US/notifications/Notifications_AnyOfferChangedNotification.html
You can use those notifications to update your database. Another option is the Products API which has a GetLowestPricedOffersForASIN operation which will tell you if your ASIN is currently in the buy box. http://docs.developer.amazonservices.com/en_US/products/Products_GetLowestPricedOffersForASIN.html
Look for IsBuyBoxWinner.
While the question is old, it could still be useful to someone having a right answer about the product api solution.
In the product api there is GetLowestPricedOffersForSKU (slightly different from GetLowestPricedOffersForASIN ) which has, in addition to the information "IsBuyBoxWinner", the information "MyOffer". The two values combined can tell if you have the buybox.
Keep in mind that the api call limits for both are very strict (200 requests max per hours) so in the case of a very high number of offers the subscription to "AnyOfferChangedNotification" is the only real option. It requires further developing to consume those notifications though, so it is by no means simple to develop.
One thing to consider is that the AnyOfferChangedNotification is not a service that can push to the SQS queue that is a FIFO(First one first-out) style buffer. You can only push to a standard - random order sqs queue. I thought I was being smart when I set up two threads in my application, one to download the messages and one to process them. However when you download messages from download these messages you can get messages from anywhere in the SQS queue. To be successful you need to at least
Download all the messages to your local cache/buffer/db until amazon returns 'there are no more messages'
Run your process off of that local buffer that was built and current as the time you got the last 'no more message' returned from amazon
It is not clear from amazons documentation but I had a concern that I have not proven yet but worth looking in to. If an asin reprices two or three times quickly it is not clear if the messages could come in to queue out of order (or any one messages could be delayed). By 'out of order' I mean for one sku/asin it is not clear if you can get a message with a more recent 'Time of Offer Change' before one with an older 'Time of Offer Change' If so that could create a situation where 1)you have a ASIN that reprices at 12:00:00 and again at 12:00:01(Time of Offer Change time). 2) At 12:01:00 you poll the queue and the later 12:00:01 price change is there but not ther earlier one from 12:00:00. 3)You iterate the sqs queue until you clear it and then you do your thing(reprice or send messages or whatever). Then on the next pass you poll the queue again and you get this earlier AnyOfferChangeNotification. I added logic in my code to track the 'Time of Offer Change' for any asin/sku and alarm if it rolls backwards.
Other things to consider.
1)If you go out of stock on a ASIN/SKU you stop getting messages 2)You dont start getting messages on ASIN/SKU until you ship the item in for the first time, just adding it to FBA inventory is not enough. If you need pricing to update that earlier (or when you go out of stock) you also need to poll GetLowestPricedOffersForASIN

How to make a simulation of a dynamic behavior in Jason (Agentspeak)

I am beginner in Jason(Agentspeak), working on social simulation project using Multi-agent simulation in Jason. I just started Jason, so a beginner in this declarative type language. I want to simulate the people behavior that changes over time.
// the code statement might be
Like an agent have characteristics
Age=30 years
Marital status = unmarried
education= college
employment= unemployed
etc etc
now I want to simulate multiple agents virtually and simulate for 20 years. so that based on already defined criteria I want to know which transitions (unmarried toward married OR education from college to university OR employment from unemployed to employment etc) in agent life has taken place.
I need guidance about Simulation in Jason, how to handle ?
Thanking you all
In Jason you define what agent believes in and what goals agent has. There is also a concept of plan to achieve those goals. Beliefs represent the information available to an agent. For example agent's age is 30 according to agents own information.
age(30)[Source(self)].
Status(single)[Source(self)].
or for example agent believes that it likes some other agent:
likes(anotherAgent).
Goals represent states of affairs the agent wants to achieve, for example your agent might want to write a book or find a job :
!write(book).
!find(job).
in addition to these goals , we can define test goals which checks if a condition is met:
?married(A).
An AgentSpeak plan has the following general structure:
triggering_event : context <- body.
• where:
the triggering event denotes the events that the plan is meant to handle;
the context represent the circumstances in which the plan can be used;
the body is the course of action to be used to handle the event if the context is believed true at the time a plan is being chosen
to handle the event.
You should define plans which can help change the status of agent from single to married or from unemployed to find a job. for example agent might need to check first if it knows someone, or if already knows, agent should check if it likes someone, or any other rules that you need to define as preference of agents for choosing a partner.
There is a book which can help you to get started:
There is also an active mailing list available on the Jason website.

How to calculate time left in a count down scenario

We have a requirement to count down based on a user taking a test. What would be a best way to tackle tracking the time taken by a user while taking the test.
We do capture start time, end time. But the calculations go awry if the application server or the OS goes down during the test. We were thinking of using another variable to store the current time after the user submits an answer to the question. So (end time - current time) would reasonably account for the amount of time left.
Is there an effective way to calculate the "time left" in such cases other than the one mentioned above?
We would like the solution to be database agnostic as possible
To be specific, I'll continue with MYSQL.
As you may stated, you have captured start time. When the test loaded by the user, write this timestamp in a DATETIME field. Another option is that using UNIX_STAMP. And then, when user submits the answer, you may easily put this data to another DATETIME field.
As well as other rdbms systems, mysql got the date-time manipulation functions.
SELECT CURRENT_TIMESTAMP(); query returns current timestamp. eg. '2007-12-15 23:50:26'
SELECT UNIX_TIMESTAMP(); query returns current unix timestamp which may be easy to calculate difference. eg. 1111885200
Also we have got DATE_SUB() and DATE_ADD() functions for addition, subtraction operations.
Please visit date-time manual page for details. I guess this information will lead you to a proper solution.
--
Added on Sep 18:
You may use javascript to track user behaviour. For instance, a function calls a server side script with a salt or something you have in session. That server side script records the current timestamp as "last update". Database parts same as above.
I have written such a set of exams using a countdown timer. As unfortunately there were times when power cuts happened frequently in the computer lab, I had to add code to handle this. Basically, the exam program saves its state (the answers and the time elapsed) in an .ini file every 30 seconds. When the exam program starts, it checks to see whether such an ini file exists - if so, it carries on from where the program ceased (in terms of which questions have yet to be answered and how long remains), otherwise the program begins anew.
In order to make the exams standalone and thus independent of any server, all the questions and options were exported to a resource file, which was then included in the build of the exam itself.

Resources