Reputation: 183
I'm new to api.ai and trying to make the bot adapt to the user's vocabulary. For example if at first the bot asks if the user wants to talk, user will say yes/yep/okay/ok etc and I want to use that answer to user later again. Can I do this? thanks!
Upvotes: 0
Views: 59
Reputation: 3479
yes
or affirmative
API.AI entity. In the entity include all the synonym values (like the ones you described yes
/yep
/okay
/ok
).yes
entity in multiple intents). yes
parameter in the webhook request and if it is present record the value, in a database along with a user identifier (provided by the platform you choose, like Google Assistant or Slack) for later retrieval in a response to the user. Below is some non-working code using Cloud Functions for Firebase for fulfillment of an API.AI agent and the Firebase Realtime Database to store the user data that would be a good starting point for your fulfillment:
const functions = require('firebase-functions');
const admin = require("firebase-admin");
const db = admin.database();
const ref = db.ref("your/firebase/database/here");
exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
const parameters = request.body.result.parameters;
if (parameters['yes']){
var usersRef = ref.child("users");
usersRef.set({
userId: {
yes: parameters['yes']
}
});
}
});
Upvotes: 2