1

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.

  • Welcome to SO. Please add what your exact question is. What of the showed code does not work? Why can't you just your posted code? – miile7 Jun 26 '20 at 06:37
  • It is working @miile7 but i just want to know how to proceed further as in if a particular entity is selected (say google is selected) i want to code something so that the bot asks for another question witht the options "random question" or "dsa question" and then the bot will show the interview problem accordingly. I want to write the code for this. – Benjamin Franklin Jun 26 '20 at 06:42

1 Answers1

1

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.