How to Create a WordPress Chatbot with Dialogflow

Chatbots have become an increasingly popular tool for businesses to interact with their customers. They offer a convenient and efficient way to answer frequently asked questions, resolve customer issues, and provide information about products and services.

One of the most popular platforms for creating chatbots is Dialogflow, a Google-owned platform that allows you to build conversational interfaces for websites, mobile apps, and messaging platforms. In this article, we’ll show you how to create a chatbot for your WordPress website using Dialogflow and integrate it with social media intents.

Why Use Dialogflow for Your WordPress Chatbot?

Dialogflow is a powerful and user-friendly platform for creating chatbots. It offers a range of features that make it an ideal choice for businesses looking to build conversational interfaces, including:

  • Natural language processing: Dialogflow uses Google’s machine learning technology to understand and interpret user requests, even when they’re phrased in a conversational or informal way.
  • Easy integration: Dialogflow can be integrated with a variety of platforms and messaging apps, making it easy to create chatbots that work across multiple channels.
  • Customizable intents: Dialogflow allows you to create custom intents that match the specific needs of your business, making it easy to create chatbots that respond to specific questions or requests.
  • Social media integration: Dialogflow has a range of built-in social media intents, such as the ability to share links on social media, post status updates, and more.

How to Create a Chatbot with Dialogflow

To create a chatbot with Dialogflow, you’ll need to complete the following steps:

  1. Create a Dialogflow account: The first step is to create a Dialogflow account and log in to the platform. You can sign up for a free account or opt for a paid account with additional features.
  2. Create a new agent: Once you’re logged in, click the “Create Agent” button to create a new chatbot. Give your chatbot a name and select the language and time zone you want to use.
  3. Define intents: Intents are the core of your chatbot, and they define what your chatbot will do when it receives a request from a user. To create a new intent, click the “Intents” tab and select the “Create Intent” button. Give your intent a name and add a few example phrases that users might say to trigger the intent.
  4. Add responses: Once you’ve created an intent, you’ll need to add responses for your chatbot to send back to the user. You can add a variety of responses, including text, images, and links. You can also use variables to personalize the responses and make them more relevant to the user.
  5. Test your chatbot: Before you integrate your chatbot into your WordPress website, it’s important to test it to make sure it’s working as expected. You can test your chatbot by typing in different requests in the Dialogflow console or by using the built-in chatbot testing interface.

Integrating Your Dialogflow Chatbot with WordPress

Once you’ve created your chatbot in Dialogflow, you’ll need to integrate it with your WordPress website. 

To do this, you’ll need to use our Live Chat plugin on WordPress.  

Adding Live Chat to WordPress

Our Live Chat plugin has the benefit of natively integrating with the messaging apps you already use in your company - Microsoft Teams, Webex, and Slack.  So if you use either of these at your company, this is the perfect solution so that you don't need to learn another app and keep focused on the collaboration tools you already use.  You won't have to switch between your internal corporate collaboration tools and your external live chat with our WordPress plugin.

To get started, first go to our website at https://www.socialintents.com and click either 'Add to Slack' or 'Add to Microsoft Teams'.

Now that you've set up an account in Social Intents for WordPress for either Slack or Teams, you'll want to grab your WordPress API key which you will copy into the WordPress plugin settings.  We'll go through the details of finding your WordPress Plugin API key for Microsoft Teams, Webex, and Slack users below.

You can find your code snippet under your Chat Settings.  Click on the Live Chat app in the let sidebar (or add it if you haven't yet to your team), and then go to your Live Chat settings.  Click on the Install Code Snippet tab in the settings to find the key:

WordPress Microsoft Teams

For Slack and Webex Live Chat Users

If you are a Live Chat for Slack or Web Chat user, login to your Social Intents account and click on the Install Code Snippet Link in the lefthand navigation:

WordPress Plugin Dashboard

You'll see a popup that will display your WordPress API Key:

WordPress API KeySave this API key for use in the next step below.

Adding Live Chat plugin WordPress

Next we will add the Live Chat plugin to WordPress.  Go to your WordPress admin site and then to the Plugin link.  Click on the Add New button to add a plugin.

WordPress Plugin Settings

Now, search for the plugin named: 'Live Chat for Microsoft Teams and Slack', then click 'Install Now'

Once installed, click on 'Settings' in the Plugin

Now you'll see a text field called Your app key.  This is where you will put the API Key that you retrieved in the Your WordPress API key section above.

Copy this key in then slick 'Save Settings'.

WordPress Api Key Setting

Integrate Dialogflow with Live Chat

Now that you have Live Chat deployed into WordPress and your Dialogflow Agent set up, the last step is to integrate Social Intents Live Chat with Dialogflow.  Set up your authentication details and generate a Dialogflow Service Account Key that you'll use to integrate with your chat widget in Social Intents.    

If you click on the Settings Gear icon next to your agent name, you'll see the screen below.  Click on the link to your Project ID highlighted below.

Then click on 'Go to project settings':

Select 'Create Service Account':

Now, name your service account and select 'Create':

Under Step 2, assign a role of Dialogflow --> Dialogflow API Client to your service account:

Click 'Continue', then click 'Done'

At this point,  you should see an item similar to the following under your Service Accounts liar.  Notice you haven't created any keys yet:

The final step here is to create your JSON Key.  Click on your new service account, then select ADD KEY to generate your Private Key JSON file that will be used for our integration:

Choose JSON as your Key type and click Create.  This will download your private key to your computer.

Whew, all set!  You'll now upload this private key to your chat widget Chatbot page to enable our Social Intents integration with Dialogflow.

Complete your WordPress and Dialogflow Integration: Add your Dialogflow Key to Social Intents

Now that you have create a Live Chat app and your new Dialogflow agent and key file, connect your Social Intents account to Dialogflow by logging into Social Intents, selecting My Apps from the left navigation bar, then Edit Settings on your Live Chat widget.  

From the chat settings page, select the Chat Bots tab at the top of the page.

Select the Chatbot name that visitors will see when your chatbot responds, select the language you've used in creating your Agent in Dialogflow, and choose your Chatbot type.

Lastly, upload the .JSON Key file that you downloaded in the previous step by Choosing the File and clicking the 'Upload Dialogflow Private Key' button.  This tells our app how to connect to the Dialogflow agent for answering your visitor questions in your chatbot.

That's it!  Your Dialogflow Chatbot is now enabled in WordPress

You're now all configured and your Dialogflow website chatbot is deployed on your WordPress website.