Lingo.Api.Interaction (Lingo v0.4.2)

Copy Markdown View Source

Interaction responses and follow-ups.

Inside a bot, Lingo.Context answers interactions for you; these are for answering them by hand, with the interaction's id and token.

Summary

Types

What an interaction response did, from with_response: true. interaction holds the interaction's id and type (as in Lingo.Type.Interaction) and the response's ids and state; resource what it created: its type (as create_response/5 takes it) and the message sent or the activity_instance launched (%{id: instance_id}).

Functions

Sends a follow-up message to an interaction.

Responds to an interaction. type is one of :channel_message, :deferred_channel_message, :deferred_update_message, :update_message, :autocomplete, :modal, :launch_activity or :pong. With with_response: true it returns what the response did (see callback_response/0).

Deletes a follow-up message.

Deletes the first response to an interaction.

Fetches a follow-up message.

Fetches the first response to an interaction.

Edits the first response to an interaction.

Types

callback_response()

@type callback_response() :: %{
  interaction: %{
    id: Lingo.Api.id(),
    type: Lingo.Type.Interaction.interaction_type() | integer(),
    activity_instance_id: String.t() | nil,
    response_message_id: Lingo.Api.id() | nil,
    response_message_loading: boolean() | nil,
    response_message_ephemeral: boolean() | nil
  },
  resource:
    %{
      type: atom() | integer(),
      activity_instance: %{id: String.t()} | nil,
      message: Lingo.Type.Message.t() | nil
    }
    | nil
}

What an interaction response did, from with_response: true. interaction holds the interaction's id and type (as in Lingo.Type.Interaction) and the response's ids and state; resource what it created: its type (as create_response/5 takes it) and the message sent or the activity_instance launched (%{id: instance_id}).

Functions

create_followup(interaction_token, params)

Sends a follow-up message to an interaction.

create_response(interaction_id, interaction_token, type, data \\ nil, opts \\ [])

@spec create_response(Lingo.Api.id(), String.t(), atom(), map() | nil, keyword()) ::
  Lingo.Api.result() | Lingo.Api.result(callback_response())

Responds to an interaction. type is one of :channel_message, :deferred_channel_message, :deferred_update_message, :update_message, :autocomplete, :modal, :launch_activity or :pong. With with_response: true it returns what the response did (see callback_response/0).

delete_followup(interaction_token, message_id)

@spec delete_followup(String.t(), Lingo.Api.id()) :: Lingo.Api.result()

Deletes a follow-up message.

delete_original_response(interaction_token)

@spec delete_original_response(String.t()) :: Lingo.Api.result()

Deletes the first response to an interaction.

get_followup(interaction_token, message_id)

Fetches a follow-up message.

get_original_response(interaction_token)

@spec get_original_response(String.t()) :: Lingo.Api.result(Lingo.Type.Message.t())

Fetches the first response to an interaction.

update_followup(interaction_token, message_id, params)

Edits a follow-up message.

update_original_response(interaction_token, params)

@spec update_original_response(String.t(), Lingo.Api.content()) ::
  Lingo.Api.result(Lingo.Type.Message.t())

Edits the first response to an interaction.