Karta.Messaging.Events (Karta v1.0.0)

The webhook events of the messaging module (Karta.Webhooks.Catalogue's messaging_types/0), sent through Karta's signed deliveries (Karta.Webhooks.emit/2), in the transaction that records what happened. A webhook receives them only when it names them: a webhook with no event list (events: nil, "every type") never gets a messaging event.

  • messaging.message.received - server_id, connector_id, channel, conversation_id, message_id, address, address_kind, display_name, kind, text (left out when the server's webhook_include_body is off, and null for media without a caption), media_id, occurred_at, backfill, external_ref. History imported when a number is first linked is stored and not announced (backfill); messaging.history.imported says it arrived.
  • messaging.message.status - message_id, request_id, attempt_no, channel, connector_id, address, reference, state, final, fallback_from, error_class, error_code, cost, duplicate_possible. The channel used and, where known, the cost are always in it.
  • messaging.connector.connected, .disconnected, .needs_link, .needs_update - server_id, connector_id, name, plug, channel, status, agent_version, reason.
  • messaging.history.imported - server_id, connector_id, account_id, chats, messages, from, to.

Summary

Functions

A connector event: connected, disconnected, needs_link or needs_update.

Records events (a list built lazily) for the server's subscribed webhooks.

messaging.history.imported.

messaging.message.status for a send that turned out to have happened after Karta gave it up (the agent answered a command that had expired): state is sent, late is true and duplicate_possible is true, because Karta may have tried again meanwhile and the customer may get it twice.

messaging.message.received for an inbound message.

messaging.message.status for an outbound message after a change of state.

The text of a message as the API and the events show it: the text, the caption, or nil.

Functions

connector(kind, connector, reason \\ nil)

@spec connector(String.t(), Karta.Messaging.Connector.t(), String.t() | nil) :: map()

A connector event: connected, disconnected, needs_link or needs_update.

emit(server_id, build)

@spec emit(Ecto.UUID.t(), (-> [map()])) :: :ok

Records events (a list built lazily) for the server's subscribed webhooks.

history_imported(connector, event)

@spec history_imported(Karta.Messaging.Connector.t(), map()) :: map()

messaging.history.imported.

late_sent(message, connector, address)

@spec late_sent(
  Karta.Messaging.Message.t(),
  Karta.Messaging.Connector.t(),
  String.t() | nil
) :: map()

messaging.message.status for a send that turned out to have happened after Karta gave it up (the agent answered a command that had expired): state is sent, late is true and duplicate_possible is true, because Karta may have tried again meanwhile and the customer may get it twice.

received(message, conversation, connector)

messaging.message.received for an inbound message.

status(message, connector, address)

messaging.message.status for an outbound message after a change of state.

text(message)

@spec text(Karta.Messaging.Message.t()) :: String.t() | nil

The text of a message as the API and the events show it: the text, the caption, or nil.