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

[Triggers](https://docs.kapso.ai/docs/flows/triggers) start a workflow
automatically: on an inbound message, a WhatsApp event, a project event,
or an API call.

A trigger map has `trigger_type` (`"inbound_message"`, `"api_call"`,
`"whatsapp_event"`, `"project_event"`), `active`, and type specific
fields: `phone_number_id`, `event`, `event_name`, `property_key`,
`operator` and `property_value`.

# `result`

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

# `create`

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

Creates a trigger.

    Triggers.create(client, workflow_id, trigger_type: "inbound_message", phone_number_id: pnid)

# `delete`

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

Deletes a trigger.

# `list`

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

Lists a workflow's triggers.

# `replace`

```elixir
@spec replace(KapsoEx.Client.t(), String.t(), [map()]) :: result()
```

Atomically replaces every trigger of a workflow. If any trigger is
invalid, nothing changes.

# `update`

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

Updates a trigger. Only `active` can be changed.

---

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