I am using events trigger in ADF v2. My trigger parameter values look like this:-
"parameters": {
"FolderPath": "#triggerBody().folderPath",
"FileName": "#triggerBody().fileName",
"Year": "#{split(#triggerBody().folderPath,'/')[2]}",
"Month": "#{split(#triggerBody().folderPath,'/')[3]}",
"Day": "#{split(#triggerBody().folderPath,'/')[4]}",
}
I initially ran it with just 2 initial parameters and the sample values for FolderPath look like this as seen from ADF monitor after a run is succeeded:-
test/poc/2019/09/20/00
But when I add other parameters to it, like Year, Month, Day as shown here, while publishing the changes, I get an error 'Trigger activation failed':-
When I hard coded Year, Month, Day in the trigger, it again started working. I am guessing some issues in calling expression language functions from event based trigger. I am basically trying to dynamically calculate individual elements from FolderPath such as 2019 as Year, 09 as Month and so on. How to achieve this?
Pasting DraganB's comment as an answer here:-
Try
"Year": "#{split(triggerBody().folderPath,'/')[2]}", "Month": "#{split(triggerBody().folderPath,'/')[3]}", "Day": "#{split(triggerBody().folderPath,'/')[4]}"
Basically delete # before triggerBody
Related
I am using a copy activity with request method as POST to copy the JSON response from a rest api. The rest api requires a body which contains date and time details in the below format
[
{
"start_date": "2023-02-07"
"start_time": "06:42:06"
"end_date": "2023-02-07"
"end_date": "08:47:06"
}
]
When am using the date and time as hardcoded values like the one shown above, it works fine. When I try to make it dynamic i.e. startdate as currentdate - 1 and start time as current time - 24hrs and end date as currentdate and end time as current time its failing.
In simple words I want to make the body of the api as dynamic
I tried the end date as "{#formatdatetime(utcnow(),'yyyy-MM-dd')}"
and end time as end time as "{#formatdatetime(utcnow(),'hh-MM-ss')}"
and few other combinations of the above code but its failing. Can someone please help me with this issue.
Since I don't have access to a REST API like yours, I have taken set variable activities to demonstrate how to create the required body using dynamic content.
I have used addDays() function to remove 1 day from both current date (1 day) and current time (24 hours and hence 1 day).
Then I have formatted the result using formatDateTime in the following way:
[ { "start_date": "#{formatDateTime(addDays(utcNow(),-1),'yyyy-MM-dd')}" "start_time": "#{formatDateTime(addDays(utcNow(),-1),'hh:mm:ss')}" "end_date": "#{formatDateTime(utcNow(),'yyyy-MM-dd')}" "end_date": "#{formatDateTime(utcNow(),'hh:mm:ss')}"} ]
The result would be as shown below:
I'm making a bot that can take dinner reservations. When it asks for the users reservation time, I'd like the bot to populate my variable $dayoftheweek with the day of the week based on the date the user inputs. How would I be able to do that?
here is my slot "If Found".
Basically I'd like to know what "value" I could put in to get the day of the week populated.
The easiest would be to use the new system entities (currently in beta). Enable the beta in your skills options. Then, in your dialog node, assign the following:
Check for: #sys-data.day_of_week
save as: mydayofweek
Note that the day names are lower case.
You can use the method reformatDateTime of the expession language to get the day from #sys-date.
For example setting $dayofweek to
<? #sys-date.reformatDateTime('u') ?>
will set $dayofweek to a value between "1" (Monday) and "7" (Sunday)
or setting $dayofweek to
<? #sys-date.reformatDateTime('E') ?>
will set $dayofweek to a value between "Mo" and "Su"
The value of #sys-date is stored as a string format "yyyy-MM-dd" e.g. "2016-11-21".
If you want to know what day of the week that date is, you can use the method reformatDateTime:
"<? #sys-date.reformatDateTime('EEEE') ?>"
Here all the posibles values of the method
So your node would look something like this.
Or in JSON format:
{
"context": {
"dayoftheweek": "<? #sys-date.reformatDateTime('EEEE') ?>"
}
}
And here a small test of what would be stored in $dayoftheweek:
Watson: Hello. How can I help you?
User: Day of the week test
Watson: Tell me a date
User: September 13, 2019
Watson: Friday
Here is the JSON Skill for the test.
I am using IBM Watson Assistant and try to validate user input against time frames / spans. What function should I use?
I was using #sys-date.before(now()) method to validate the time frame between past and present of a user input, but it does now work for me. If I input now or today Watson Assistant still thinks it is a past...
#sys-date.before(now()):
Looks "like you're trying to make a reservation in the past. Try again."
true $day it is
I expect if user inputs now or today to make reservations work, and if user inputs time in the past to response as
"like you're trying to make a reservation in the past. Try again."
The code snippet in question looks like this:
{ "context":
{ "day": "#sys-date" } }
{ "context":
{ "time": "<? #sys-time.reformatDateTime('h:mm a') ?>" } }
I solved it! What I did is I put (today) for here #sys-date.before(today()) and now for here #sys-time.before(now())
With IBM Watson Assistant you can use systen entities #sys-date and #sys-time to turn user input into data / time values. And you can use expression language functions for date and time to evaluate and transform those values. It seems that you are already using both. Now it is up to the logic...
There are functions before and after, but also sameMoment or sameOrAfter and more for comparisons. If the user inputs today, it is not before now because both would refer to the same day and date. Are you looking for the time value to be before the current timestamp or before the current date? You would need to compare time to time or date to date. You can reformat the values to snip off the time component and turn them into dates.
For more fancy validations you could even use java.util.Date functionality.
This should be true if it is a past moment:
now.after(yourInput)
I'm having trouble wrapping my head around the best way to solve this and could use some outside opinions. In my ES data, I have news articles from the past ~100 years. I'm trying to figure out the best way to search for articles by attributes of a date, not a date range. Here are some for-instances:
Get articles "on this day", e.g. April 15, regardless of year.
Search for articles written between specific hours, e.g. 9am-5pm, or days of the week e.g. Saturdays and Sundays.
Search for articles written during June, July, and August (again, regardless of year).
... and so on. The best solution I've come up with is to store these attributes separately in the index, e.g.
{
"publish_date": {
"full": "2014-04-15 12:34:56",
"year": 2014,
"month": 4,
"monthname": "april",
"day": 15,
"dayofweek": "tuesday",
"dayofyear": 105,
"hour": 12,
"minute": 34,
"second": 56,
"week": 16
}
}
I'm not happy with this solution and I want to break up with it.
Any thoughts on what you would do differently, or how you'd solve this problem?
Thanks!
first off, why aren't you happy with it? It's perfectly fine and in-line with the 'denormalization' hat you probably need to start wearing when doing document-modeling in ES (and other denormalized / nosql databases)
Having said that, you don't need to write the different fields in your own indexing-code. Instead you could go for:
using multi-fields, which allows 1 input field to be indexed to multiple ES-fields, each with there own mapping. http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-core-types.html#_multi_fields_3
define such a ES-field for each date-mapping you want to do: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/mapping-date-format.html
we have enabled the October 2nd 2013 breaking changes for our application yesterday, the change to the application settings is already confirmed. If I submit bid_info in the new format (with strings instead of numeric indexes) it works:
"bid_info": {
"CLICKS": 75
}
When I try to read the ad group with a request to its url later, I get a bid_info and a max_bid setting in parallel (I expected that max_bid will be removed in October 2nd-mode), but the bid_info contains the numeric index and not the expected CLICKS-string:
(...)
"adgroup_status": 3,
"bid_type": 1,
"max_bid": 75,
"bid_info": {
"1": 75
},
"ad_status": 3,
"locations": [
3
],
(...)
Any suggestions for that? Is this bug or by design? Or did something went wrong with the activation of the October 2nd changes for our application?
Bye
Tobias
Same for me but without activating october 2nd breaking changes...
It's quite strange to have number as name field and it is not allowed in languages like in c#.
It should be this kind of info:
A dictionary of values that you place on your bid
CPM={'REACH':cent_value}
CPC={'CLICKS':cent_value}
oCPM or CPA={'ACTIONS':cent_value}
I've 1, 38, 44, 55 in place of this.
Update, it's actually this:
Actions: 55
Reach: 44
Clicks: 1
Social Impressions: 38
More info: https://developers.facebook.com/docs/reference/ads-api/optimizedcpm/
https://developers.facebook.com/bugs/539767489417940?browse=external_tasks_search_results_5203fffd63da04c48847913
I actually filed a ticket against this. The Facebook bug response said it would be fixed on July 17th, however a contact at Facebook elevated this ticket after it was not fixed on July 17th, and it is now being currently worked on.
We were told it should be functional by the end of August.