Suppose there is an intent in Dialogflow named "intent.direction". This intent have some phrases like : "Direction to PLACE_NAME" or "Navigate to PLACE_NAME",etc. Here "PLACE_NAME" is the name of any place to which user wants to go.
When this intent is triggered, I want the "PLACE_NAME" i.e. name of place, to be passed to my WEBHOOK (index.js).
Is there any way to do this?
-------------------UPDATED RESPONSES------------------
function makeDirection(app)
{
if (!hasScreen)
{
app.ask('Sorry, try this on a screen device');
}
else
{
//-----variables----
var body2="";
var placeName = app.getArgument( 'PLACE_NAME' );
app.ask(placeName);
below are the few images of testing, I am getting the last word i.e. "PLACE_NAME" but....
Yes.
I assume your Intent looks something like this:
The important things to note about the Intent settings are:
- We have selected the part of each training phrase that indicates the PLACE_NAME
- We have set them to the entity type of
@sys.any
. This will match anything. If we have other entity types that would make sense here (either one we define or something like @sys.address
or @sys.street-address
), we could have used those instead.
- We have changed the parameter name to
PLACE_NAME
.
- We have set the field to be required.
We've also done things like set the action name to something and turned on fulfillment through a webhook.
In our webhook, we'll get the values of the parameters that have been set by this Intent. How we do this will depend on what libraries we're using, if any.
Since you've indicated this is for Actions on Google, it is likely you're using the AoG node.js library. If so, we can get the parameter using something like
var placeName = app.getArgument( 'PLACE_NAME' );
If you're reading the JSON and using Dialogflow V1, you can get the value out of the body object with something like this:
var placeName = body.result.parameters['PLACE_NAME'];
if you're using Dialogflow V2 instead, it is at a slightly different path:
var placeName = body.queryResult.parameters['PLACE_NAME'];
This is an alternative way:
const functions = require('firebase-functions');
const yourClientId = 'xxxxx-xxxxxx.apps.googleusercontent.com';
const app = dialogflow({clientId: yourClientId}, {debug: true});
app.intent('intent.direction', (conv,params) => {
...
let placeName=params.PLACE_NAME
}