The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
---
title: Overview
description: Server-side TypeScript that runs inside Twenty — triggered by HTTP routes, cron schedules, database events, AI tools, or workflow actions.
---
import { PageBanner } from "/snippets/page-banner.mdx"
import { CardTitle } from "/snippets/card-title.mdx"
## What the logic layer covers
A Twenty app's **logic layer** is the code that *runs* — server-side TypeScript handlers reacting to HTTP requests, cron schedules, and record changes; AI skills and agents that live inside the workspace; connections (OAuth or a custom sign-in flow) that let your functions act on a user's behalf in third-party services; and messaging channels that bring an external inbox into Twenty.
```text
┌─ HTTP route ──┐
│ Cron schedule │
│ Database event │ ┌────────────────────┐
triggers ─┤ AI tool call ├─────▶│ Logic function │
│ Workflow action │ │ (your handler) │
│ Manual exec │ └────────────────────┘
└────────────────────┘ │
▼
┌────────────────────────────┐
│ Twenty API (records) │
│ Third-party API │
│ (via Connection token) │
└────────────────────────────┘
```
## In this section
<CardGroup cols={2} className="documentation-card-group">
<Card href="/developers/extend/apps/logic/logic-functions" img="/images/user-guide/halftone/card-page-logic-functions.svg">
<CardTitle>Logic Functions</CardTitle>
The core building block — trigger types, payloads, and the typed API client.
</Card>
<Card href="/developers/extend/apps/logic/skills-and-agents" img="/images/user-guide/halftone/card-page-skills-agents.svg">
<CardTitle>Skills & Agents</CardTitle>
Reusable AI agent instructions and assistants with custom system prompts.
</Card>
<Card href="/developers/extend/apps/logic/workflows" img="/images/user-guide/halftone/workflows-belt-v1.svg">
<CardTitle>Workflows</CardTitle>
Ready-made workflows installed with your app: triggers, steps, and how they run.
</Card>
<Card href="/developers/extend/apps/logic/connections" img="/images/user-guide/halftone/card-page-connections.svg">
<CardTitle>Connections</CardTitle>
OAuth credentials your app holds for third-party services — Linear, GitHub, Slack, and more.
</Card>
<Card href="/developers/extend/apps/logic/messaging-channels" img="/images/user-guide/halftone/card-page-messaging-channels.svg">
<CardTitle>Messaging Channels</CardTitle>
Bring conversations from any provider into Twenty's Message and Message Thread records — threading and de-duplication included.
</Card>
<Card href="/developers/extend/apps/logic/inbox" img="/images/user-guide/halftone/card-page-messaging-channels.svg">
<CardTitle>Inbox</CardTitle>
Post messages in members' inbox from logic functions and front components.
</Card>
<Card href="/developers/extend/apps/logic/key-value-store" img="/images/user-guide/halftone/card-page-key-value-store.svg">
<CardTitle>Key-Value Store</CardTitle>
Persist state between logic function runs — caches, cursors, and cross-workspace claims.
</Card>
<Card href="/developers/extend/apps/logic/background-jobs" img="/images/user-guide/halftone/card-page-background-jobs.svg">
<CardTitle>Background Jobs</CardTitle>
Enqueue a logic function run on the workers to get past the per-run timeout.
</Card>
<Card href="/developers/extend/apps/logic/credits" img="/images/user-guide/halftone/card-page-charging-credits.svg">
<CardTitle>Charging Credits</CardTitle>
Declare what your app bills for and charge workspace credits for it.
</Card>
</CardGroup>
## Trigger types at a glance
A logic function picks one or more triggers — every entry below is a separate field on `defineLogicFunction()`:
| Trigger | When it runs | Setting |
|---------|--------------|---------|
| **HTTP route** | A request hits your `/s/<path>` endpoint | `httpRouteTriggerSettings` |
| **Cron** | A CRON expression matches | `cronTriggerSettings` |
| **Database event** | A workspace record is created, updated, or deleted | `databaseEventTriggerSettings` |
| **AI tool** | A Twenty AI feature decides to call your function | `toolTriggerSettings` |
| **Workflow action** | A workflow step invokes your function | `workflowActionTriggerSettings` |
Functions run sandboxed in isolated Node.js processes and access the workspace through a typed API client scoped to the role declared on [`defineApplication()`](/developers/extend/apps/config/application).
<Note>
**Install-time hooks** — code that runs before or after the install — share this runtime but use their own define functions and live under [Config → Install Hooks](/developers/extend/apps/config/install-hooks).
The [**health check**](/developers/extend/apps/logic/logic-functions#health-check) shares it too. An app declares one check with no trigger. By default, Twenty calls its zero-argument handler when workspace app settings open. Set `runOnUserPreferences: true` to run it on a member's Apps preferences page instead, with their required `userWorkspaceId`.
</Note>
<PageBanner illustration="section-apps-logic" />