Back to Blog

Dialogflow Architecture and Purpose

In communicating with clients, I've concluded that most people misunderstand Dialogflow's architecture. This is especially true for those who have already dealt with ManyChat and similar chatbot builders. I decided to write a small article about Dialogflow architecture with a focus on human-agent interaction.

In my opinion, there are 4 points that need to be understood to get a proper understanding of Dialogflow architecture.

1. Request-Response

At the core of Dialogflow is the user request and its processing.

  1. The user sends a request to the Dialogflow agent.
  2. Natural language processing module is enabled.
  3. Dialogflow sends a response to the user.
Blog post image

Why is this important?

Very often, chatbots are equated with mailing services, and the whole essence of automation comes down to "bombarding" the user with messages on schedule. The "request first, then response" paradigm makes it clear that mailing is not supported in Dialogflow, and the only way to send a message to a user outside of dialogue is to use the API.

For this you will need:

  • knowledge of the API of the messenger with which Dialogflow is integrated
  • a server where the program code for working with the API will be hosted

Difficult? If you need mailings, it's better to pass by Dialogflow. In ManyChat or Smart Sender implementing and maintaining a mailing (editing content, managing schedule and chains) is very convenient.

2. Intent Mapping

The second concept that needs to be understood is how intents work.

As soon as your Dialogflow agent receives a user request, it will try to match it with a list of predefined intents. Intents are created by the bot developer as a way to tell Dialogflow: "Here's a list of tasks that the user might ask to perform."

To understand how intent matching really works, you need to study key features like entities, contexts, parameters, and more. I recommend watching videos on my YouTube channel.

After Dialogflow matches the user's request with one of the predefined intents, it will send a response (which is also predefined by the bot developer) back to the user.

3. Fulfillment

Once Dialogflow matches the user's request with one of the predefined intents, it may need to perform some business logic before sending a response.

This is where the concept called Fulfillment comes in.

Here's how it works:

  1. Dialogflow recognizes the user's request and gets structured information.
  2. The structured information is sent to some program code running on a separate hosting maintained by the bot developer. This code is called a webhook.
  3. The webhook performs the necessary business logic.
  4. Returns a response to your Dialogflow agent in a specific format.
  5. Dialogflow analyzes the data, extracts relevant information, and forms a response that is sent to the user.

4. Integration

In addition to the concepts listed above, Dialogflow provides its own API.

This API allows programmatically sending requests to your Dialogflow agents. The request will be matched with an intent, and the corresponding response will be sent to the party that accessed the Dialogflow API.

This means you can "embed" a Dialogflow agent into your existing applications and services. This can be anything. From a website to a mobile app or computer game.

Conclusion

It's important to remember that Dialogflow's task is to replace a live person in communication. If you chose Dialogflow to create a bot, try to avoid complex branched dialogue chains. Build the bot's work so that the user can get the desired result with one or two touches.

But if you can't do without business logic, I want to give a few tips.

  1. In Dialogflow there is such a thing as an "Event". With its help, you can redirect the user to one intent or another depending on their (user's) actions. This will greatly facilitate the task.
  2. If your business logic is quite simple, the request handler code can be placed inside the Dialogflow agent using the Inline editor. In this case, you don't need a separate hosting and technical knowledge for setup. All this is done automatically in the Google Cloud service.

Start with something very simple, like a FAQ bot. Make a list of the most common questions users ask you, write out the answers, and compose intents according to this scheme. And then improve the robot's structure, build up functionality, and master the integration of Dialogflow with other services.

If you have questions - write them in the comments below the article or to me on Telegram and don't forget to subscribe to the YouTube channel so that I have an incentive to record new educational videos.