As someone who has been working with rich website chatbots using Dialogflow for over a year, I have identified 5 ways you can integrate a Dialogflow chatbot into your website. But before I go further, here are a few things you should know:
Integrate Dialogflow with Drift (or Intercom)
If you use live chat software such as Drift or Intercom, they usually provide an API which allows you to integrate your Dialogflow chatbot with their service.
For example, I have a (very basic) Dialogflow chatbot integrated into the Drift chat window you see on the bottom right of every page on this site. Go ahead and try it!
Generally speaking, this is how it works: you will specify something called a webhook - basically someplace where your code runs. You will add the URL for the webhook inside your Drift settings.
Every time a visitor sends a message via the chat window, Drift will send a notification to this webhook code. Your webhook code will relay the user's message to Dialogflow, get the response from Dialogflow, and relay the response back to the Drift chat window. Without getting too deep into the technicals, the overall point I am making is that this is possible although quite complex.
In return for creating this complex integration, you get the best of both worlds - a live chat to talk to your users + a bot to help your users when you are away. And on top of that, you also get all the excellent features already provided by Drift (and Intercom).
Create a WordPress Plugin
Naturally, this option only makes sense for WordPress powered websites. But since WordPress powers nearly 30% of the web, that still means about 1 in 3 of you will be able to use this option.
Now you might not be interested in creating your own WordPress plugin. If possible, you would probably want to simply take an existing off-the-shelf plugin and just install it on your website.
At the moment, there is no WordPress plugin for Dialogflow which supports the second version of their API (v2). Since the previous version v1 is being deprecated by October 2019, there is very little benefit to getting and installing a plugin which only works with API v1.
If you were to build your own plugin, you actually get the best of many worlds.
- Since it is your own code, you can modify and extend it as you wish rather than wait for the plugin developer to add new functionality
- WordPress plugin ecosystem is huge, so it isn't very hard to find competent WordPress plugin developers
- There is an integrated user management system already included in WordPress, and you can just use it for authentication if you decide to build an analytics dashboard for your bot
- For use cases such as WooCommerce shopping assistant bots, this option probably gives you the smoothest integration. Note: I am hardly a WooCommerce expert, and I am basing this off my knowledge of how the WordPress ecosystem works.
Use a Hosted Service
There are services like Kommunicate.io which allows you to embed a chatbot into your website. Since it is a completely hosted service, there is very little maintenance work required on your part.
With the migration to API v2, you probably need a developer to help with the integration. But still, this is probably the easiest option for someone who wants to be completely hands off.
Not surprisingly, this is the option which gives you the least amount of control. You are also somewhat dependent on a third party service not going down, so that is another factor to consider.
Personally, I haven't used it and so I cannot recommend it.
Custom middleware running on the same site
If you use a server-side language such as PHP, Python or Ruby for your website, you can add some middleware code to create the integration.
An important advantage of this approach is that since you already have someone developing and maintaining the existing website, you can take advantage of their existing knowledge (of your systems and processes) and just ask them to also create this custom middleware code.
This is how I built the demo bot on my website.
I recently discovered an intriguing option, but haven't fully tested it out - use Firebase for hosting the middleware.
(By the way, this option talks about hosting the middleware code someplace different from where your website is hosted. You can put up the code on just about any cloud host, and if you choose that option, Firebase seems to be the best choice).
If you haven't heard of Firebase - it is basically a suite of technologies created by Google which serves a lot of different purposes. One of them is to run your code on their cloud - using Firebase Cloud Functions.
Using Firebase Cloud Functions promises a lot of benefits:
- Simple authentication for your middleware code
- A quick, simple way to store your conversation logs
- A simple way to integrate with Chatbase, which is like Google Analytics for chatbots
Since Firebase Cloud Functions do have something of a learning curve, and you also need to have some reasonable amount of knowledge about how the Google cloud works, this option is probably best suited for you if you already have some in-house expertise around these technologies.
Do you need some help choosing the best option for your website? Get in touch.