Reputation: 43
I got a weird problem with dialogflow / node.js backend.
Within Dialogflow I have two entities "color" and "order_amount". I set the entities to required within the intent. But only one of the required entities is send back to my backend and the other is undefined. Though both are received within dialogflow.
app.intent('Default Welcome Intent - yes', (conv, {product_color}, {order_amount}) => {
console.log({product_color});
console.log({order_amount});
conv.ask(`Top. In welke maat?`);
});
So for example, when this intent runs the slotfilling is being done in dialogflow. But I only the first entity is defined e.g {color} and {order_amount} is undefined. When I switch {product_color} and {order_amount} as the below example. Then product_color is undefined.
app.intent('Default Welcome Intent - yes', (conv, {order_amount}, {product_color})
Anyone knows whats going on?
Upvotes: 1
Views: 58
Reputation: 50701
The issue is that you're mangling your JavaScript. The second function parameter contains an object with all the Intent parameters. The {name1}
syntax in JavaScript maps object attribute names to a variable. So you could rewrite the line as
app.intent('Default Welcome Intent - yes', (conv, {product_color,order_amount})
Upvotes: 1
Reputation: 43
Got the answer myself. You can use "params": https://actions-on-google.github.io/actions-on-google-nodejs/classes/dialogflow.dialogflowconversation.html#parameters
Upvotes: 2