Coder Social home page Coder Social logo

nobusugi246 / groovy-knowledge-integrator Goto Github PK

View Code? Open in Web Editor NEW
7.0 4.0 2.0 7.03 MB

A System for Knowledge Integration by grails/groovy. A Chat Microservice and a Chatbot Microservice by groovy language.

License: Apache License 2.0

Groovy 1.36% JavaScript 93.22% CoffeeScript 0.19% CSS 5.14% HTML 0.09% PLSQL 0.01%
chat chatbot grails spring-boot uikit

groovy-knowledge-integrator's Introduction

groovy Knowledge Integrator

1. ScreenShot

chatIndex
Figure 1. ScreenShot of this Chat Application

2. Features

A Chat Microservice builded by Grails Ver.3.2 and a Chatbot Microservice builded by Spring Boot/Groovy.

  1. Chatbot by groovy language.

    • A Chat Microservice has embedded one, a Chatbot Microservice is a container of any bot by groovy language.

    • Chatbot for Robotic Process Automation(RPA) with Selenium/Geb.

  2. Accepts Github webhooks at the Chat Microservice.

  3. Crawls Feeds of Atom / RSS / RDF. If updated, sends them to selected Chat Room.

  4. Calls Jenkins to build Pipeline.

  5. User Icon (Identicon) by Jdenticon.

  6. Chat Rooms.

  7. Chat log display by selecting a day on Calendar.

about
Figure 2. Outline

この図の矢印は、情報の流れを示しています。

(1) いわゆるチャットによるコミュニケーション。必要に応じて ChatRoomの作成、削除を行ないます。

(2) プロジェクトで使用しているレポジトリ(GitHub, GitLab, GitBucket)の変更や、 Pull Requestの通知、Issueの追加 / 削除などが、WebHookによりチャットとして表示します。

(3) Jenkinsに定義された Pipelineの実行を、チャットにより指示します。

(4) 社内に乱立している Redmineプロジェクトの活動状況や、世界中の Blogや NEWSの情報、 GitHubでの開発者の Public Activity、Jenkinsによるビルド状況などについて、 変化が随時チャットとして時系列で表示します。

これらの活動を、発生順に、時系列に並べられてチャットとして表示します。 適宜、ChatRoomを作成して振り分けることで、分類し、見通しを良くします。

3. How to run / 実行方法

Download gki-chat-1.1.12.jar and gki-container-0.1.8.jar from releases link, then

List 1. How to run Microservices
$ java -jar gki-chat-1.1.12.jar
$ java -jar gki-container-0.1.8.jar

or

$ java -Dgeb.env=chrome -jar gki-container-0.1.8.jar

This will generate 2 Database files (prodDb.mv.db, botContainerDB.mv.db) at the current folder.

And access http://localhost:8080/chat/index (Chat), http://localhost:8081 (Chatbot) from your Browser

If you want to change port number(ex. 8082), then

List 2. How to change port number
$ java -jar gki-chat-1.1.12.jar --server.port=8082

4. How to use / 利用方法

4.1. 初期表示

ブラウザで http://localhost:8080/chat/index にアクセスします。 最初のアクセスであれば、以下の様に表示されます。

index00
Figure 3. 初期表示

まず「Your Name」フィールドに名前を記入します。 それから Tabキーまたはマウスにより、 「Chat Message」フィールドにフォーカスを移動します。 これにより、次の様にメッセージが表示されます。 (このメッセージは、新規のユーザが接続したときか、 hello コマンドを送信したときに表示されます。 そのユーザにのみ表示され、他のユーザには見えません。 メッセージの永続化(詳細は後述)もされません。)

chatIndex
Figure 4. 名前設定後の表示

「gkibot」は、組み込みの Chatbotです。このチャットシステムを利用するための案内役です。 表示されるコマンドは、その時点で利用できるものが表示されます。

チャットのメッセージは、以下の様に「Identicon」、「ユーザ名」、「タイムスタンプ」に 続いて表示されます。同じユーザのメッセージが続く場合は、これらは一度だけ表示されます。

index01a
Figure 5. Identicon

「Identicon」は、ユーザを視覚的に識別するためのアイコンです。 「ユーザ名」の文字列から生成されるため、 同じユーザ名であれば同じ Identiconが表示されます。

「Your Name」フィールドに記入した名前は、 「Users in this Chat Room」テーブルに表示されます。

index01b
Figure 6. Chat Roomのユーザ一覧表示

このテーブルには、この Chat Roomにいるユーザの一覧が表示されます。 このチャットサーバに接続しているすべてのユーザを知りたい場合は、 users コマンドを実行してください。

「OnLine」表示は、サーバとの接続が切れると、以下の様に「OffLine」と表示されます。

index02
Figure 7. OffLine表示

一時的に通信が切れただけであれば、ブラウザによるページのリロードにより 「OnLine」に戻る場合があります。 それでも「OffLine」のままであれば、サーバの管理者に連絡してください。

4.2. メッセージの送受信、コマンドの実行

「Chat Message」フィールドに文言を入力し、Returnキーを押すことで、 今いる Chat Roomにメッセージを送信します。 そのメッセージは、その Chat Roomにいるユーザに送信されます。

メッセージの内容がコマンドの形式に一致した場合、 コマンドとして実行されます。

メッセージは基本的に永続化(データベースに記録)されます。 ただし、以下の場合は永続化されません。

  1. コマンドの応答メッセージで、そのユーザにのみ意味がある場合。 hello / users / info / health / metrics など、 それを実行したときのユーザにのみ意味がある応答メッセージは、 永続化されません。 他のユーザにも表示されません。

  2. コマンドの実行がエラーにより失敗した場合のエラー返信メッセージ。 そのコマンドを実行したユーザにはエラーメッセージが返信されますが、 そのエラーの返信メッセージは永続化されません。 他のユーザにも表示されません。

また、メッセージの内容が URL(http:// または https:// ではじまる文字列)に一致した場合、 それはリンクとして表示されます。

4.2.1. コマンドの実行例

Chat Roomの作成

makeChatRoom コマンドを使用します。 コマンドに続いて、作成したい Chat Roomの名前を記載します。 その名前にスペースを含めることはできません。

index04a
Figure 8. Chat Roomの作成例(1/2)

コマンドの実行が成功すれば、 以下のようにコンボボックスに Chat Roomが追加された一覧として表示されます。

index04b
Figure 9. Chat Roomの作成例(2/2)

このコンボボックスで Chat Roomを選択することで、 利用する Chat Roomを変更できます。

WebHookの登録

基本的な手順は以下です。

  1. WebHookを表示する Chat Roomを作成します(必要に応じて)。

  2. WebHookを表示する Chat Roomに移動し、利用する WebHookを登録します。

  3. GibHub / GitLab / GitBucket等で、WebHookの設定を行ないます。

ここでは作成した Chat Roomに移動後の手順を説明します。

addHook コマンドを使用します。 使用方法は、 hello コマンドか、 addHook とのみ入力することで表示されます。 [] 内の入力は必須ではありません。

index04z
Figure 10. addHookコマンドの入力形式

ここでは localhostの GitBucketサーバと連携するための設定を例に説明します。 以下のように addHook コマンドを実行することで、 この Chat Roomに WebHookのメッセージが表示されるようになります。

index04w
Figure 11. WebHookの登録例(1/4)

次に、GitBucket側の設定を行ないます。 以下のように、「Setting」メニューの「Service Hooks」タブを選択します。 新規の登録であれば、右下の「Add webhook」ボタンを押下します。

index04y
Figure 12. WebHookの登録例(2/4)

以下のように、それぞれの項目に記入し、「Add webhook」ボタンを押下します。

index04x
Figure 13. WebHookの登録例(3/4)

GitBucketのレポジトリに Pushされた場合には、以下のように表示されます。

index04v
Figure 14. WebHookの登録例(4/4)
Feedの登録

基本的な手順は以下です。

  1. Feedを表示する Chat Roomを作成します(必要に応じて)。

  2. Feedを表示する Chat Roomに移動し、利用する Feedを登録します。

ここでは作成した Chat Roomに移動後の手順を説明します。

addFeed コマンドを使用します。 使用方法は、 hello コマンドか、 addFeed とのみ入力することで表示されます。 [] 内の入力は必須ではありません。

index04c
Figure 15. addFeedコマンドの入力形式

ここでは、Springの Blogを登録します。 addFeed コマンドの記述に問題なければ、gkibotから登録したとの応答があります。 URLが適切であれば、1分以内に、最初の Feedの表示が登録した Feed名によりされます。

index04d
Figure 16. Feedの登録例(1/2)

最新の Feedが 1件表示されます。 タイムスタンプは、Feedに付加されていたものです。 以後は、これよりも新しい Feedが追加されたときに、追加分が随時表示されます。 この追加の確認は、一定間隔で実行されます。その間隔はデフォルトでは 30分です。

この間隔を変更する場合は、以下のようにコマンドを実行します。

List 3. Feedの登録例(2/2)
addFeed SpringBlog https://spring.io/blog.atom FeedsTimeline 120

間隔時間(Interval)の単位は分です。

Redmineプロジェクト

Redmineのプロジェクトを対象とする場合は、以下のように、「活動」タブを選択します。

index04e
Figure 17. Redmineの「活動」タブを選択

次に、右側に表示される、Feedに含める項目を選択し、「適用」ボタンを押します。

index04f
Figure 18. 確認したい「活動」タブの変更内容を選択

次に、右下の「Atom」のリンクを右マウスボタンにより URLをコピーします。

index04g
Figure 19. Feedの URLをコピー

最後に、同様に登録を行ないます。

index04h
Figure 20. Redmineプロジェクトの登録
GitHubの開発者の Public Activity

GitHubのレポジトリは直接 Feedとしてあつかえません。 開発者(レポジトリの管理者)であれば、 その「Public Activity」タブの Feedを登録すればよいです。

index04j
Figure 21. GitHubの開発者の Public Activity

4.3. Jenkin Jobとの連携

Jenkin Jobとの連携は以下ができます。

  1. Jenkins Jobにビルドの実行を依頼する。

  2. ビルドの結果を Feedとして(指定した) Chat Roomに表示する。

この連携のための設定は以下の手順になります。

  1. Feedを表示する Chat Roomを作成します(必要に応じて)。

  2. Feedを表示する Chat Roomに移動し、Jenkins Jobのビルド実行結果を Feedとして登録します。

  3. Jenkins Jobを登録します。

ここでは作成した Chat Roomに移動後の手順を説明します。

Jenkins Jobのビルド実行結果を Feedとして登録する場合は、 以下の「RSS全ビルド」の URLを右マウスボタンによりコピーし、 addFeed コマンドにより、他の Feedと同様に登録します。

index04i
Figure 22. Jenkins ビルド実行結果の登録

Jenkins Jobの登録には、 addJenkins コマンドを利用します。

使用方法は、 hello コマンドか、 addJenkins とのみ入力することで表示されます。 [] 内の入力は必須ではありません。

index04u
Figure 23. addJenkinsコマンドの入力形式

Jenkinsの Web画面で、 それぞれの Jenkins Jobの状況が表示される URLを以下のように登録します。

index04t
Figure 24. Jenkins Jobの登録

ビルドの実行の依頼では、この URLに buildが付加された以下の URLが使用されます。

http://localhost:8180/job/gki/build

実際に設定とビルドを実行した例を以下に示します。

まず、Jenkins Jobのビルド実行結果の Feedの登録を行ないます。 Feedの確認間隔をデフォルトの 30分より短い 10分として設定しています。

index04s1
Figure 25. Jenkins Jobの Feedの登録

次に Jenkins Jobを登録します。 Jenkinsの設定により認証が必要となっているため、 ユーザ名とパスワードも設定しています。

続いて build コマンドにより Jobの実行を依頼し、 その結果が Feedとして表示されます。

index04s2
Figure 26. Jenkins Jobの登録と実行、結果の表示

4.4. 設定の Export / Import

4.4.1. Export

以下の URLにアクセスしてください。

List 4. 設定Export用 URL
http://localhost:8080/chat/export

ブラウザでアクセスした場合、 「ChatService.conf」というファイル名で保存されます。

curl等でアクセスした場合も、このファイル名で保存してください。

4.4.2. Import

このプロセス起動時に Importされます。 プロセス起動のコマンドを実行するフォルダに、 「ChatService.conf」というファイル名でこの設定ファイルを配置しておいてください。

5. Grails Tips

5.1. @Scheduled Annotation

Since Grails Ver.3.1.7, at the Service Class which has a method with @Scheduled Annotation, lazyInit should be disabled.

List 5. disable lazyInit
class xxxx {
  static lazyInit = false
...

  @Scheduled(fixedRate=10000L)
  void yyyy() {
...
  }
}

5.2. BootStrap.groovy

Since Grails Ver.3.2, BootStrap.groovy should be placed at same package of Application.groovy.

6. License / ライセンス

Apache License Version 2.0

7. Acknowledgements / 謝辞

8. ChangLog / 変更履歴

  • Chatbot Ver.0.1.8, . : 2017-09-18

  • Chat Ver.1.1.12 / Chatbot Ver.0.1.7, Update grails to Ver.3.2.11 for Chat, update uikit for Chatbot. : 2017-08-16

  • Chatbot Ver.0.1.6, Update libraries and fix HtmlUnit. : 2017-07-30

  • Chatbot Ver.0.1.5, Update libraries around Selenium and Geb. : 2017-07-17

  • Chatbot Ver.0.1.4, Add send/reply methods for chatbot. : 2017-06-05

  • Chatbot Ver.0.1.3, Add description of bot and testing feature by bot. : 2017-05-31

  • Chat Ver.1.1.11 / Chatbot Ver.0.1.2, Add dropdown list of NavBar for ChatServer and ChatBotServer : 2017-05-25

  • Chat Ver.1.1.10 / Chatbot Ver.0.1.1, Fix null DM message Chat, add ChatServer Manager at Chatbot Microservice. : 2017-05-22

  • Chat Ver.1.1.9 / Chatbot Ver.0.1.0, Initial release of the Chatbot Microservice. : 2017-05-17

  • Ver.1.1.8, Resize the frontend at startup. : 2017-04-24

  • Ver.1.1.7, Update Grails to Ver.3.2.8, change UX with uikit. : 2017-04-10

  • Ver.1.1.6, Update Grails to Ver.3.2.6, change tab to Now when chat message sent. : 2017-02-15

  • Ver.1.1.5, Change Accordion to Tab. : 2017-02-05

  • Ver.1.1.4, Update Groovy and fix auto link at frontend. : 2017-01-29

  • Ver.1.1.3, Fix Accordion heights and replace the Accordion icon. : 2017-01-26

  • Ver.1.1.2, Support smooth collapsing. : 2017-01-22

  • Ver.1.1.1, Remove horizontal scroll bars, add a Accordion icon. : 2017-01-22

  • Ver.1.1.0, Fix Web Notification, separate Past Messages in an Accordion. : 2017-01-15

  • Ver.1.0.10, Fix User List and cache MessageNumber. : 2017-01-13

  • Ver.1.0.9, Update support of MessageNumberBadge on each day, add reply selection. : 2017-01-12

  • Ver.1.0.8, First support of MessageNumberBadge on each day. : 2017-01-10

  • Ver.1.0.7, Not to notify by self and old messages. : 2016-12-21

  • Ver.1.0.6, Add first support for the Web Notification. : 2016-12-17

  • Ver.1.0.5, Update Grails to Ver.3.2.3 with fix #32. : 2016-12-03

  • Ver.1.0.4, Downgrade Grails to Ver.3.1.14 because of #32. : 2016-12-03

  • Ver.1.0.3, Update Grails to Ver.3.2.2. : 2016-11-06

  • Ver.1.0.2, Update Grails to Ver.3.1.12. Restructure folders.: 2016-10-10

  • Ver.1.0.1, Optimize Icon Image download. : 2016-08-16

  • Ver.1.0.0, Fix Icon Image upload, add temporary input display. : 2016-08-14

  • Ver.1.0.0-RC2, Update Icon Image update. : 2016-08-11

  • Ver.1.0.0-RC1, Update Grails to Ver.3.1.10, close #5. : 2016-08-09

  • Ver.0.1.17, Update Grails to Ver.3.1.9 and Gorm to Ver.5.0.10, close #21. : 2016-07-03

  • Ver.0.1.16, Use style "word-break: break-all;" to Scaffolding table. : 2016-06-20

  • Ver.0.1.15, Minor improvements. : 2016-06-14

  • Ver.0.1.14, Fix #4, #20. : 2016-06-12

  • Ver.0.1.13, Fix #17. : 2016-06-08

  • Ver.0.1.12, Fix #13, #14, #15. : 2016-06-05

  • Ver.0.1.11, Upgrade to Grails 3.1.8, fix #11. : 2016-06-01

  • Ver.0.1.10, Fix export, add import Configuration with ConfigSlurper. fix #9, #10. : 2016-05-30

  • Ver.0.1.9, Upgrade to Grails 3.1.7, add feature of export Configuration. : 2016-05-29

  • Ver.0.1.8, Fix #6, #8. : 2016-05-24

  • Ver.0.1.7, View only last one item when feed added. : 2016-05-23

  • Ver.0.1.6, Add initial FeedCrawler. : 2016-05-22

  • Ver.0.1.5, Add initial WebHook Configuration. : 2016-05-19

  • Ver.0.1.4, Add delay between messages of list. : 2016-05-15

  • Ver.0.1.3, Add link to Issue/Pull Request No. of Chat Message. : 2016-05-13

  • Ver.0.1.2, Update to display Spring Boot Actuator info/health/metrics, and accept Github webhooks. : 2016-05-12

  • Ver.0.1.1, Add log viewer by selected date and users command. : 2016-05-10

  • Ver.0.1.0, Initial release. : 2016-05-09

groovy-knowledge-integrator's People

Contributors

nobusugi246 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

pl99 kosuke-

groovy-knowledge-integrator's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.