Chat app for Android made with Kotlin and Pusher that integrates a chatbot build with Dialogflow. Follow the tutorial here.
- Clone this repository.
- Create a Pusher app.
- Enter your Pusher app information in
server/src/main/kotlin/com/pusher/chatbotapi/MessageController.kt
and inandroid/app/src/main/java/com/pusher/chatbot/ChatActivity.kt
. - Create a Dialogflow agent and configure it either by following the steps of the tutorial or importing the zip file
TriviaBot.zip
in the root of this repo using the option Export and Import in the Settings page of your agent. - In the General section of the Settings page, copy the Project ID and enter it in the class
server/src/main/kotlin/com/pusher/chatbotapi/MessageController.kt
. - Go to your Google Cloud Platform console, choose the project created for your Dialogflow agent, create a new Service account key in the APIs & Services>Credentials section as a JSON file and download the file to a directory outside this project.
- Configure the environment variable
GOOGLE_APPLICATION_CREDENTIALS
and set as its value the location of the JSON file that contains the private key you created in the previous step. - In a terminal window, go to the
server
directory and executegradlew bootRun
to start the server. - In a terminal window in that directory and execute
ngrok http localhost:8080
to expose your local server to the world. - Copy the HTTPS forwarding URL, something like https://5a4f24b2.ngrok.io.
- In your Dialogflow console, click on the Fulfillment option, enable the Webhook option, and add the URL you just copied from ngrok appending the path of the webhook endpoint (
webhook
). - Open the app with Android Studio.
- Build the project and run it on two emulator.
- Choose an username and start sending messages
- Android Studio 3.1.4
- MinSdkVersion: 15
- TargetSdkVersion: 27
- buildToolsVersion: 27.1.1
- Pusher account
- Dialogflow (Google) account
- ngrok
- Pusher - APIs to enable devs building realtime features
- Dialogflow A Google-owned developer of human–computer interaction technologies based on natural language conversations
- Thanks to Pusher for sponsoring this tutorial.
MIT