Configure um chatbot inteligente no discourse 🤖

Olá,

Após semanas de experimentações, finalmente consegui configurar um bot de IA, semelhante ao discobot, mas que aprende e é mais responsivo. Aqui está como fiz, para quem estiver interessado em configurá-lo. Existem várias etapas, mas uma vez que tudo esteja configurado, o resultado é incrível.

  1. Instale o plugin hubot para o Discourse Hubot Adapter for Discourse. Para instalar o hubot no seu Discourse, as variáveis do hubot, como HUBOT_DISCOURSE_USERNAME, são inseridas no arquivo (sua_pasta_do_hubot)/bin/hubot. Basta usar o nano ou editá-lo para escrever export HUBOT_DISCOURSE_USERNAME=meubot. Para mais detalhes, acesse Discobot for training - #10 by featheredtoast

  2. Cadastre-se e crie um novo bot em https://dialogflow.com/

  3. Instale um adaptador hubot / apiai (dialogflow) a partir daqui: GitHub - ojacques/hubot-apiai: Add smartness and conversational UX to Hubot with API.AI as back-end · GitHub
    3a. No arquivo bin/hubot, certifique-se de que as seguintes variáveis estejam configuradas:

    export HUBOT_DISCOURSE_USERNAME=(nome_de_usuário_do_bot, não use discobot)
    export HUBOT_DISCOURSE_KEY=(chave de API do usuário do bot, não a chave de API do site)
    export HUBOT_DISCOURSE_SERVER=(url do Discourse)
    export API_AI_CLIENT_ACCESS_TOKEN=(token de acesso da API do servidor do bot no Dialogflow, encontrado nas configurações)
    export GOOGLE_APPLICATION_CREDENTIALS=(seuarquivo).json
    export DIALOGFLOW_PROJECT_ID=(nomedoprojeto)

Você precisará baixar um arquivo JSON de credenciais do Google, que pode ser obtido seguindo este guia: https://cloud.google.com/genomics/downloading-credentials-for-api-access

  1. Agora inicie seu hubot digitando bin/hubot -a discourse-adapter para executá-lo. Se quiser que ele continue rodando mesmo quando você não estiver no terminal, digite nohup bin/hubot -a discourse-adapter &

  2. Envie uma mensagem privada ao bot para testes. Se você configurou o bot do Dialogflow com conversas casuais, pode dizer oi, como vai e iniciar uma conversa casual imediatamente. Outros diálogos precisam ser configurados. Existem alguns tutoriais no YouTube que são um bom ponto de partida: https://youtu.be/HqfN9qjNj9A

Aqui está uma demonstração:

Se tiver alguma dĂşvida, sinta-se Ă  vontade para perguntar.

Além disso, um agradecimento especial a @codinghorror e à equipe por desenvolverem o Discourse, e a @awole20 por desenvolver o plugin hubot. Não teria conseguido sem vocês!

38 curtidas

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 curtida

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

5 curtidas

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

1 curtida

@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 curtida

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

3 curtidas

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

1 curtida

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 curtida

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.

Thanks for sharing this, Tim. I’m curious to know what types of dialogue you’ve set up for the chatbot. How are your forum users engaging with it in the real world?

4 curtidas

Hello Nacho,

It’s actually been awhile since I’ve used the chatbot, but am planning on using it again for an upcoming project. Mostly it was used for training sessions for teachers, they would go through a course using chatbot and learn about teaching through the dialogue. Let me know if you have any questions.

5 curtidas

Thanks, great post! Love it

2 curtidas

Uau, adorei isso e preciso refletir sobre isso nestes dias.
Preciso de alguma IA no meu site Discourse.

3 curtidas

Antes de mergulhar na implementação no meu Discourse (e como sou apenas um pouco proficiente, mas bom em seguir instruções :nerd_face: )… estas instruções neste tópico ainda estão funcionando? Ou… existe uma maneira mais atual ou preferida de integrar um bot de IA?

3 curtidas

Houve algumas conversas. Aqui está uma com desenvolvimentos mais recentes:

2 curtidas