Slack Bot - jupark33/Spring GitHub Wiki
- Slack ์์ ์๋ก์ด ์ฑ ์์ฑ
- ์ฑ ๋ฉ๋ด์์ Slash Commands ์ ํ
- ๋ช ๋ น์ด (์ : /report) ๋ฅผ ๋ฑ๋กํ๊ณ ์์ฒญ URL์ ์ค์ ํ๋ค. ๋ด์ด ์คํ๋ ์๋ฒ์ Endpoint ์ด๋ค.
- ํ์ด์ ์ผ๋ก ๋ด ์ฝ๋ ์์ฑ
- Slack Workspace์ ์ฑ ์ค์น
- ํ์ด์ ๋ด ์ฝ๋
โโโpython
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route('/slack/command', methods=['POST'])
def slack_command():
data = request.form
user_command = data.get('text')
user_name = data.get('user_name')
# ๋ช
๋ น์ด ์ฒ๋ฆฌ ๋
ผ๋ฆฌ
response_message = f"Hello {user_name}, you entered: {user_command}"
return jsonify({
"response_type": "in_channel", # ์๋ต์ ๊ณต๊ฐ์ ์ผ๋ก ๋ณด๋
๋๋ค.
"text": response_message
})
if __name__ == "__main__":
app.run(port=3000)