Reputation: 39
How can I set dynamic args in Text response? not from user phrases
I have a case:
bot says: "Do you find a work?"
user says: "Yes"
Text response:
bot says: "I can offer you vacancy {random vacancy}"
Upvotes: 1
Views: 1607
Reputation: 1554
You can't do it with a default text response, in fact, you need to enable webhook call for that intent in the fulfillment section. I'll show you how my intent looks like.
Here you have the webhook code:
'use strict';
const http = require('http');
const request2 = require('request');
exports.dialogflowFirebaseFulfillment = (req, res) => {
console.log('Dialogflow Request body: ' + JSON.stringify(req.body));
let action = req.body.queryResult['intent']['displayName'];
switch(action){
case "work":
// Get the city from a database
let city="Randomcity";
// Get the job from a database
let job="randomjob";
res.send(JSON.stringify({ 'fulfillmentText': "I can offer you this fantastic job in "+city+" city, doing "+job}));
break;
//Add more cases if you have more intents
}
}
And this is the result:
Upvotes: 3
Reputation: 6800
There are two cases :
1. If you want to return random arguments, then you can simply set all possible arguments in the responses and DialogFlow will randomly select a response a send it to user.
Hope it helps.
Upvotes: 1