Serverless! 使用 AWS 開發 Slack Slash Commands

本文介紹如何使用 AWS Lambda & AWS API Gateway 搭建一個不需要伺服器的環境,提供 Slack Slash Commands 查詢豆瓣電影。
2016-01-24 Update:New – Slack Integration Blueprints for AWS Lambda
這篇文章使用到的技術:
Slack Slash CommandsAWS LambdaAWS API Gateway豆瓣電影 API 閱讀這篇文章需要具備什麼能力:
Node.js 的基本能力Amazon Web Services 的基本操作 接下來我會逐步講解這些東西:
Slack Slash Commands 的運作機制建立一個簡單的 AWS Lambda function建立一個簡單的 AWS API Gateway 執行 Lambda function使用 Lambda 呼叫豆瓣電影 API測試 AWS API Gateway將 API Gateway endpoint 加入至 Slack Slash Command Slack Slash Commands 的運作機制 當你在 Slack channel 輸入 /movie 權力的遊戲,Slack 會發出一個 content-type Header 設為 application/x-www-form-urlencoded 的 HTTP POST 請求,格式如下:
token=YOUR_SLASH_COMMAND_TOKEN team_id=YOUR_TEAM_ID team_domain=YOUR_TEAM_DOMAIN channel_id=YOUR_CHANNEL_ID channel_name=YOUR_CHANNEL_NAME user_id=YOUR_USER_ID user_name=YOUR_USER_NAME command=/movie text=權力的遊戲 response_url=YOUR_HOOK_URL 然後 Slack 需要收到的 JSON 回應格式如下(詳見 Attachments):
{ "response_type": "in_channel", "attachments": [ { &q…
2016-01-24 Update:New – Slack Integration Blueprints for AWS Lambda
這篇文章使用到的技術:
Slack Slash CommandsAWS LambdaAWS API Gateway豆瓣電影 API 閱讀這篇文章需要具備什麼能力:
Node.js 的基本能力Amazon Web Services 的基本操作 接下來我會逐步講解這些東西:
Slack Slash Commands 的運作機制建立一個簡單的 AWS Lambda function建立一個簡單的 AWS API Gateway 執行 Lambda function使用 Lambda 呼叫豆瓣電影 API測試 AWS API Gateway將 API Gateway endpoint 加入至 Slack Slash Command Slack Slash Commands 的運作機制 當你在 Slack channel 輸入 /movie 權力的遊戲,Slack 會發出一個 content-type Header 設為 application/x-www-form-urlencoded 的 HTTP POST 請求,格式如下:
token=YOUR_SLASH_COMMAND_TOKEN team_id=YOUR_TEAM_ID team_domain=YOUR_TEAM_DOMAIN channel_id=YOUR_CHANNEL_ID channel_name=YOUR_CHANNEL_NAME user_id=YOUR_USER_ID user_name=YOUR_USER_NAME command=/movie text=權力的遊戲 response_url=YOUR_HOOK_URL 然後 Slack 需要收到的 JSON 回應格式如下(詳見 Attachments):
{ "response_type": "in_channel", "attachments": [ { &q…