title: Conversational facebook messenger bot
body: <p>Hi I am making a new bot for a product where I need to ask customer login id and password. </p>
  
  <p>So for my case, user would initiate a conversation by typing <code>hi</code> then bot will reply <code>Hey! How can I help you</code>, here if customer enter <code>I want to transfer money</code> then bot will respond <code>Please enter a login ID</code>, first here customer will enter login id and bot will respond <code>Enter your password</code> then it goes like this.</p>
  
  <p>I have done like below in node js which seems not a correct way to me.</p>
  
  <pre><code>app.post('/webhook/', function (req, res) {
  
      let messaging_events = req.body.entry[0].messaging
      for (let i = 0; i &lt; messaging_events.length; i++) {
          let event = req.body.entry[0].messaging[i]
          let sender = event.sender.id
          if (event.message &amp;&amp; event.message.text) {
              let text = event.message.text.toLowerCase();
              var greets = ['hi', 'hey', 'hello', 'good morning', 'good evening']
              if(greets.indexOf(text) &gt; -1) {
                  sendTextMessage(sender, 'Hey! How can I help you ?')
              }
              else if((text.indexOf('money transfer') &gt; -1) || (text.indexOf('transfer money') &gt; -1)) {
                  sendTextMessage(sender, 'OK. Please enter your login details.')
                  lastMessage = 'Please enter your login ID.'
              } else if(text.indexOf('restart') &gt; -1) {
                  lastMessage = ''
                  sendTextMessage(sender, 'Thanks, Give a seconds to me :)')
              }
              else {
                  sendTextMessage(sender, 'Huh! Uhhh broke me :(')
              }
          } else if (event.postback) {
              var payload = event.postback.payload;
              if(payload) {
                  // When a postback is called, we'll send a message back to the sender to 
                  // let them know it was successful.
                  // do nothing
                  switch (payload) {
                      case 'USER_DEFINED_PAYLOAD':
                          sendTextMessage(sender, 'Welcome to XXX, What are you looking for today ?')
                          break;
                  }
              }
              console.log("Postback received: " + JSON.stringify(event.postback));
          }
      }
      res.sendStatus(200)
  })
  </code></pre>
  
  <p>What is the best way to achieve my case, how flow will be maintained if user enter a login id then bot would ask for password.</p>
  
  <p>Thanks in advance.</p>