Skip to main content
For advanced use cases, the AI can generate server-side code that calls your connected integrations directly from API routes and background workflows. This is useful when you need integration access as part of your app’s logic — not just in the chat.

When to use integrations in code

Most of the time, the AI handles integrations for you during the chat. But there are cases where you need integration access baked into your app’s code:
Use caseExample
Form submissionsA form that creates a Jira ticket when submitted
API endpointsAn endpoint that fetches Salesforce contacts for a dropdown
Background workflowsAn Inngest function that syncs HubSpot deals every hour
Data processingAn API route that enriches leads with People Data Labs data
NotificationsSending a Slack message when a record changes
In these cases, the AI generates code that calls integrations from the server side, so the logic runs automatically without user interaction in the chat.

How it works

You describe what you need, and the AI writes the code. For example:
When someone submits the new ticket form, create a Jira issue in the Backend project with the form data.
The AI generates an API route that:
  1. Receives the form submission
  2. Calls the Jira integration to create an issue
  3. Returns the created issue details to the frontend
Under the hood, the AI uses runIntegrationActionFromServer() to execute integration actions from server-side code. You do not need to call this function directly or understand its API — the AI handles the implementation.
Only organization-level integrations are accessible from server-side code. Personal integrations (set to “You only” visibility) cannot be used in generated app code, because the app runs for all users.

Common patterns

API route that calls an integration

The AI generates Next.js API routes that call integrations in response to HTTP requests:
Create an API route that fetches all Slack channels and returns them as JSON.
The AI produces a server-side route that queries the Slack integration and returns the results. The frontend can then call this endpoint to populate a dropdown or display a list.

Workflow functions

For recurring or event-driven tasks, the AI can wire integrations into Inngest workflow functions:
Create a workflow that runs every morning and posts a summary of yesterday’s Stripe charges to the #finance Slack channel.
The AI generates a scheduled workflow function that:
  1. Queries the Stripe integration for yesterday’s charges
  2. Formats a summary message
  3. Posts it to the specified Slack channel

Chained integration calls

You can combine multiple integrations in a single operation:
When a new support ticket is created, look up the customer in Salesforce and attach their account details to the ticket.
The AI generates code that calls the Salesforce integration to look up the customer, then writes the enriched data back to the ticket.

Integration availability

For integration code to work in your deployed app, the integration must be:
  1. Connected at the organization level (not personal visibility)
  2. Active — the authorization has not expired or been revoked
  3. Accessible — the integration has the necessary permissions for the actions your code uses
If an integration is disconnected or its authorization expires, API routes and workflows that depend on it will return errors.
If you disconnect an integration that app code depends on, those API routes and workflows will fail until the integration is reconnected. Check for dependent apps before removing a connection.

Debugging integration calls

When an integration call fails in your app code, check the following:
  • Integration status — Visit the Integrations page and verify the connection is active.
  • Visibility — Ensure the integration is set to Organization visibility, not “You only.”
  • Permissions — Some integrations require specific scopes or permissions. Reauthorize the integration if needed.
  • Sandbox logs — Check the sandbox console for error messages when testing in the editor.
If you are unsure why an integration call is failing, ask the AI in the chat:
The Jira integration is returning an error when creating tickets. Can you help me debug it?
The AI can inspect the error, check the integration configuration, and suggest fixes.