# Apps in workflows

> How apps and workflows meet today. A task can carry an app that collects its output, and the sommatic.app.handoff node ends a run by handing its result to an app through a task.

Source: https://docs.sommatic.ai/en/apps/workflow-bridge/ (updated 2026-11-26)

A workflow prepares the case; an app is where a person finishes it. Today they meet through **tasks**: the task is the
durable link between a run and a person, and the app is the screen the person uses to resolve it.

## A task that opens an app

A task can name the app that collects its output in `execution`:

| Field            | What it is                                                                             |
| ---------------- | -------------------------------------------------------------------------------------- |
| `app_slug`       | The app to open. Without it, the task shows the form generated from `required_output`. |
| `launch_mode`    | The mode the app opens in.                                                             |
| `input_payload`  | Extra data for the app.                                                                |
| `app_session_id` | Filled at runtime when the app session opens.                                          |

```json
{
  "title": "Review the extracted invoice",
  "type": { "id": 12, "name": "review", "title": "Review" },
  "priority": { "id": 3, "name": "high", "title": "High" },
  "required_output": {
    "schema": { "type": "object", "required": ["decision"], "properties": { "decision": { "type": "string" } } }
  },
  "execution": {
    "app_slug": "<app-slug>",
    "launch_mode": "task",
    "input_payload": { "invoice_id": "<invoice-id>" }
  }
}
```

Create it with `POST /work-management/task/`. In the portal, the task shows **Open App**. The app opens with an input
that carries `task_id`, the `task` itself, the fields of the task `payload` and the `input_payload`. When the app calls
`sdk.submitOutput()`, the output becomes the task's `outputs`: a `decision` of `rejected` rejects the task, any other
output completes it, after the [output validation](https://docs.sommatic.ai/en/human-in-the-loop/task-lifecycle.md).

The `human.task.create` node does not set `execution` today. Create app-bound tasks through the API.

## Hand a run's result to an app

[`sommatic.app.handoff`](https://docs.sommatic.ai/en/nodes/sommatic.app.handoff.md) is a terminal node: the run ends and delivers its result to
an app.

```json
{
  "target": {
    "app_slug": "<app-slug>",
    "route": "/review",
    "launch_mode": "command-center"
  },
  "input_mapping": {
    "case_id": "{{ $json.case_id }}",
    "summary": "{{ $('Summarize').item.json.summary }}"
  },
  "organization_id": "<organization-id>",
  "assignee": "<user-identity>",
  "task_title": "Review the prepared case"
}
```

| Field                                       | Required | Default                                       |
| ------------------------------------------- | -------- | --------------------------------------------- |
| `target.app_slug`                           | Yes      |                                               |
| `target.route`                              | No       | `/`                                           |
| `target.launch_mode`                        | No       | `command-center`                              |
| `input_mapping`                             | No       | `{}`. Expressions are resolved on the server. |
| `organization_id`, `assignee`, `task_title` | Yes      |                                               |
| `task_type`, `task_priority`                | No       | Review, medium.                               |

What it does:

1. It resolves the open descriptor on the server: `{ app_slug, route_path, input_payload, launch_mode }`.
2. It creates a task assigned to `assignee`, which carries the descriptor. The task is durable: it waits in the
   person's inbox even if they are offline when the run ends.
3. It leaves through `out` with `app_handoff_descriptor`, `task_id` and `task_title`, and the run's result keeps the
   descriptor. When the run was started from the Command Center, the app opens there as soon as the run ends.

The run does not resume after the handoff. Whatever the person does in the app happens outside that run.

## What is not available yet

> **Warning: Apps as a gate inside a run**
>
> `sommatic.app.execute` is partial. Today it creates the app interaction and continues through its default port
> without waiting for the app's output, so the run does not pause for the person. Do not use it as a gate. The `task`
> and `workflow` [launch modes](https://docs.sommatic.ai/en/apps/launch-modes.md) describe the intended contract; today the output of an app opened
> from a task reaches the task, not the run that created it.

## Next steps

- [Human in the loop](https://docs.sommatic.ai/en/human-in-the-loop.md): Tasks, assignees and required outputs.
- [Contracts](https://docs.sommatic.ai/en/apps/contracts.md): Align the app output with the task.
- [Human-in-the-loop nodes](https://docs.sommatic.ai/en/nodes/family/hitl.md): Every node of the family.
