Reputation: 11
I have been trying to achieve the following flow in dialogflow. So if a user selects from any of the following four rich responses(facebook,google,amazon,microsoft), the user will again be prompted to choose if they want a random interview problem or specific dsa topic(of that company) after which the user get's a question from that category
My code for this something like this
app.intent(COMPANY_INTENT, (conv) => {
const company = conv.parameters[COMPANY_ENTITY].toLowerCase();
conv.ask( "dsa or shuffle" );
if(company=="google" ) {
var set1=[
'"here is a question from google1 reverse a linked list"',
'"here is a question from google2 reverse a linked list"'];
var pick = Math.floor( Math.random() * set1.length );
var response = set1[pick];
conv.ask( response );
} else if(company=="microsoft"){
conv.ask("here's a question from microsoft reverse a linked list");
} else if(company=="facebook"){
conv.ask("here's a question from facebook reverse a linked list");
} else{
conv.ask("failed");
}
});
I am trying to achive the flow where the user can be prompted to choose between random question and dsa type question of the specific company and after that accordingly give the problem to user. Can someone tell how to do this or code this logic.
Upvotes: 1
Views: 150
Reputation: 21
If the question you want to aks is different depending on the company the user chooses, you can just send back as a response the question you want to ask to the user for each company, and create follow up intents in Dialogflow to get the user answer to that questions.
If the question you want to aks is the same depending on the company the user chooses, the best option is creating a required parameter in the same intent to store that new information and just add the question you want to ask as the prompt for the parameter. In that way you would receive both parameters in fullfilment (company and random/dsa) at the same time and you could just respond accordingly.
Upvotes: 1