In our previous posts, we presented simple and effective guides for integrating a Dialogflow bot on a website and on Android. In this article, we’ll be sharing steps that show how to build an iOS chatbot with Dialogflow. All you need to build a sample chatbot using Dialogflow and Kommunicate for an iOS app.
Below is an example of the Kommunicate Support Bot developed on iOS using Dialogflow. You can check out the functionality of the Kommunicate Support bot here:
Kommunicate supports both Swift and Objective C in our iOS SDK, and we’ve made it very easy to add the SDK using CocoaPods.
The actionable, rich messaging bot can reply based on whether users are on chat for general queries, technical queries, or simply checking out or scheduling a demo.
Let’s now jump into the crux of this post—building the bot itself!
Step by Step Guide to Building iOS Chatbot with Dialogflow
Step 1: Setup an account in Kommunicate
It’s really simple to get started with a free account on Kommunicate. Sign up and navigate to the Bot section. Click on Settings in the Dialogflow block.
Upload your Dialogflow provided client keys. In case you’re using Dialogflow V1, you can copy paste your client and dev tokens. However, we do recommend using Dialogflow V2 for the latest capabilities.
To complete the setup, click Next and set up your Bot Profile. You can check your newly created bot in two places:
- Dashboard →Bot Integration → Integrated Bots: You can check all your integrated bots here.
- Dashboard → Bot Integration: Your Dialogflow icon should be green with the number of bots are you have successfully integrated.
Step 2: Install Dialogflow integrated iOS Chatbot SDK into your app
In this step, you’ll need to add the Kommunicate iOS SDK to your app, which comes with a pre-configured Dialogflow integration. Follow the instructions below to add the iOS SDK into your app:
Kommunicate is available through CocoaPods. To install it, simply add the following line to your Podfile:
This is how the pod file looks once installed:
Run pod install in your project terminal folder:
After finishing the installation, you can initialize the SDK by calling the method below.
Set up the App id
You can obtain your unique Application ID in the Installation Section. If in any file you’d like to use Kommunicate, don’t forget to import the framework with import Kommunicate
Step 3: Send and receive Information
Now you can send the payload data to Dialogflow through the chat screen and get a text response from the Dialogflow Agent. Kommunicate provides a ready-to-use Chat UI, so all you need to do is launch the chat screen for this step:
Run the iOS project and chat with the Dialogflow bot. You can easily integrate Dialogflow in iOS apps in a few simple steps. In case you need more information, you can check out the Kommunicate iOS documentation.
Here are some sample chat screens of the iOS app with the Dialogflow and Kommunicate integration:
Are you considering chatbots for your business? Download the Complete Beginner’s Guide to Chatbots for a more detailed explanation on chatbots’ capabilities, industry use-cases, and a step-by-step guide on how to build one.
Dialogflow iOS SDK Client
Dialogflow provides an iOS Client SDK that makes it easy to integrate speech recognition with API.ai’s natural language processing API on Apple devices.
If you’re looking to develop your own chat implementation, you can directly integrate Dialogflow into your iOS app without Kommunicate SDK, using the following SDK from GitHub: