0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Slack API の url_verification に Lambda + Python で応える

Posted at

URL Verification Challenge の値を返せばOK

import json

def lambda_handler(event, context):
    # Slack API からのリクエストボディを取得
    body = json.loads(event['body'])

    # URL Verification Challenge か?
    if "challenge" in body:
        # challenge の値を取得
        challenge = body['challenge']
        
        # レスポンスを作成
        response = {
            "statusCode": 200,
            "body": json.dumps({"challenge": challenge})
        }
        
        # レスポンスを返す
        return response

    # レスポンスを作成
    response = {
        "statusCode": 200,
        "body": json.dumps({"message": "Hello from Lambda!"})
    }
    
    # レスポンスを返す
    return response
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?