Dialogflow prebuilt agent's Make Appointment intent seems to be buggy on initial deployment - dialogflow-es-fulfillment

First, when you follow the tutorial here and deploy the recommended prebuilt agent, and you view the Inline Editor under fulfillment, the editor displays a warning/error on line 82:
expected an assignment or function call and instead saw an expression.
code snippet throwing up the error:
err ? reject(err) : resolve(event);
Having set up the Google Calender API and updated the parameter in index.js file, the prebuilt agent returns this error below when "Make Appointment intent" is run. the appointmentDateString constant can not read and parse the time parameter correctly.
Sorry, we're booked on Invalid Date at Invalid Date. Is there anything else I can do for you?

The problem is that the date format is not correct beacause there are two timeZoneOffset in the string to parse to Date.
In order to solve this issue, erase one of the timeoffset.
function convertParametersDate(date, time){
//ORIGINAL
//return new Date(Date.parse(date.split('T')[0] + 'T' + time.split('T')[1].split('-')[0] **+ timeZoneOffset**));
//SOLVED
return new Date(Date.parse(date.split('T')[0] + 'T' + time.split('T')[1].split('-')[0]));
}

Related

Power Automate Cloud - OneDrive When a file is created Trigger Condition

I'm using the OneDrive when a file is created trigger in my flow. I want to set a trigger condition that will only trigger if the file type is .xlsx
I tried the following condition:
#contains(triggerOutputs()?['headers/x-ms-file-name-encoded'], 'xlsx')
I get the following error:
InvalidTemplate. Unable to process template language expressions for trigger 'When_a_file_is_created' at line '1' and column '37225': 'The template language function 'endswith' expects its first parameter to be of type string. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#endswith for usage details.'.
I did some research on-line and it appears to be due to the OneDrive dynamic selector "File name" being encoded, but I wasn't able to find any solutions for working around this issue.
Any help is greatly appreciated
Thanks
You can use the base64tostring function to turn it into a readable string.
Try an trigger condition expression like below
#endswith(base64tostring(triggerOutputs()?['headers/x-ms-file-name-encoded']), '.xlsx')

Apex DateTime to String then pass the argument

I have two Visualforce pages, and for several reasons I've decided it is best to pass a datetime value between them as a string. However, after my implementation my date always appear to be null even though my code seems to compile.
I have researched quite a few formatting topics but unfortunately each variation of the format() on date time seems to not produce different results.
The controller on page 1 declares two public variables
public datetime qcdate;
public String fdt;
qcdate is generated from a SOQL query.
wo = [SELECT id, WorkOrderNumber, Quality_Control_Timestamp__c FROM WorkOrder WHERE id=:woid];
qcdate = wo.Quality_Control_Timestamp__c;
fdt is then generated from a method
fdt = getMyFormattedDate(qcdate);
which looks like this
public String getMyFormattedDate(datetime dt){
return dt.format(); }
fdt is then passed in the URL to my next VF page.
String url = '/apex/workordermaintenanceinvoice?tenlan='+tenlan +'&woid=' + woid + '&invnum=' + invnum + '&addr1=' + addr1 + 'fdt=' + fdt;
PageReference pr = new PageReference(url);
I expected when calling {!fdt} on my next page to get a proper string. But I do not.
UPDATE:
Sorry I guess I should not have assumed that it was taken for granted that the passed variable was called correctly. Once the variable is passed the following happens:
The new page controller creates the variable:
public String fdt
The variable is captured with a getparameters().
fdt = apexpages.currentPage().getparameters().get('fdt');
The getfdt() method is created
public String getfdt(){
return fdt;
}
Which is then called on the VF page
{!fdt}
This all of course still yields a 'blank' date which is the mystery I'm still trying to solve.
You passed it via URL, cool. But... so what? Page params don't get magically parsed into class variables on the target page. Like if you have a record-specific page and you know in the url there's /apex/SomePage?id=001.... - that doesn't automatically mean your VF page will have anything in {!id} or that your apex controller (if there's any) will have id class variable. The only "magic" thing you get in apex is the standard controller and hopefully it'll have something in sc.getId() but that's it.
In fact it'd be very stupid and dangerous. Imagine code like Integer integer = 5, that'd be fun to debug, in next line you type "integer" and what would that be, the type or variable? Having a variable named "id" would be bad idea too.
If you want to access the fdt URL param in target page in pure Visualforce, something like {!$CurrentPage.parameters.fdt} should work OK. If you need it in Apex - you'll have to parse it out of the URL. Similar thing, ApexPages.currentPage() and then call getParameters() on it.
(Similarly it's cleaner to set parameters that way too, not hand-crafting the URL and "&" signs manually. If you do it manual you theoretically should escape special characters... Let apex do it for you.

Dialogflow not triggering prompt for required parameters

I have the issue that prompts I defined for parameters which are required in an intent are simply not triggered when the parameter is missing. The simulator is responding with "sorry, I didn't get that" if the parameter is missing.
An example:
functions code using dialogflow-fulfillment nodejs library:
function test(agent) {
let age = agent.parameters.age.amount;
let conv = agent.conv();
conv.ask('This is from the backend: ' + age);
return agent.add(conv);
}
Intent on Dialogflow:
Simulator:
The issue is that the training phrase you used includes a number, so the machine learning sees the pattern as something roughly like "If the person says 'test' followed by a number, trigger this intent."
But when testing, we were just using a phrase "test". The pattern detection didn't see a number as part of the phrase, so it didn't think it would match that intent.
To solve this, you can add the training phrase of just "test" without giving it a parameter. This will match the phrase, but still need to make sure the "age" parameter has a value, so it will prompt for it.

How to correctly add a variable's value to parameters in Postman?

I'm learning Chrome Postman now and my issue now is:
I need to generate a new value of a parameter for each request.
So each request (I make a POST) must have a unique value of this parameter.
So far I thought to manage it with environment variables and I have done it like this:
I add a new environment variable with a unique value
I use this variable in the "value" field on a parameter
And it doesn't work - I get error 401 Authorization Required.
Seems that the error is not connected to the parameter at all but as soon as I change the parameter and manually input a unique data it works well!
So this will work for me:
Please suggest what I'm doing wrong here and advice how to do it right. Thanks!
Spent some more hours investigating I found my problem!
The problem is the value I put into a variable - it included ":" sign and this sign simply changed my URL.

Running a query using date from a form MS Access

How do I run a query using a value from a textbox from a form I have? I know that there is another post here at Stackoverflow dealing with this issue but I found it to be insufficient for my needs.
I formated my textbox into Medium Date format with its default value being =Date(). However, when I pick up a date and open my report I get this error:
Runtime error 3071: Expression Too Complex
My where clause is this
WHERE
(
(AllInfo.DateOpened >= CDate([Forms]![Main Form]![WindowPrintOptions]![CustomizedReport]!txtDateOpenedFrom.Value))
)
and I am sure it is this code piece that is throwing the problem since when I take it out of the query the error message simply disappears.
Any ideas?
Try with:
(AllInfo.DateOpened >= DateValue([Forms]![Main Form]![WindowPrintOptions].[Form]!txtDateOpenedFrom))
)
Folks,
I got the problem. It was the "AllInfo" alias. It wasn't applicable at that escope inside the query. By changing the proper things, it was enough to write:
[Forms]![Main Form]![WindowPrintOptions]![CustomizedReport]!txtDateOpenedFrom.Value
Issue solved. Thank you all!