I have an intent with several nested follow-up intents like this:
And then in the code of the fulfillment function I have this where the number 70 is firing the giveChoice
but the rest is not fired. Why? How do I do this with followup intents?
let intentMap = new Map();
intentMap.set('Default Welcome Intent', welcome);
intentMap.set('Default Fallback Intent', fallback);
//Intent - 70
intentMap.set('0068 - Intents - 70', giveChoice);
intentMap.set('0068 - Intents - 70 - no', giveFirstNextQuestion);
intentMap.set('0068 - Intents - 70 - no - no', giveSecondNextQuestion);
intentMap.set('0068 - Intents - 70 - no - no - no', giveThirdNextQuestion);
// intentMap.set('your intent name here', googleAssistantHandler);
agent.handleRequest(intentMap);
I managed to recreate your issue and solve it. I will summarize the points to follow:
Enable webhook call for this intent (in the fulfillment section) for all the intents and follow-up intents you want to use.
The functions you create to use, "giveChoice", "giveFirstNextQuestion",... should follow the structure:
function givechoice(agent){
agent.add(`Would you like this response to be recorded?`);
agent.setContext({
name: 'first-call',
lifespan: 2,
});
}
function afirmative(agent){
agent.getContext('first-call');
agent.add(`Thank you for accepting`);
}
Pay attention that in the case above I only do one follow-up intent. If you do a third, for instance, then the second function has to have a getContext and a setContext to work properly.
The final part is exactly as you did it. In my case:
let intentMap = new Map();
intentMap.set('0068 - Intents - 70',givechoice);
intentMap.set('0068 - Intents - 70 - yes',afirmative);
agent.handleRequest(intentMap);