Any parameters set on an intent will be kept in the output context and recoverable in posterior follow-up intents within the lifespan of such context.
Through the Dialogflow UI you can reference them in the initial response as $<parameter-name>
.
For example, assuming your parameter name is id, the response can be: Welcome player $id,...
.
For values in the context in posterior follow-up intents use #<context-name>.<parameter-name>
.
For example, in a second follow-up which has parameter answer and input context id-followup use Your answer has been $answer, if you are not player #id-followup.id please let me know your actual id
.
If you need to use the Fulfillment Webhook I recommend a structure like the one illustrated here, i.e. a structure like:
//The user inputs a participant ID (name of the parameter is id)
function answers(agent){
const id = agent.parameters.id;
agent.add(`So your id is ${id}`);
agent.add(`Any extra questions...`);
agent.setContext({
name: 'question',
lifespan: 5, // Amount of follow-up intents this context will be kept
parameters: {'cid': id},
});
}
// Next functions that use the participant id as input context
function answers2(agent){
// Get the context and from it extract the id value
const cont = agent.getContext('question');
const particular_id = cont.parameters.cid;
// The rest of your code
Some documentation you may find useful includes Input and output contexts, Parameter reference,...