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!
0
votes
1 Answers
2
votes
- create a
yesoraffirmativeAPI.AI entity. In the entity include all the synonym values (like the ones you describedyes/yep/okay/ok). - create an intent with examples of all your user queries where the user might say this first (you may need to include the
yesentity in multiple intents). - Create a webhook (fulfillment getting started guide here). In the webhook check for the
yesparameter 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']
}
});
}
});