I'm creating an integration dynamically for an action my agent chooses to use that does not have an integration setup. I know I can fetch the app and see a list of its supported schemes and use one there for the integration. My question is, what does "COMPOSIO_LINK" do exectly? Is that a link you return to me that I redirect my user to? I've used this for an app that uses OAUTH so the user see's the oauth flow, but what if the app does not have oauth, what does "COMPOSIO_LINK" do then?
const actionDetails = await getActionDetails(toolId)
if (!actionDetails) {
return
}
const config = {
...formatActionDetailsForPrompt(actionDetails),
approvalNeeded: !(
toolId.toUpperCase().includes('GET_') ||
toolId.toUpperCase().includes('_GET') ||
toolId.toUpperCase().includes('_FIND') ||
toolId.toUpperCase().includes('FIND_') ||
toolId.toUpperCase().includes('_SEARCH') ||
toolId.toUpperCase().includes('SEARCH_') ||
toolId.toUpperCase().includes('READ_') ||
toolId.toUpperCase().includes('_READ') ||
toolId.toUpperCase().includes('_LIST') ||
toolId.toUpperCase().includes('LIST_')
),
integration: actionDetails.appName,
}
if (actionDetails.no_auth) {
return config
}
const result = await toolSet.integrations.list({
appName: actionDetails.appName,
})
const integration = result.items[0]
if (!integration) {
const { result: app, error } = await attempt(toolSet.apps.get({ appKey: actionDetails.appKey }))
if (error) {
console.error('Error getting app params', error)
return
}
if (!app) {
console.error('Error getting app params', error)
return
}
if (!app.no_auth) {
await toolSet.integrations.create({
appUniqueKey: actionDetails.appKey,
name: `${actionDetails.appName}-managed`,
authScheme: 'COMPOSIO_LINK',
forceNewIntegration: true,
useComposioAuth: true,
})
}
}
const isOauth = integration.authScheme.toLowerCase().includes('oauth')
const auth: { status: 'CONNECTED' | 'DISCONNECTED'; authUrl: string | null; type: 'oauth' | 'key' } = {
status: 'CONNECTED',
authUrl: null,
type: isOauth ? 'oauth' : 'key',
}
const entity = await toolSet.getEntity(userId)
let connection = null
try {
connection = await entity.getConnection({ appName: actionDetails.appName })
} catch (error) {
console.log('Error getting connection', error)
}
if (!connection || connection.isDisabled || connection.status !== 'ACTIVE') {
if (isOauth) {
const connReq = await entity.initiateConnection({
integrationId: integration.id,
appName: actionDetails.appName,
authMode: 'COMPOSIO_LINK',
redirectUri: createUrl(`/api/composio/callback/${sessionId}`),
})
auth.authUrl = connReq.redirectUrl
auth.status = 'DISCONNECTED'
} else {
auth.status = 'DISCONNECTED'
}
} else if (connection && connection.status === 'ACTIVE') {
auth.status = 'CONNECTED'
}
return {
...config,
auth,
}