Search code examples
dialogflow-esactions-on-googledialogflow-es-fulfillment

How to mention multiple Intent call in single app.intent function


In Fulfillment, I need to call the same function for no. of intents. Current code is given below.

I want to create a single app.intent(instead of multiple like mentioned below) functions for multiple intents. I need to create a single app.Intent function put all the possible intent names. Please help me out how to achieve this.

app.intent('Intent1', (conv,{vardata})=>{ 
Result(vardata);
});   
app.intent('Intent2', (conv,{vardata})=>{ 
Result(vardata);
});    
app.intent('Intent3', (conv,{vardata})=>{ 
Result(vardata);
});    

Result(vardata)
{
//do something based on vardata value
}

Solution

  • You should be able to combine the handlers into one by providing an array instead of a single string value as a name.

    app.intent(['Intent1', 'Intent2', 'Intent3'], (conv,{vardata})=>{ 
      Result(vardata);
    });     
    
    Result(vardata)
    {
    //do something based on vardata value
    }