Skip to content

Commit cae5ade

Browse files
committed
fix (tasks): fix trigger creation
1 parent 92d3b35 commit cae5ade

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/server/main/integrations/routes.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -375,16 +375,21 @@ async def finalize_composio_connection(
375375
"gcalendar": "GOOGLECALENDAR_GOOGLE_CALENDAR_EVENT_SYNC_TRIGGER",
376376
"gmail": "GMAIL_NEW_GMAIL_MESSAGE"
377377
}
378-
trigger_config = {"calendarId": "primary"} if service_name == "gcalendar" else {}
378+
trigger_config = {}
379+
if service_name == "gcalendar":
380+
# Google Calendar trigger requires specifying which calendar to watch.
381+
trigger_config = {"calendarId": "primary"}
382+
elif service_name == "gmail":
383+
trigger_config = {"labelIds": "INBOX"}
379384
try:
380385
logger.info(f"Setting up Composio trigger for {service_name} for user {user_id}")
381386
trigger = await asyncio.to_thread(
382387
composio.triggers.create,
383388
slug=slug_map[service_name],
384-
user_id=user_id,
389+
connected_account_id=connected_account_id,
385390
trigger_config=trigger_config
386391
)
387-
trigger_id = trigger.id
392+
trigger_id = trigger.trigger_id
388393
logger.info(f"Successfully created Composio trigger {trigger_id} for {service_name} for user {user_id}")
389394
except Exception as e:
390395
logger.error(f"Failed to create Composio trigger for {service_name} for user {user_id}: {e}", exc_info=True)
@@ -468,4 +473,4 @@ async def composio_webhook(request: Request):
468473
except Exception as e:
469474
logger.error(f"Error processing Composio webhook: {e}", exc_info=True)
470475
# Return a 200 to Composio to prevent retries on our internal errors.
471-
return JSONResponse(content={"status": "error", "detail": str(e)}, status_code=200)
476+
return JSONResponse(content={"status": "error", "detail": str(e)}, status_code=200)

0 commit comments

Comments
 (0)