Set up a smart chatbot on discourse 🤖

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 - #10 by featheredtoast

  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: https://cloud.google.com/genomics/downloading-credentials-for-api-access

  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!

38 лайков

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!

1 лайк

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

5 лайков

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

1 лайк

@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)?

1 лайк

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

3 лайка

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

1 лайк

I am slowly working my way through this. What threw me at the first stage was access errors when running yo hubot --adapter=discourse-adapter per the installation instructions for the plugin. It looks like you have to change the permission for the folders. Fix is documented here.

1 лайк

So, as I discussed above, I hit an error installing NPM. Error was using root when installing, a common gotcha that leads to a lot of EACCES and permission errors. This is a well-documented error. I believe a lot of people are on Digital Ocean. Follow their documentation for correctly setting up NPM on your droplet.

Спасибо за то, что поделились этим, Тим. Мне интересно узнать, какие типы диалогов вы настроили для чат-бота. Как пользователи форума взаимодействуют с ним в реальной жизни?

4 лайка

Привет, Начо,

Прошло уже довольно много времени с тех пор, как я последний раз пользовался чат-ботом, но планирую снова использовать его для предстоящего проекта. В основном он применялся для обучающих сессий для учителей: они проходили курс с помощью чат-бота и изучали методы преподавания через диалог. Дай знать, если у тебя возникнут вопросы.

5 лайков

Спасибо, отличный пост! Мне нравится

2 лайка

Вау, мне это очень понравилось, и я должен обдумать это в ближайшие дни. Мне нужен ИИ на моём сайте Discourse.

3 лайка

Прежде чем я приступлю к реализации этого в своём Discourse (и поскольку я лишь немного разбираюсь в этом, но хорошо умею следовать инструкциям :nerd_face: )… актуальны ли ещё эти инструкции в этой теме? Или… есть ли более современный или предпочтительный способ интеграции ИИ-бота?

3 лайка

Было несколько обсуждений. Вот одно с более свежими обновлениями:

2 лайка