Implementing the chatbot

Now that we have the backend tasks ready, let's focus on the chatbot itself. In general, the chatbot will take the user's utterances as input and respond with utterances of its own. However, since we are building a chatbot for Facebook Messenger, our chatbot will mostly take input in the form of button presses and respond using both utterances and visually appealing cards.

Let's start by implementing the Chatbot.java class. We will begin by working out an algorithm to process and respond to users' utterances:

  1. Process user input.
  2. Update context.
  3. Identify bot intent.
  4. Generate bot utterance and output structure.
  5. Respond.

This one is a very simple algorithm to start with. First, user input, in the form of utterances ...

Get Hands-On Chatbots and Conversational UI Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.