Setting up a smart chatbot on discourse 🤖


(Timothy Vail) #1

Hello,

After weeks of tinkering, I finally managed to set up an AI bot, similar to discobot but one that learns and is more responsive. Here is how I did it for anyone interested in setting it up. There is quite a few steps, but once you get it all set up, the result is amazing.

  1. Install the hubot plugin for discourse Hubot Adapter for Discourse, to install hubot on your discourse, the hubot variables like HUBOT_DISCOURSE_USERNAME are entered into (yourhubotfolder)/bin/hubot file, just nano or edit it to write export HUBOT_DISCOURSE_USERNAME=mybot) For more details go here Discobot for training

  2. Sign up and make a new bot on https://dialogflow.com/

  3. Install a hubot / apiai (dialogueflow) adapter from here: GitHub - ojacques/hubot-apiai: Add smartness and conversational UX to Hubot with API.AI as back-end 3a. in the bin/hubot file, make sure you have the following variables set

    export HUBOT_DISCOURSE_USERNAME=(bot’s username, don’t do discobot)
    export HUBOT_DISCOURSE_KEY=(your bot-user’s api key, not the site api)
    export HUBOT_DISCOURSE_SERVER=(discourse url)
    export API_AI_CLIENT_ACCESS_TOKEN=(dialogflow bot server api, found in the settings)
    export GOOGLE_APPLICATION_CREDENTIALS=(yourjson).json
    export DIALOGFLOW_PROJECT_ID=(nameoftheproject)

You will have to download a google application credential json, which you can get following this guide: Downloading Credentials for API Access  |  Cloud Genomics  |  Google Cloud Platform

  1. Now boot up your hubot by typing bin/hubot -a discourse-adapter to run it. If you want it to run even when you are not in the terminal, type nohup bin/hubot -a discourse-adapter &

  2. Private message the bot for testing. If you set up the dialogflow bot with small talk, you can say hi, how are you and engage in small talk right away. Other dialogue you have to set up. There are a few tutorials on youtube that are a good start. https://youtu.be/HqfN9qjNj9A

Here is a demo

If you have any questions, feel free to ask.

Also, a proper thank you to @codinghorror and the team for developing discourse, and @awole20 for developing the hubot plugin, couldn’t have done it without you!


(William) #2

This is just plain awesome! I am not too experienced with this myself, but do you know if this would work to deploy on Heroku or not? Thanks for the tutorial!


(Jeff Wong) #3

Hubot is indeed able to be installed on Heroku - check out the Hubot docs for more info: Deploying to Heroku | HUBOT


(William) #4

That’s cool. I’ll look further into this.


(William) #5

@awole20 @Timothy_Vail I know I sound absolutely hilarious by saying this, but is there any way to make a bot that you guys know of without being an admin (a.k.a having an api key)?


(Timothy Vail) #6

You need to be the admin of not only discourse but of the server it sits on. No way around that one.


(William) #7

That´s a bummer. Thanks for the information though.