What is the equivalent of dialogflow's app.setContext() from v1 in the v2 API? Given the setup that the migration guide outlines (below), what call would you make to--for example--set a context when the welcome intent is triggered in the demo code below?
// v2
const functions = require('firebase-functions');
const { dialogflow } = require('actions-on-google');
const app = dialogflow();
app.intent('Default Welcome Intent', conv => {
conv.ask('How are you?');
});
exports.factsAboutGoogle = functions.https.onRequest(app);
Set the context like this:
const parameters = { // Custom parameters to pass with context
welcome: true,
};
conv.contexts.set('welcome-context', 5, parameters);
The second parametr is for context lifespan.
In your example code:
const functions = require('firebase-functions');
const { dialogflow } = require('actions-on-google');
const app = dialogflow();
app.intent('Default Welcome Intent', conv => {
conv.ask('How are you?');
const parameters = { // Custom parameters to pass with context
welcome: true,
};
conv.contexts.set('welcome-context', 5, parameters);
});
exports.factsAboutGoogle = functions.https.onRequest(app);
Then you can access the contexts with:
const contexts = conv.contexts;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With