Skip to content

Commit ee1c245

Browse files
committed
Handle app_mention and prepare to send a message back
1 parent 71992f4 commit ee1c245

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

solution/main.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from pprint import pprint
22

3+
from benedict import benedict
4+
35
from fastapi import Body, FastAPI, Request, Response
46

57
app = FastAPI()
@@ -16,6 +18,15 @@ async def echo(request: Request, response: Response, data=Body(...)):
1618
# So we can post back a message
1719
pprint(data)
1820

21+
payload = benedict(data)
22+
23+
event_type = payload.get("event.type")
24+
channel_id = payload.get("event.channel")
25+
26+
if event_type == "app_mention":
27+
# Send the message here
28+
print(channel_id)
29+
1930
return {
2031
"data": data,
2132
"raw_body": body,

solution/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
fastapi==0.67.0
22
uvicorn==0.14.0
33
requests==2.26.0
4+
python-benedict==0.24.0

0 commit comments

Comments
 (0)