保管ルールを設定する
グローバルconfiguration
オブジェクトは、URLなどの一般的に使用される値を保存するためにRule内で利用可能です。資格情報やAPIキーなどの機密情報は、configuration
オブジェクトを通じて保存し、Ruleのコードには含めないようにするべきです。
構成値
ダッシュボードの[Rules Settings(Rule設定)]で、設定値を設定できます。
構成キーの値を編集・変更するには、既存の構成設定を削除し、新しい値に置き換えます。構成領域を表示するには、少なくとも1つのRuleが作成されている必要があります。作成されていない場合は、Rulesのデモが表示されます。

configurationオブジェクトを使用する
設定した任意の設定値は、Rulesのコード内でキーを使ってconfiguration
オブジェクトを通じてアクセスできます。
var MY_API_KEY = configuration.MY_API_KEY;
Was this helpful?
/
次の例は、新しいユーザーがサインアップした際にSlackメッセージを送信するRuleです。Slack WebhookはSLACK_HOOK_URL
キーで設定された設定
値です。
function (user, context, callback) {
// short-circuit if the user signed up already or is using a Refresh Token
if (context.stats.loginsCount > 1 || context.protocol === 'oauth2-refresh-token') {
return callback(null, user, context);
}
// get your slack's hook url from: https://slack.com/services/10525858050
const SLACK_HOOK = configuration.SLACK_HOOK_URL;
const slack = require('slack-notify')(SLACK_HOOK);
const message = 'New User: ' + (user.name || user.email) + ' (' + user.email + ')';
const channel = '#some_channel';
slack.success({
text: message,
channel: channel
});
// don’t wait for the Slack API call to finish, return right away (the request will continue on the sandbox)`
callback(null, user, context);
}
Was this helpful?
/