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 case | Example |
|---|---|
| Form submissions | A form that creates a Jira ticket when submitted |
| API endpoints | An endpoint that fetches Salesforce contacts for a dropdown |
| Background workflows | An Inngest function that syncs HubSpot deals every hour |
| Data processing | An API route that enriches leads with People Data Labs data |
| Notifications | Sending a Slack message when a record changes |
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:
- Receives the form submission
- Calls the Jira integration to create an issue
- Returns the created issue details to the frontend
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:
- Queries the Stripe integration for yesterday’s charges
- Formats a summary message
- 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:- Connected at the organization level (not personal visibility)
- Active — the authorization has not expired or been revoked
- Accessible — the integration has the necessary permissions for the actions your code uses
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.
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.