# `KapsoEx.WhatsApp.Conversations`
[🔗](https://github.com/rocket4ce/kapso_ex/blob/v0.1.0/lib/kapso_ex/whatsapp/conversations.ex#L1)

Conversations stored by Kapso for a phone number, plus thread control on
[shared numbers](https://docs.kapso.ai/docs/whatsapp/conversation-routing).

For project-wide queries, assignments and status changes see
`KapsoEx.Platform.Conversations`.

# `result`

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

# `get`

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

Gets a conversation. Params: `fields`.

# `list`

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

Lists conversations, latest activity first.

Params: `status` (`"active"`/`"ended"`), `assigned_user_id`, `unassigned`,
`last_active_since`, `last_active_until`, `phone_number`, `limit`,
`before`, `after`, `fields`.

# `thread_control`

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

Passes, releases or takes a conversation between apps on a shared number.

`action` is `"pass"`, `"release"` or `"take"`. `to` is a phone number or a
map with `:to` / `:recipient`.

## Options

  * `:target_role` - for `"pass"`: `"escalation"`, `"ai_agent"`,
    `"customer_service"`, `"marketing"`, `"utility"` or `"ctwa"`.
  * `:metadata` - string (up to 2000 chars) passed to the receiving app.

A `502` means the outcome is unknown; Kapso never retries it.

    Conversations.thread_control(client, phone_number_id, "15551234567", "pass",
      target_role: "escalation", metadata: "Customer asked for a human")

---

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