# OS Notification

> Show system notification.

Source: https://docs.sommatic.ai/en/nodes/io.desktop.notify/

- Slug: `io.desktop.notify`
- Family: Input and output
- Version: 1.0.0
- Status: Available
- Execution: async

Show system notification.

## Configuration

- `title` (string, optional)
- `message` (string, required)
- `icon` (string, optional): Path to icon
- `appName` (string, optional): Default: `Sommatic Orchestrator`.

## Output ports

- `out` (default): Notification dispatched
- `error`: Notification failed

## Input contract

- `title` (string, optional)
- `message` (string, required)
- `icon` (string, optional)
- `appName` (string, optional)

## Output contract

- `response` (string, optional): Notification dispatch result

## In expressions

What a later node can read from this node's output with `$("OS Notification").item.json.<path>` (write your node's label instead of `OS Notification`). **Editor** marks the paths the workflow editor suggests under Previous Nodes (the output contract); **Worker** marks the paths the worker really returns through `out`, from the output shown in Ports.

- `$("OS Notification").item.json.response` (string) = `"<notifier response>"`: Notification dispatch result


## How it works

Shows a native operating-system notification on the machine that runs the worker and returns the notifier's response.

1. Resolves the config. `title`, `message`, `icon` and `appName` fall back to the same keys of the incoming payload.
2. Sends the notification with `title` (default `Alert`), `message`, `icon` and `appName` as the application id.
3. Waits for the notifier callback: success leaves through `out` with `{ response }`, a failure through `error`.

## In a workflow

### Node

```json
{
  "node_id": "node-notify-operator",
  "label": "Notify operator",
  "operator_slug": "io.desktop.notify",
  "operator_version": "1.0.0",
  "config": {
    "title": "Batch finished",
    "message": "{{ $json.processed }} documents processed",
    "appName": "Sommatic Orchestrator"
  }
}
```

### Envelope

```json
{
  "ok": true,
  "data": {
    "response": "<notifier response>"
  },
  "port": "out"
}
```

## Output ports (behaviour in the code)

### `out`

The notifier accepted the notification. `response` is the value the platform notifier reports.

```json
{
  "response": "<notifier response>"
}
```

### `error`

The notifier failed. `error` is the error object passed by the notifier, or a message if the call threw.

```json
{
  "error": "<notifier error>"
}
```

## Behaviour in the code

- `appName`: The schema default `Sommatic Orchestrator` is not applied by the code; when empty, no application id is sent.
- `message`: Declared as required but not validated by the worker; always set it.

## Errors

| Message | Port | Cause and fix |
| --- | --- | --- |
| `<notifier error>` | `error` | The host has no notification service available (for example, a headless server). Run the node on a machine with a desktop session. |

## Notes and limits

- The notification appears on the host that runs the orchestrator worker, not in the Sommatic AI web client. Use a task or a message node to reach users.
- When persisted, an error object from the notifier may serialize as an empty object.


## Contracts (JSON Schema)

### All (`*.definition.js`)

```json
{
  "slug": "io.desktop.notify",
  "name": "OS Notification",
  "category": "io",
  "version": "1.0.0",
  "description": "Show system notification.",
  "capabilities": [
    "notification",
    "desktop"
  ],
  "config_schema": {
    "type": "object",
    "properties": {
      "title": {
        "type": "string"
      },
      "message": {
        "type": "string"
      },
      "icon": {
        "type": "string",
        "description": "Path to icon"
      },
      "appName": {
        "type": "string",
        "default": "Sommatic Orchestrator"
      }
    },
    "required": [
      "message"
    ]
  },
  "input_contract_schema": {
    "type": "object",
    "properties": {
      "title": {
        "type": "string"
      },
      "message": {
        "type": "string"
      },
      "icon": {
        "type": "string"
      },
      "appName": {
        "type": "string"
      }
    },
    "required": [
      "message"
    ]
  },
  "output_contract_schema": {
    "type": "object",
    "properties": {
      "response": {
        "type": "string",
        "description": "Notification dispatch result"
      }
    }
  },
  "ports": [
    {
      "port_id": "out",
      "label": "Shown",
      "description": "Notification dispatched",
      "is_default": true,
      "supports_condition": true
    },
    {
      "port_id": "error",
      "label": "Error",
      "description": "Notification failed",
      "is_default": false,
      "supports_condition": false
    }
  ],
  "execution_mode": "async",
  "required_resources": [],
  "compatible_worker_pools": [
    "desktop-agent"
  ],
  "tags": [
    "desktop",
    "notification"
  ],
  "is_stateful": false,
  "publisher": {
    "identity": "org_link_loom",
    "profile": {
      "name": "Link Loom",
      "verified": true,
      "url": "https://me.veripass.com/link-loom",
      "logo_url": null
    }
  }
}
```

### config_schema

```json
{
  "type": "object",
  "properties": {
    "title": {
      "type": "string"
    },
    "message": {
      "type": "string"
    },
    "icon": {
      "type": "string",
      "description": "Path to icon"
    },
    "appName": {
      "type": "string",
      "default": "Sommatic Orchestrator"
    }
  },
  "required": [
    "message"
  ]
}
```

### input_contract_schema

```json
{
  "type": "object",
  "properties": {
    "title": {
      "type": "string"
    },
    "message": {
      "type": "string"
    },
    "icon": {
      "type": "string"
    },
    "appName": {
      "type": "string"
    }
  },
  "required": [
    "message"
  ]
}
```

### output_contract_schema

```json
{
  "type": "object",
  "properties": {
    "response": {
      "type": "string",
      "description": "Notification dispatch result"
    }
  }
}
```

### ports

```json
[
  {
    "port_id": "out",
    "label": "Shown",
    "description": "Notification dispatched",
    "is_default": true,
    "supports_condition": true
  },
  {
    "port_id": "error",
    "label": "Error",
    "description": "Notification failed",
    "is_default": false,
    "supports_condition": false
  }
]
```
