Building a Chatbot with Dialogflow and Slack

Chatbots come in many different styles and most chatbot solutions use directed questions and answers to guide visitors down a specific path.  Our chatbot is different in that we've integrated our Live Chat platform with Dialogflow and Slack in order to leverage natural language processing.  

Our implementation allows you to create dynamic chatbots on Social Intents that you can train to answer just about any questions your visitors may have.  Best of all, it requires no coding, and no expensive upgrades in our solution.

Here's a step by step guide to creating your first chatbot with Social Intents, Slack, and Dialogflow.

Prerequisites

High Level Steps

In this tutorial we're going to walk through the steps of adding chatbot functionality to your live chat that you can deploy on your website today.  Here are the steps:

  1. Add our Live Chat app to your Slack Account
  2. Generate your Dialogflow Private Key for Authentication
  3. Add your Dialogflow Key to Social Intents
  4. Test out your new Live Chat app with chatbot capabilities!

1. Add our Live Chat app to your Slack Account

If you don't already have a Slack account, you can sign up for free here: https://slack.com

First, add our Live Chat app to your Slack account.  Simply head over to our Live Chat for Slack page and select Add to Slack.  This will add our app to your Slack workspace.

You'll be asked to select an inbound channel for live chat invites.  This is where we'll send new live chat requests. 

After selecting your channel, you're all set.  You can copy and paste this code snippet into your website in order to enable live chat on your own site.  You can also install this code snippet later.

2.  Generate your Dialogflow Authentication Keys

Next, head over to https://www.dialogflow.com and login with your Google account.  Dialogflow is a natural language processing solution that uses Agents and Intents to respond to questions.  It supports many different messaging and voice platforms so you can create a single agent for your live chat and your other channels.

In this tutorial we'll create a test Agent that you'll integrate with Slack.  After logging in, just select the Create Agent button as in the screen below.

Your new agent will have 2 default intents.  These will be enough to get started and respond with generic welcome messages.  As you get more familiar with Dialogflow, you can create multiple Intents and Contexts to answer questions, gather answer data, and respond with Cards, Images, and Buttons.

Here are some sample phrases that our new chatbot will respond to in your live chat.

Our chatbot supports all response types from Dialogflow.  So if you want to respond with Cards, Images, Suggestions, or more in Dialogflow you can create a Slack, Google Assistant, or Telegram response type and we'll use these as well as the Text responses when responding to questions.  

Set up Dialogflow Authentication Key for Integration

Next, set up your authentication details and generate a Dialogflow Service Account Key you will use to integrate with your chat widget.  

If you click on the settings icon next to your new agent, you'll see the screen below.  Click on the link to your Service Account highlighted below.

Click on the Service account as below or you can create a new one:

Once you're on your Service account details page, click the Edit icon at the top of the page to put you in edit mode.  Then select 'Create Key' to generate your Private Key JSON file that will be used for our integration.

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

You'll now upload this private's Key to your chat widget Chatbot page to enable our Social Intents integration with Dialogflow.

3. Add your Dialogflow Key to Social Intents

Now that you have created 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.  You can create a new widget if you don't have a Live Chat app yet created.

From the chat settings page, select the Chat bot 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 when the chatbot is

4.  That's it!  You're ready to test your new chatbot

You're now all configured and ready to test your chatbot.  Simply login to our website, select your Live Chat app and choose Preview.  If you've already added the code snippet to your website, you can chat right there