ComposioIntegrationNotConnectedError
composio.errors.ComposioIntegrationNotConnectedError
Stack trace
Traceback (most recent call last):
File "app.py", line 42, in <module>
composio_client.send_event(event)
File "/usr/local/lib/python3.9/site-packages/composio/client.py", line 88, in send_event
raise ComposioIntegrationNotConnectedError("Composio integration not connected. Please authenticate first.")
composio.errors.ComposioIntegrationNotConnectedError: Composio integration not connected. Please authenticate first. Why it happens
This error occurs when the Composio client attempts to send data or perform actions without a successful connection or authentication to the Composio service. It usually means the integration setup step was skipped or the API key was not provided or invalid.
Detection
Check for this exception immediately after initializing the Composio client or before sending events; log connection status and verify API key presence to catch it early.
Causes & fixes
API key environment variable is missing or not loaded
Set the COMPOSIO_API_KEY environment variable before initializing the client and verify it is accessible in your runtime environment.
Client initialization code did not call the authentication or connect method
Ensure you call composio_client.connect() or the equivalent authentication method before sending any events.
Using an invalid or expired API key causing authentication failure
Verify your API key is valid and has not expired; regenerate it from the Composio dashboard if necessary.
Code: broken vs fixed
from composio import ComposioClient
client = ComposioClient()
# This line raises ComposioIntegrationNotConnectedError
client.send_event({'event': 'test'}) import os
from composio import ComposioClient
os.environ['COMPOSIO_API_KEY'] = 'your_api_key_here' # Set your API key securely
client = ComposioClient()
client.connect() # Authenticate and connect before sending events
client.send_event({'event': 'test'})
print('Event sent successfully') Workaround
Wrap send_event calls in try/except ComposioIntegrationNotConnectedError, then log the error and retry client.connect() before resending the event.
Prevention
Always set and verify the COMPOSIO_API_KEY environment variable and call the client’s connect or authenticate method during app startup to ensure the integration is connected before use.