Skip to content

Commit

Permalink
Merge pull request #179 from i-dot-ai/feature/follow_up_questions
Browse files Browse the repository at this point in the history
Follow Up Questions / Handling Refactor
  • Loading branch information
kurtismassey authored Nov 14, 2024
2 parents 32944d0 + 28e6383 commit a219bc3
Show file tree
Hide file tree
Showing 12 changed files with 2,856 additions and 2,245 deletions.
23 changes: 9 additions & 14 deletions caddy_chatbot/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
)


from integrations.microsoft_teams.structures import initialise_teams_client
from integrations.microsoft_teams.structures import MicrosoftTeams

app = FastAPI(docs_url=None)

google_chat = GoogleChat()


@app.get("/health")
def health():
Expand All @@ -28,8 +30,7 @@ async def google_chat_endpoint(event=Depends(verify_google_chat_request)) -> dic
"""
Handles inbound requests from Google Chat for Caddy
"""
logger.info("New Google Chat Request")
google_chat = GoogleChat()
logger.debug("New Google Chat Request")
try:
return await google_chat.handle_event(event)
except UserNotEnrolledException:
Expand Down Expand Up @@ -65,21 +66,15 @@ async def microsoft_teams_endpoint(request: Request):
logger.debug(f"POST request received: {event}")

try:
microsoft_teams, user_supervisor = await initialise_teams_client(event)
microsoft_teams = MicrosoftTeams(event)
return await microsoft_teams.handle_event(event)
except UserNotEnrolledException:
return Response(status_code=status.HTTP_403_FORBIDDEN)
except NoSupervisionSpaceException:
return Response(status_code=status.HTTP_400_BAD_REQUEST)

event_type = event.get("type")
match event_type:
case "message":
return await microsoft_teams.handle_message_event(event, user_supervisor)
case "invoke":
return await microsoft_teams.handle_invoke_event(event, user_supervisor)
case _:
logger.warning(f"Unhandled event type: {event_type}")
return microsoft_teams.responses.NOT_FOUND
except Exception as e:
logger.error(f"Error processing Microsoft Teams supervision request: {str(e)}")
return Response(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR)


@app.post("/microsoft-teams/supervision")
Expand Down
Loading

0 comments on commit a219bc3

Please sign in to comment.