It is a well-known fact that today’s world is thriving with data. With so many sources of data readily available like social media platforms, be it YouTube, Facebook, or Twitter, terms like ‘Data Analysis’, ‘Machine Learning’, and ‘Artificial Intelligence’ are seen to be prevailing. The question is “Is it necessary to understand these terms and Natural Language Processing (commonly known as NLP) completely to build a chatbot?” and a simple answer to this question is “NO”. This has become possible with the help of Dialogflow.

In this series of posts, we will discuss all Dialogflow and how to create a chatbot using it.

What is Natural Language Processing (NLP)?

Here we will just discuss the tip of the iceberg named Natural Language Processing to get a gist of what Dialogflow does. Natural Language (example- English) is the language that we humans communicate with. On the other hand, programming language (for example- Python) is developed to give commands to computers. Natural Language Processing makes it possible for humans and computers to interact without the use of programming languages so that computers can comprehend written or verbal inputs from us. As a result, to imitate the way humans communicate, NLP models are developed. Natural languages are quite difficult to interpret correctly all the time because of grammar, idioms, context, homophones etcetera. So, a good NLP model should be able to interpret the sarcastic tone in a tweet saying “My flight is delayed. Great!” Some of the many uses of NLP in real life:

  • Spam detection– The emails in our inbox are classified as spam because of the detection of language which suggests spamming or phishing. For instance, bad grammar and threatening language are some factors used to perform the classification.
  • Social media sentiment analysis– Posts on social networking sites such as Twitter can be scanned to get a hold of the reaction of people with respect to any product or event. This information can prove to be quite useful for marketing campaigns.
  • Virtual agents and chatbots– Virtual agents like Siri, Alexa and chatbots, which are now frequently noticed on many websites, are used to provide appropriate and helpful outputs such as text or actions, whichever is suitable, after examining the input from the end-user.

Unfortunately enough, it is not possible to develop a natural language processing chatbot without using coding. Having said that, there are some user-friendly tools to help simplify the process. Well, where there is a will, there is a chatbot.

What are chatbots?

Thanks to customers’ demand for assistance round-the-clock, the use of chatbots is skyrocketing. To enable customer engagement with the means of text, speech, images etcetera, and that too at any time of the day, artificial intelligence systems called chatbots are used. Insider Intelligence reveals that 40% of internet users prefer dealing with chatbots rather than agents. Moreover, in quite a literal sense, every industry ranging from medical to retail and finance is rapidly shifting to the digital market and chatbots have become a necessity for this very reason. Some well-known chatbots are eBay ShopBot and Lyft Bot.

  • Chatbots answer questions and queries. As an example, “What is the cost of the hair dryer?” or “What are the working hours of your company?”
  • Book seats for events.
  • Give personalized recommendations by analyzing customer’s replies.
  • Collect customer feedback.
  • For inventory management, such as looking for particular items in the inventory.
  • Integrating with ERP apps to get to know about enterprise resource availability.
  • A bot giving illustrations to build another bot.
  • A personalized travel assistant to help with tasks such as booking hotels with respect to end-users travel plans and comfort and so on.

What is Dialogflow?

Dialogflow (formerly Api.ai, Speaktoit) is now owned by Google. It is basically a framework that provides “Natural Language Processing” and “Natural Language Understanding” facilities. In other words, based on Natural Language conversations, Dialogflow builds human-computer interaction services. On top of it, this framework provides many functionalities like webbook services and integration services which make Dialogflow quite a good place to develop a chatbot.

According to Google Cloud:

Dialogflow is a natural language understanding platform used to design and integrate a conversational user interface into mobile apps, web applications, devices, bots, interactive voice response systems and related uses.”

Terminologies related to Dialogflow

Firstly, we should discuss an introduction to the terminologies that will be used throughout this blog. Below is a snapshot of a part of the Dialogflow console which displays some of the essentials of Dialogflow.

Figure 4: Dialogflow Essentials
  • Agent: A Dialogflow agent is quite similar to a human agent. First, it needs training. This training is specifically to handle human interactions which are, in a way, expected. Here, the agent’s name is ‘democrat’. Going further in this blog, we will learn all about creating agents and using them to create chatbots.
  • Intent: The relationship of intent to the agent is many to one. In other words, one agent has multiple intents. According to the input by the user, a particular intent is matched, and this process is known as intent classification. Each intent has training phases, actions, parameters and responses.
  • Training phases are some of the phrases which are predicted beforehand and given to the machine. One point to note here is that there is absolutely no need to add ALL the phrases. You can add some of the phrases and the built-in machine-learning of Dialogflow envisions other phrases. In simpler words, if a user is expected to enter some numbers (example- customer id) then training phrases would be some numbers.
  • Action is used to link the matched intent with some specific actions. In the following snapshot, the action is ‘get_name’.
  • Values from the input from the user are obtained by Parameters. Continuing the above example, if the expected expression from users is a number, the entity type would be identified as ‘sys. the number’. ‘sys’ suggests that it is a system-built entity and not a user-defined one. To access this value by user, ‘$name’ will be required use.
Figure 5: Training phases, action and parameters
  • Response, as the name suggests, is text, image or any other response which are to be returned to the user. The ‘Custom Payload’ field is used to pass rich content to the user. Examples of rich content include image responses, suggestion chips and so on.
Figure 6: Responses
  • Entities: As discussed earlier, some common sort of data like numbers, date, time, etcetera can be identified by the system itself, known as system entities. We can also define our own entities known as custom entities. For example, an entity named drink can be created with the names of all the drinks like tea and coffee. In this way, when a user enters some expression along with the name of some drink, the entity type would be identified as ‘drink’. Furthermore, this same value could be used to give out a response or else perform an action, etcetera.
Figure 7: Custom entity
Figure 8: Detection of custom entity
  • Fulfilment: Whenever a developer wishes to give dynamic responses, fulfilment comes into play. What I mean by dynamic responses is, for instance, if the user wishes to extract the name of a customer from the database by using the customer id provided beforehand, then fulfilment needs to be enabled for that individual intent.
  • Integrations: Dialogflow provides integration with a number of platforms. This can be used to create an agent on those platforms. Some examples of built-in integrations of Dialogflow are Dialogflow messenger (which we will be using), Dialogflow web demo, LINE, Slack, Telegram, etcetera along with some partner built-in telephony integrations, Google-contributed open-source integrations and independent integrations.

Do let me know if you think any other integration than Dialogflow messenger would be better to work with.

Conclusion

Today what we discussed was just the beginning or should I say just a trailer video of this amazing movie named Dialogflow. Although I hope that you understood today’s topics, do not feel overwhelmed at all if you didn’t understand some portions. Going further, we are going to get into the depth of all the terminologies and the features of Dialogflow and implement the same to develop a chatbot. The uses of chatbots truly amaze me! Do comment about any innovative or unique chatbots that you have interacted with or heard of that have amazed you.

I am open to any suggestions or feedback related to this post. Thank you.

References