How to build a network of chatbots connected to a single Dialogflow agent

Josh Barkin
Being Janis
Published in
17 min readJan 10, 2020

--

If you like this story, consider taking my Dialogflow Course.

Chatfuel or Manychat (Either tool is great) are an important piece of what I refer to as the Bot Stack, tools that when stacked together help you deliver exceptional conversational experiences for your clients:

  1. It’s easier to visualize your messaging flows. It’s harder to do that if you’re working only with Dialogflow.
  2. These tools serve as a CRM to store user data which you can extract from messages processed by Dialogflow.
  3. They make it easy to connect to other tools using Zapier or Integromat which is harder to do if you’re only working with Dialogflow and you’re not a programmer.

While neither of these tools is required to build an AI-enhanced chatbot, if don’t have developer skills, or want to make your clients active participants in building an AI Chatbot, then these tools are useful.

Training AI is an investment of time, but you can create a single Dialglow agent that will serve your entire niche. With each client you add, you’ll reduce your cost per-client and increase your profit margins.

In short, the effort you extend to one client will benefit all clients when you focus on a niche. Here some niches that could benefit from an AI-enhanced chatbot, but you would need a Dialogflow AI agent to serve each niche.

Unless you’re a large Agency and can dedicate a resource to each business vertical, then it makes more sense to focus on one vertical and maximize your penetration into that market to capture market share, while maximizing your time AI training.

Let’s say, for example, I chose to focus on the eCommerce niche because I know that there is no shortage of businesses with Shopify, WooCommerce, Amazon stores, or even Etsy. I only need to train one Dialogflow agent to serve all clients in my target niche.

The reason I only need just one Dialogflow agent is that I can reasonably assume that user input will be very similar for all my clients. Customers are going to engage with a chatbot because they are either interested in buying something, or because they need support related to something they recently purchased. Although the products will vary between the different eCommerce businesses I serve, the use-cases for a chatbot will be the exact same.

If you decide later that you want to expand your focus to other niches, then you can take your proven formula for success and adapt it to other niches, replicating your success and multiplying your revenues. There are likely a number of Dialogflow Intents you can even re-use for other niches (general customer service questions, small talk) so if you add another niche, you won’t be starting from scratch. You can simply copy intents from one Dialogflow agent to another and then further refine your Dialogflow agent for each niche.

Aggregating messages across chatbots will make all of your bots smarter, faster.

The more time you put into training AI, the more responsive chatbots connected to your single Dialogflow agent can become. You can see here that you might have multiple chatbots using the same Dialogflow agent. When one chatbot receives a message and you train your Dialogflow agent to understand and respond to that message, all chatbots using the same Dialogflow agent will benefit from that training.

Even though the messages you receive from users are similar and related to your niche and these similar messages can be added to the same Dialogflow Intent, you can have different responses that are unique to each business.

This is where bot tools Chatfuel and Manychat are particularly useful. Using one of these platforms, you can create what I call a Response Template. This is a template that you’ll install to each client’s Facebook page so that each chatbot can have its own response. In short, your one Dialogflow agent will act as a brain for multiple chatbots understanding all incoming messages, but each Chatbot (built with Manychat or Chatfuel) will be used to respond to the end-user.

A Response Template means you just have to edit the responses for each Facebook page

Step 1: The Dialogflow Template

First, you’ll want to create your Dialogflow template. This is should be a set of Dialogflow Intents and Dialogflow Entities that you will use to understand all end-users in your niche who send messages through your network of chatbots.

Using our eCommerce niche example, you can see here how I have created an Entity calledshipping-countries and I list all of the countries that my network of eCommerce chatbots will ship too. I’ll also include synonyms since there are different ways that users might express a shipping country when sending a message. If a user asks “Do you ship to the U.S.”, then the value I’ll capture and store is “United States”.

It’s the reference value that will get stored in my Chatbot CRM (In Manychat the value will automatically get stored to a Custom User Field, or in Chatfuel the value will automatically get stored as a User Attribute) and from there I can create conditions and deliver a chatbot response to the user.

I’ll also have a set of Intents that will capture common messages relating to eCommerce. When users send my network of bots a message, I’m hoping those messages will trigger one of these Dialogflow Intents.

You can name your Dialogflow Intents anything you want, but if you’re curious about my strategy for naming Dialogflow Intents as shown above, read this.

Here is a Dialogflow Intent that will capture questions about shipping costs. These are all of the things that users might say to my network of eCommerce chatbots. One Dialogflow agent will capture all of these related messages and process them for all chatbots that use the Dialogflow agent.

In the first Training Phrase below, you can see that France is annotated. I highlighted the word and selected the @shipping-countries Entity that I created. Since France is a value in my @shipping-countries Entity, I’ll store that value as a Parameter.

The Dialogflow Intent response will use a Custom Payload response. Here is what my Custom Payload would look like if I used Manychat to build my Chatbot. It’s a Flow ID which you can find in the URL of a Manychat flow in your Manychat dashboard.

If you’re building a bot with Chatfuel, then here is what your Custom Payload response would look like. It tells Dialogflow to respond with a Chatfuel block. In this case, it’s a Chatfuel block named faq.shipping.costs

It doesn’t matter if you’re working with Chatfuel or Manychat. Any message you receive will be processed by the Dialogflow Intent, and providing that the flow exists in your Manychat bot, or the block exists in your Chatfuel bot, you’ll be able to respond with your chatbot. How will Dialogflow know which chatbot will respond? Well, I’ll explain that in a minute (That’s what Janis does!), but first you’ll want to have a Response Template, where you can edit your responses for each chatbot/client/

Step 2: The Chatbot Response Template

I showed you how you can create a Dialogflow template which consists of Entities and Intents that will process the messages you receive from users. I also showed you how can tell Dialogflow to respond with a Chatfuel Block, or in the case of Manychat, a Flow (by responding with the Flow ID).

Now you’ll want to create a chatbot template to manage all of the responses to your Dialogflow Intents. In this example template response, a user triggered my Dialogflow Intent with a question about shipping. Because I had a Dialogflow Entity with a list of countries that my customers will ship to, annotated and annotated the word in my training phrases, when a user’s message triggers the Dialogflow Intent, a value I capture will automatically be saved in my chatbot tool.

In my response template, I just need to check to see if a value was saved and create a conditional response.

Each Chatbot will have its own response. For example, if a user says “How much does it cost to ship to Italy?” then a Dialogflow Intent will be triggered, and you’ll be able to extract “Italy” from that message with Dialogflow, Janis will save that value in your chatbot Response Template, and if your client ships to Italy, then your Response Template would have a condition for that.

Working with Chatfuel?

If you’re using Chatfuel for your responses, you can see how I have a number of blocks that have names that I can easily map to my Dialogflow Intent names.

You’ll want to maintain one master chatbot to manage your response blocks, and then as you add new clients and connect Chatfuel to your client’s Facebook page, you can simply copy a group of blocks from your Chatfuel Response Template to your client’s page, then simply edit the responses for your client’s bot.

You can see how you’ll tell Dialogflow which Block to respond with. The same block name can exist in hundreds of chatbots.

Working with Manychat?

You can see here a bunch of flows in a Manychat Response Template. It’s a good strategy too to name your response flows so they match your Dialogflow Intent names. There isn’t a technical reason to do this. It’s just easier to map your Intent names in Dialogflow to your response flow names in Manychat so it’s easier to manage your Intents and their responses.

The difference between Chatfuel and Manychat is that you’ll want to create a Manychat template, so that can can then install your Manychat Respone Template every time you add a new Manychat bot to a Facebook page. You can do that by clicking Templates in your left navigation.

Note that before you create a template with your response flows, make sure to clear out all of your Custom User Field and your Bot Field values.

You’ll want to click + New Template and then select the page/bot that you used to create your flows.

Select only the flows you want to include in your Response Template. Here you can see that for my eCommerce template I selected the flows which I’ll use to respond to users when they hit my Dialogflow Intents.

Manychat will automatically include Custom User Fields and tags that are referenced in your flows, but Bot Fields need to be manually selected for inclusion. While you have the option to specify if the field is a Bot Field or a Template Field I’d recommend keeping them as Bot Fields since Bot Fields are managed just below your Custom User Fields (Template fields are not).

I recommend using Bot Fields often in your Response Template. This makes it easy to manage slight variances in data between your clients. For example, chatbot end users might ask the business about their address, phone number, or website. You’ll have Flows set up that answer these questions. The structure of your response will be similar, but the actual data you communicate will likely be different for each of your clients. When you manage slight variable differences using Bot Fields, then you just need to reference the Bot Field in your response.

Then, when you install your Response Template to a Facebook page, you just need to edit the Bot Field values and each of your clients will have unique responses specific to their business.

When you create your template, you can specify if your Bot Fields should Prefill with the current value and selecting this option will include whatever values you have saved in your Bot Fields at the time you create your template.

Some Bot Field values might be private to your Agency such as a Janis Key, so you may not want to pre-fill the template with the current value because that will use the same Janis Key for every bot, and you won’t want to do that.

When you install the template and edit the Bot Field values for your client, you can then add in a unique API key for your client so you can track and monitor each of your client’s bots separately.

When you save your Manychat template, Manychat will give you a link. You’ll want to copy and store this link somewhere. This is what you’ll click when you want to install a Manychat response template to your client’s Facebook page.

It’s important to note that you’ll only want to install your Manychat Response template ONCE per page.

Manychat creates a unique Flow ID for each response flow you create, and the Flow ID is maintained when you install the template to your page. If you try and install the same template to the same page, then Manychat will create a unique Flow ID for subsequent installs! This will break things as your Dialogflow agent won’t reference the flows that were added to the Dialogflow Response,

Create Template Updates Instead

There is a good chance you’re going to want to add Dialogflow Intents and therefore you’re going to need additional Response Flows in Manychat. A good strategy is to create additional templates and add them as updates to your client bots. You’ll create your new Dialogflow Intents and those will have new responses flows, then package up those response flows into new templates.

You can create new Response Flow templates that ONLY contain the new flows which correspond to your new Dialogflow intents. Just give your new Response Flow templates unique names. If you have multiple clients, just maintain a Google Sheet with a list of each bot and the templates that have been installed for each bot. That way you’ll know which bot needs to be updated and which ones have already been updated.

Connecting one Dialogflow agent to your network of Chatbots

Now that you have a system for managing ONE Dialogflow agent that will serve multiple clients in your niche, and one or more response templates which you’ll use for each chatbot, you’ll need to connect your Dialogflow agent to your network of bots and you can use Janis for that!

Every time you onboard a new customer with your Agency, you’ll want to register your client’s bot with Janis. This so that Janis can generate a unique key for your client’s bot, and so you’ll be able to manage your client’s bot. You’ll be able to get notifications from Janis for the specific bot and you’ll be able to take over live for the specific Chatbot. Even though each bot has a unique Janis Key, all bots will use the same Dialogflow agent.

You can say Add a bot to Janis and then simply select your single Dialogflow agent.

Janis will know if the Dialogflow agent has already been used before for another Chatbot, so when Janis asks if you want to use the same agent but for a new bot, say (or click) New bot.

Then follow the steps to get a Janis key for your client’s chatbot, and add that Janis Key to your Client’s chatbot in your bot maker tool. Now you’ll have individual chatbots registered with Janis. Each will have their own responses, but each will use the same Dialogflow agent.

Empowering Clients To Help Train Dialogflow

So now you have a one Dialogflow agent serving a portfolio of Chatbots connected to Facebook. You’ll likely not want your client to ever log into Dialogflow. It’s going to be too sophisticated for your clients. Besides, Dialogflow is YOUR tool as a Bot Maker. However, it’s your client’s customer experience and you’ll want to make them active participants in helping to train AI to respond to their customers.

You could use a simple FAQ to train Dialogflow

The easiest thing to do is to ask your client to provide you with a simple FAQ. Chances are your client already has a FAQ on their website, so you could either start with their FAQ for your Dialogflow Intents, or update your existing Intents using simply referring to their FAQ and add to your training phrases.

You could use a simple Google Sheet to help train Dialogflow

You could easily add your Intent names to a Google Sheet and then ask the client to input what users say and their desired responses. You can see here I just have one worksheet and either you, or the client can add the Intent name, then just sort your Google Sheet by Intent name and everything will be grouped together.

You could then copy each thing that a user says into your Dialogflow training phrases, and manage your client’s responses by editing the Chatbot Response template you installed to their page.

You could set up a Slack workspace for training Dialogflow

Slack isn’t required to train AI, but because Slack was built for collaboration, Janis added two ways to train Dialogflow from Slack. It’s a good idea to set up a separate Slack workspace for you and your client. You just need to add Janis to the workspace, and then you have a couple of different option to collaborate with your client. See this article on all of the different ways to collaborate with your clients in Slack:

You don’t have to use all of the collaboration tools extended by Janis into Slack. There is a simple Dialogflow training tool Janis provides where your client can simply say Train to Janis in Slack and if a bot has been connected to the workspace, or linked to the workspace (those are two different things — see the article above ^) then Janis will create a training channel. Your client just needs to type messages into Slack representing things users say, and then you, or your client can add those to Intents. Janis will automatically save the messages your clients input in Slack directly to your Dialogflow agent.

Keep in mind that if you have multiple clients training this way, you’ll need to constantly review the Dialogflow Intents and also use Dialogflow’s validation tool which will find conflicts.

Conflicts might include duplicate training phrases in one Intent, or duplicate training phrases used in more than Intent, which means Dialogflow won’t know which Intent to trigger if the same training phrases are used in different Intents (and you’re not distinguishing your Intents using Dialogflow context).

Empowering Clients To Add Responses

You might add new Intents for your Dialogflow agent and create new Response Templates for those Intents too. You can give your clients more control over their automated responses with Botsheets. It’s a simple product that offers a number of Google Sheet templates for different niches where your clients can simply input content into Google Sheet cells and the content is dynamically output in Facebook Messenger through the Chatbot you built for them. This means that you don’t have to give your clients access to your Chatbot maker tool which protects you and you’ll protect your client relationship too because your client doesn’t have to learn how to build a Chatbot. They simply enter text into cells and boom, it works like magic! You just have to set up a dynamic request from your chatbot to retrieve content from the Google Sheet template and your clients just need to manage the Google Sheet like a database (but without needing database skills). The cells automatically change color indicating which information your client needs to provide and where and their bot can generate dynamic galleries for real estate listings, menus, products, promo codes, events, and much more.

So how does that even relate to Dialogflow? Well, you’ve been training your Dialogflow agent to understand the messages you receive and you’re going to create a chatbot Response Template with your bot maker tool. You connect the Google Sheet templates to your chatbot tool, then you can use Dialogflow to extract values out of messages, save the values in your chatbot tool and then use the values to search a Google Sheet.

In short, you can use AI to understand an end-user and the bot can dynamically respond with content managed by your client in Google Sheets.

Scaling for the future

The future of conversational AI will undoubtedly be led by companies like Google (Dialogflow), Microsoft, IBM, Facebook, and Amazon. None of these companies want to lose the AI race, the most transformative phase of the computing revolution. So, when you train with Dialogflow, one of the leading sources of AI, you’re building a conversational foundation for the future. You may be using Chatfuel or Manychat for Facebook marketing, but as Janis continues to grow we’ll add other channels that can’t be powered by these tools. Channels like Google Assistant and Alexa are all voice-activated experiences that are powered by Dialogflow. An end-user, for example, might ask Alexa to make a reservation at your client’s restaurant. Because you’ve trained Dialogflow to accept this type of user input you’ll be able to complete the reservation for the user. If another customer asks to make a reservation through your Facebook bot, you’ll be able to use the same Dialogflow to understand the user and fulfill that request with your Messenger chatbot.

Best of all, with Janis as your AI manager, you’ll be able to manage all of your conversational experiences for all of your customers through one platform.

Need a template?

If you like this story, consider taking my Dialogflow Course. It includes a Dialogflow template.

More resources you’ll find useful

--

--

Josh Barkin
Being Janis

Building conversational AI platforms since 2016