# `Noizu.Discord.Interactions`
[🔗](https://github.com/noizu-labs-sdks/elixir-discord/blob/v0.1.0/lib/noizu/discord/interactions.ex#L1)

HTTP interactions (slash commands, components) — signature verification and
callback responses. REST-only: interactions arrive at your HTTP endpoint, not via
the gateway.

Discord signs each request with Ed25519 over `timestamp <> raw_body`, sending
`X-Signature-Ed25519` (hex) and `X-Signature-Timestamp`. Verify against the
**raw** request body before decoding JSON, and answer `PING` (type 1) with
`respond(id, token, :pong)` — or directly in the HTTP response body
(`%{type: 1}`).

# `response`

```elixir
@type response() ::
  :pong
  | {:message, map()}
  | {:deferred, map()}
  | %{:type =&gt; pos_integer(), optional(:data) =&gt; map()}
  | %{required(String.t()) =&gt; term()}
```

# `build_response`

```elixir
@spec build_response(response()) :: map()
```

Builds the callback JSON body for `respond/4`.

# `respond`

```elixir
@spec respond(String.t(), String.t(), response(), keyword()) ::
  Noizu.Discord.Request.result()
```

POST /interactions/{interaction.id}/{interaction.token}/callback — respond to an
interaction (no bot token needed).

`response` is one of:
  * `:pong` — type 1 (PONG).
  * `{:message, data}` — type 4 (CHANNEL_MESSAGE_WITH_SOURCE); `data` = message params.
  * `{:deferred, data}` — type 5 (DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE); `data`
    may be `%{}` or `%{flags: 64}` for ephemeral.
  * a raw map `%{type: t, data: d}` for any other callback type.

Opts: `:client` (base_url/req_options/retry source, token unused), or `:base_url` /
`:req_options` / `:retry`; `:with_response` (query flag); `:meta`.

# `verify_signature`

```elixir
@spec verify_signature(String.t(), String.t(), String.t(), iodata()) :: boolean()
```

Verifies an interaction request signature. Returns `true` only for a valid
Ed25519 signature; malformed hex or keys return `false` (never raise).

---

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