LoginSignup
1
1

More than 5 years have passed since last update.

The Knowledge component & The rules component actionおよびconditionの再作成について

Last updated at Posted at 2018-07-26

object2の再作成

$ node myapp.js

Saved object with id: 40968288 and type Person
Saved object with id: 40968296 and type House
Saved object with id: 40972384 and type Door
All objects created

Object id
Created relation: 40968296(House) -[has-as-part]-> 40972384(Door)
Created relation: 40968288(Person) -[ownership]-> 40968296(House)
All relations created

要注意1:kr-node-sdkのaction.zipを削除してから、zip コマンドを実行してください。
要注意2:kr-node-sdkのpackage.jsonの"main":"action.js"になっているかどうかを確認してから、zip コマンドを実行してください。
要注意3:functionsで既存のactionを削除してから、bx wsk action コマンドを実行してください。

actionの削除方法:
1.https://console.bluemix.net/openwhisk/actions でdefault package ->web action ->有効を押してください。
2.新画面で「Web アクションとして有効化」のチェックを外してから、actionを削除してください。
3.さっきの画面に戻って、うまく削除されたとactionが消えます。

$ zip -r action.zip action.js package.json node_modules/ .env sdk/
$ bx wsk action create action2 action.zip --web true --kind nodejs:8
$ curl -X POST -H "Content-Type:application/json" -d '{"results":[{"type":"Door","id":"40972384"}]}' https://openwhisk.ng.bluemix.net/api/v1/web/XXXXXX%40XX.XXX.com_dev/default/action2

上記のcurlを実行すると、https://wpa-chat-bot.mybluemix.net/ でalert messageが表示できます。
要注意:初期設定はそのまま使わず、WA-keyのところは/wa paster-your-api-key-here で変更して下さい

condition2の再作成

要注意1:kr-node-sdkのcondition.zipを削除してから、zip コマンドを実行してください。
要注意2:kr-node-sdkのpackage.jsonの"main":"condition.js"になっているかどうかを確認してから、zip コマンドを実行してください。
要注意3:functionsで既存のconditionを削除してから、bx wsk action コマンドを実行してください。

conditonの削除方法:
1.https://console.bluemix.net/openwhisk/actions でdefault package ->web action ->有効を押してください。
2.新画面で「Web アクションとして有効化」のチェックを外してから、conditionを削除してください。
3.さっきの画面に戻って、うまく削除されたとconditionが消えます。

$ zip -r condition.zip condition.js package.json node_modules/ .env sdk/`
$ bx wsk action create condition2 condition.zip --web true --kind nodejs:8`
$ curl -X POST -H "Content-Type:application/json" -d '{"results":[{"type":"Door","id":"40972384"}]}' https://openwhisk.ng.bluemix.net/api/v1/web/XXXXXX%40XX.XXX.com_dev/default/condition2

実行すると、$ bx wsk activation poll condition でログを見えます。
また、https://console.bluemix.net/openwhisk/dashboard にも実行されたconditionのログも見えます。

スクリーンショット 2018-07-26 13.31.28.png

Rules APIでeca agentに登録

方法1:UIでAPIを操作

POST /agent/register_eca_agent

value
{
"action": "https://openwhisk.ng.bluemix.net/api/v1/web/wcl1207%40jp.ibm.com_dev/default/action2",
"condition": "https://openwhisk.ng.bluemix.net/api/v1/web/wcl1207%40jp.ibm.com_dev/default/condition2",
"event": "object-update"
}

response
{ "sample-action": "https://openwhisk.ng.bluemix.net/api/v1/web/XXXXXX%40XX.XXX.com_dev/default/action2/181f643a-6478-483f-a972-fac97aed65fd/", "id": "181f643a-6478-483f-a972-fac97aed65fd", "sample-condition": "https://openwhisk.ng.bluemix.net/api/v1/web/XXXXXX%40XX.XXX.com_dev/default/condition2/181f643a-6478-483f-a972-fac97aed65fd/" }

方法2:curl

curl -X POST --header 'Content-Type: application/json' --header 'Accept: text/html' -d '{ "event": "object-update", "condition": "https://openwhisk.ng.bluemix.net/api/v1/web/XXXXXX%40XX.XXX.com_SPACENAME/default/condition2”, "action": "https://openwhisk.ng.bluemix.net/api/v1/web/XXXXXX%40XX.XXX.com_SPACENAME/default/action2” }' 'https://watson-personal-assistant-toolkit.mybluemix.net/agent/register_eca_agent?api_key=自分のapikeyを入れてください'

subscriptionの削除

Optional:過去の不要なsubscriptionを削除できます。
スクリーンショット 2018-07-26 13.31.15.png

subscriptionの取得方法:
スクリーンショット 2018-07-26 13.31.45.png

1
1
0

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