LoginSignup
1
1

More than 3 years have passed since last update.

Botpressで作るチャットボットにAWSインフラエンジニアの仕事をさせよう

Posted at

忙しい日々が続いていて、自分の部下が欲しいーー!でも、教えるのは面倒。。。それ以前に人がいない。。。そう感じた時に自分の仕事をボットにやらせればいいんじゃないか?!と思いつき、開発?育成?することにしました。

完成イメージ


ボットに処理を依頼するとボットがansibleでsarコマンドなどを対象サーバー上で実行し、その実行結果をチャットに表示します

前回書いた記事

環境

EC2(AmazonLinux2)
ALB
Nginx
Botpress

参考リンク

Botpressインストール

mkdir botpress
wget https://s3.amazonaws.com/botpress-binaries/botpress-v12_10_7-linux-x64.zip
unzip botpress-v12_10_7-linux-x64.zip
./bp

■エラーになる時
※AmazonLinux2で動作しなかったので以下対応

Error starting botpress
Error: Could not require NativeExtension "fasttext.node" for OS "linux raspbian". Tried the following paths: [ /mnt/xxxxx/xxxxxxx/botpress/bindings/linux/default/fasttext.node ]

↑のエラーが出る場合、bindings/linux/にバイナリコンパイル済のファイルがあるのでそれをraspbianのところと合わせる
cp -a bindings/linux/centos_7_5 bindings/linux/raspbian

fasttextは別のオープンソースのようで別途コンパイルが必要みたい

Botpress設定

■Botpressをバックグラウンド実行する

・pm2インストール
npm install pm2 -g

・バックグラウンド実行
pm2 start './bp start -p'

■自分のWebサイトにbotpressチャットを表示させる
ヘッド部に↓

<script src="/assets/modules/channel-web/object_assign.js"></script>
<script src="/assets/modules/channel-web/inject.js"></script>

ボディ部に↓

<script>
      let lastConfig = {
      host: 'https://xxx.com/',
        botId: 'test1'
      }
      window.botpressWebChat.init(lastConfig)
</script>

フロー図の作成

・CHOICEノード
↓この選択肢が表示される
image.png
image.png
image.png
image.png
選択した値によって分岐させる
image.png

FAQ

■Code-Actionsで登録したjsファイルがNodeから呼び出せない、または呼び出していたものが呼び出せなくなっている場合
どうもこのあたりにバグがある模様
一度、エクスポートして再度、ボットをインポート作成しなおす
bpを再起動(オススメ)

1
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1