IBM Watson Assistant: Vary chatbot response by date/season - ibm-cloud

I'm developing with IBM Watson Assistant and I want the response to vary by date (mainly so I can use seasonal jokes or change opening hours based on time of year from the #sys-date entity). I've built a test node and basically I need the intent to recognize #sys-date: October and respond one way that would differ if #sys-date: August has anyone had to vary the assistant's response based on the month? Is this even possible?
I have already tried #sys-date: October (System date is October) as the condition for the node (under "If Assistant Recognizes") and in date format but it never gets to that node. Thanks for the help!

You can build chatbots with conditional responses. In Watson Assistant #sys-date is a system entity. It helps to detect dates in inputs. But if there is no date in the input text, then it would not have a value.
You could use date / time functions in a response and check for the current month. Use if / then / else for the answer of the month.

Related

How to setup timezone in firestore usage tab?

Not in Analysis dashboard. But when you go database then usage tab.
I'm not in GMT-7
This is quota daily period. It does not depend on where you are, but it shows how daily quota is accounted.
If you open the link "billing and quota usage" it takes you to GCP and than there is a link "Understanding Quotas". It directs to App Engine quotas here, but I understand it's the same logic. According to the doc:
Daily quotas are refreshed daily at midnight Pacific time.
So this is information about which daily period you are currently in, and it's accounted in PDT time zone.
I hope it will help!
I raised this query to Google and received response as:
Thanks for reaching out. This is Estefani from the Firebase Support team.
Unfortunately, there is no way to change the time zone on the usage tab. This is because it's an internal tool for Firebase to be able to monitor and should be in that time zone.
For now, I suggest using our tools to monitor your database performance, and if you want, I can file a feature request on your behalf for this feature to be considered for future releases. Just give me the green light and I'll do the rest.

Tasks now have a due TIME as well as DATE but API still says 00:00:00

I noticed today that an updated iOS version of the Google Tasks app includes the option to set the time in addition to the due date. A welcome improvement, and the due datetime from the iOS app properly appears on the Gsuite website. But, I don't see the time when getting the Task from the API.
Should the API be returning the proper time? All I get is 00:00:00 the same as always.
If it matters, I'm using the PHP API client. Just updated today with composer to be sure I had the most current version.
At the time of writing, according to Google's documentation for the Tasks API:
The due date only records date information; the time portion of the timestamp is discarded when setting the due date. It isn't possible to read or write the time that a task is due via the API.
https://developers.google.com/tasks/reference/rest/v1/tasks#resource:-task

Make sure mobile user isn't sending fake date, time and timezone to the server

A mobile app has a check-in feature for the user to send a photo and observation and the app will append his location, date and time to the request, and send it to the server.
It is extremely important that this date and time is not faked by the user, or else the user will be able to be late at work but check-in with a fake "15 minutes ago".
The server is in USA, and the users are in many countries so there are different date and timezones, for that reason I think I can't use server date and time.
That check-in is visible in a website to users all around the world, but the check-in time must be the one from the user who made it.
Example
User checks-in at 5th July 13:45 in Mexico.
Website should show this date and time, 5th July 13:45, even if it's visualized by someone in Japan.
Problem
User checks-in at 6th July 09:37 in Brazil, but he fakes his mobile date and time settings to say it's 6th July 09:00 to pretend he's not late for work.
How can the sever know it's actually 6th July 09:37 and not 09:00, and show that correct date and time to whoever sees it anywhere in the world?
Keep in mind that user can also fake his timezone and GPS, still the server needs to get the real timezone to show real and not mislead information.
It is extremely important that this date and time is not faked by the user, or else the user will be able to be late at work but check-in with a fake "15 minutes ago".
This part is best handled by taking a UTC timestamp from the server when the request is received.
The server is in USA, and the users are in many countries so there are different date and timezones, for that reason I think I can't use server date and time.
Time zone is irrelevant for this purpose. Get the UTC time from the server, not the local time. The local time of the server should not ever be used in your application code.
If you need to adjust it to a particular time zone, then you can collect that from the user in a variety of ways, or you could assign one permanently to the user by some administrator of your application. Even if the time zone is wrong or faked, it won't affect the duration of time worked - because you captured that in UTC.
Example
User checks-in at 5th July 13:45 in Mexico.
Website should show this date and time, 5th July 13:45, even if it's visualized by someone in Japan.
That's fine. Save that the user is in Mexico (... actually, Mexico has several time zones, so you'll need to be more specific - use an IANA time zone identifier). You can convert the UTC timestamp to Mexico time whenever you like - either when you recieve the timestamp (saving both UTC and Mexico time), or when you display it to the user (saving only UTC and converting to Mexico time at the time of display). That the user is in Japan is also irrelevant to this scenario.
Problem
User checks-in at 6th July 09:37 in Brazil, but he fakes his mobile date and time settings to say it's 6th July 09:00 to pretend he's not late for work.
That's not an issue if you capture the time in UTC at the server and make sure your server's clock is synchronized properly.
Keep in mind that user can also fake his timezone and GPS, still the server needs to get the real timezone to show real and not mislead information.
Indeed. You can't capture this information from the user in a way that can't be falsified. However, you can avoid relying on this in your application code. For pure duration calculation, just base everything on UTC. For more complex things (like determining shift differentials or daily overtime working over midnight or at other peak local hours, etc.) then have some other user set the time zone that's applicable rather than collecting it. For example, assuming these are employees, the employee's manager or HR department would assign a time zone to the employee's personnel record.
Of course, if the employee is traveling for their job, and local time rules apply differently in different time zones, then you have even more logic to think about how you capture such details. (My experience tells me this is rare.)
You can't do what you want to do. Your app relies on the mobile device's OS to get things like date, time, timezone and gps. While it's harder to fake gps data on out of the box OS's it's always going to be possible. What you really want is a "backdoor". A backdoor that will let you get to the user device's "real" information no matter how hard the user tries to hide it. If that were possible we wouldn't need/have hackers and government cyber security teams. Anyone who knew the backdoor could just find anyone else in the world.
You can only try to catch such abusers using some of your own measures. You can check if the users time zone is changing. Or using an ip address from a different country since the last time he/she used the app. Or if you're really going to ask for gps permission, you can also see if that person's location over time doesn't make sense (E.g the user was in Canada but 3 hours later it looks like they're in China). Once you detect such possible abuse, you can flag the account for human review.

Dialogflow - Make answer depend on weekday - Nonlinear Dialog

I just started using Dialogflow and I'd like to create an Dialog
where I can ask "What time do I have to go to University today"
and depending on what day of the week it will give me a different answer.
I know I can get the date via #sys.date, but is there something similiar
to get the day of the week?
Thanks!
Dialogflow doesn't have a lot of built-in conditional processing. So while you can use #sys.date to turn "today" into the date, you can't then use the date to figure out some other value.
You can, however, use the Fulfillment section to turn a date passed as a parameter into whatever you want using whatever logic is available. For a simple task like this, you can use the built-in Fulfillment Inline Editor. If you enable it, you'll be presented with some sample code, including an illustration how to access the parameters from the request.
Once you have deployed it, you'll also need to turn on Fulfillment for the specific Intent that is doing the processing. (See the second image below.)
(Update: It does have some conditional processing, since it can choose different Intents based on the Contexts that are set and specific utterances. However, there is no Context that is set for the current day of the week. While you can set one yourself, this would be done through Fulfillment, so it is probably just as simple as actually processing the parameter. It might be useful for a more extensive conversation, but not for a short question-answer.)

Fetching 1 minute bars from Yahoo Finance

I'm trying to download 1 minute historical stock prices from Yahoo Finance, both for the current day and the previous ones.
Yahoo (just like Google) supports up to 15 days worth of data, using the following API query:
http://chartapi.finance.yahoo.com/instrument/1.0/AAPL/chartdata;type=quote;range=1d/csv
The thing is that data keeps on changing even when the markets are closed! Try refreshing every minute or so and some minute bars change, even from the beginning of the session.
Another interesting thing is that all of these queries return slightly different data for the same bars:
http://chartapi.finance.yahoo.com/instrument/2.0/AAPL/chartdata;type=quote;range=1d/csv
Replace the bold number with 100000 and it will still work but return slightly different data.
Does anyone understand this?
Is there a modern YQL query that can fetch historical minute data instead of this API?
Thanks!
Historical minute data is not as easily accessible as we all would like. I have found that the most affordable way to gather Intraday Stock Price data is to develop automated scripts that log price information for whenever the markets are open.
Similar to the Yahoo data URL that you shared, Bloomberg maintains 1-Day Intraday Price information in JSON format like this : https://www.bloomberg.com/markets/api/bulk-time-series/price/AAPL%3AUS?timeFrame=1_DAY
The URL convention appears easy to input on your own once you have a list of Ticker Symbols and an understanding of the consistent syntax.
To arrive at that URL initially though, without having any idea for guessing / reverse-engineering it, I simply went here https://www.bloomberg.com/quote/AAPL:US and used Developer Tools on my browser and tracked a background GET request which led me to that URL. I wouldn't be surprised if you could employ similar methods on other Price Data-related websites.
You can also write scripts to track price data as fast as your internet goes. One python package that I find pretty handy and is ystockquote
You can have it request price data every couple of seconds and log that into a daily time series database.
Yes there is other APIs.
I don't know if it can still help but if you need intraday data, there is a API on rapidapi called (Quotient) which allows to pull intraday (at 1-min level), EOD market (FX, Crypto, Stocks (US, CANADIAN, UK, AUSTRALIA, EUROPE), ETFs and Futures. It also provides earnings, dividends, splits and a lot others informations.