はじめに
Slackアプリの Event Subscriptions -> Enable Events -> Request URLでURL設定時にタイトルのエラーが出た場合の対応方法を整理します。
エラー内容
Your URL didn't respond with the value of the challenge parameter.
- 内容としては
challengeパラメータを指定してレスポンスを返していない、という意味です。
結論
Lambda(Node.js)の場合、以下のようなコードを書けばOKです。
challenge のみを含むレスポンスを返却するのがポイントです。
index.js
exports.handler = async (event) => {
// TODO implement
console.log(`event=${JSON.stringify(event)}`);
const event_body_json = JSON.parse(event.body);
console.log(`challenge=${event_body_json.challenge}`);
const response = {
challenge: event_body_json.challenge
};
return response;
};
注意点
- Lambdaで関数生成時にresponseに
statusCode: 200が含まれていますが、外しましょう。 -
statusCode: 200を含めていたために、私の場合はエラーがでてしまい、少し詰まりました。