# `KapsoEx.Workflows`
[🔗](https://github.com/rocket4ce/kapso_ex/blob/v0.1.0/lib/kapso_ex/workflows.ex#L1)

[Workflows](https://docs.kapso.ai/docs/workflows/introduction): automated
WhatsApp conversations built from nodes and edges.

Executions are in `KapsoEx.Workflows.Executions` and triggers in
`KapsoEx.Workflows.Triggers`.

# `result`

```elixir
@type result() :: {:ok, map()} | {:error, KapsoEx.Error.t()}
```

# `create`

```elixir
@spec create(KapsoEx.Client.t(), map() | keyword()) :: result()
```

Creates a draft workflow. Attributes: `name` (required), `slug`,
`description`, `definition` (`%{nodes: [...], edges: [...]}`).

# `get`

```elixir
@spec get(KapsoEx.Client.t(), String.t()) :: result()
```

Gets workflow metadata, status and execution stats (without the definition).

# `get_definition`

```elixir
@spec get_definition(KapsoEx.Client.t(), String.t()) :: result()
```

Gets the workflow with its editor definition (nodes and edges).

# `get_variables`

```elixir
@spec get_variables(KapsoEx.Client.t(), String.t()) :: result()
```

Gets the system variables and the variables discovered from past executions.

# `list`

```elixir
@spec list(KapsoEx.Client.t(), map() | keyword()) :: result()
```

Lists workflows, newest first.

Params: `status`, `name_contains`, `created_after`, `created_before`.

# `update`

```elixir
@spec update(KapsoEx.Client.t(), String.t(), map() | keyword()) :: result()
```

Updates a workflow. Attributes: `name`, `slug`, `description`, `status`
(`"draft"`, `"active"`, `"archived"`), `message_debounce_seconds`,
`inbound_message_read_mode`, `definition`, and `lock_version` for
optimistic locking.

    Workflows.update(client, workflow_id, status: "active")

---

*Consult [api-reference.md](api-reference.md) for complete listing*
