The Data Briefing: How to Build a Chatbot in a Weekend

Sep 27, 2017

The best way to learn a new technical skill is to just play around with the technology. Learning through playing with technology goes for building websites, mobile apps, and now, chatbots. As chatbots have become more popular, some online sites will let you create a chatbot with little or no programming. Now, realize that the easier it is to create the chatbot, the less sophisticated the chatbot will be. However, you may not need a sophisticated chatbot that can handle almost any situation.

Chatbot technology concept on electric circuit background surrounded by related AI and chat icons

Technically, you can build a basic chatbot in about 10 to 15 minutes. I used ChatFuel to build a Facebook chatbot. ChatFuel is free and has a drag-and-drop builder platform. You create text blocks of responses you can link to respond to user messages. ChatFuel provides an artificial intelligence (AI) service you can add to your chatbot so it will respond to key terms or phrases. So, if it takes only 15 minutes to build a chatbot, why spend the weekend?

You spend most of the weekend creating the conversational routines for the chatbot. Creating conversational routines starts with determining what the purpose of the chatbot is regarding the conversational flow and user journey. For my test chatbot, I decided that the goal of the chatbot is to educate users on leadership development concepts and techniques. I visually mapped out the most common leadership development concepts, questions, and expected conversation paths. You do this in ChatFuel by creating blocks. In other chatbot programming languages, you can set up a database or use an AI service like IBM’s Watson.

For your first chatbot, you will want to keep it simple. So, you will want to build a chatbot that is “on the rails”—conversations that guide the user down pre-defined queries. The alternative is a more responsive chatbot that uses heavy-duty AI to handle more spontaneous user conversations. For our weekend project, stay on the rails. That means focusing on one task for the chatbot and prevent conversational dead ends. Building good chatbot conversations requires careful scripting (like the scripting you see in movies; not programming).

Chatbot and human conversation messages.

As another chatbot developer explains, “[e]very sentence has to drive the conversation forward and bring the user closer to his goal.” You want to create a persona for your chatbot that uses dialogue to advance the customer journey while understanding the context of the user’s requests. Think of scenarios and flowchart the conversations from the query-response-second query-second response and so on.

For example, let’s consider my leadership development chatbot. An obvious question would be, “what is leadership development.” I would prepare a response that can then branch off to “why is leadership development important” or “how are leaders developed” or “how do I develop myself as a leader” questions. Each of the previous questions will break off into their conversational paths. Where you stop depends on how many topics seem a natural fit for your users. As your chatbot interacts with users, you will create more topics and conversation paths based on user feedback.

The final part to scripting is handling user queries you do not expect. Chatbots should have a repertoire of responses that tells users when the chatbot does not know the answer or doesn’t understand the question. ChatFuel has a default response block built for these occasions.

So, here is a fun weekend project that can teach you more about the exciting technology of chatbots while giving you some experience in building Conversational User Interfaces. Even if you do not build another chatbot, I hope this project gives you greater insight into how chatbots work and the importance of scripting the user journey. As the federal government adopts more chatbots to serve the American public better, you might have to help craft the customer’s journeys for the chatbots. Building your chatbot will help you better understand how to script effective customer journeys.

To connect with other federal employees experimenting with or successfully working with chatbots, check out and join our some of our Communities of Practice, such as the Web Content Managers Forum, MobileGov, SocialGov, User Experience (UX), or Artificial Intelligence for Citizen Services.

Disclaimer: All references to specific products, brands, and/or companies are used only for illustrative purposes and do not imply endorsement by the U.S. federal government or any federal government agency.

Each week, The Data Briefing showcases the latest federal data news and trends. Visit this blog every week to learn how data is transforming government and improving government services for the American people. If you have ideas for a topic or have questions about government data, please contact me via email.

Dr. William Brantley is the Training Administrator for the U.S. Patent and Trademark Office’s Global Intellectual Property Academy. All opinions are his own and do not reflect the opinions of the USPTO or GSA.