ConvergerClient.ClientAPI (converger_client v0.1.0)

Copy Markdown View Source

The client API under /api/v1/converger, authenticated with converger tokens (Authorization: Bearer). Your backend mints tokens with the channel secret (generate_token/2) and hands conversation-bound tokens to end users, or uses them itself (for example with ConvergerClient.Socket).

Summary

Functions

Starts a conversation; the returned token is bound to it.

Exchanges the channel secret for a converger token.

A new conversation-bound token for an existing conversation. Options: :watermark.

Activities after a watermark, oldest first. Options: :watermark (the integer seq or a legacy opaque string, sent as is), :limit.

Exchanges a valid token for a fresh one.

Types

result(t)

@type result(t) :: {:ok, t} | {:error, ConvergerClient.Error.t() | Exception.t()}

Functions

close_conversation(client, token, conversation_id)

@spec close_conversation(ConvergerClient.t(), String.t(), String.t()) ::
  result(ConvergerClient.ConversationStatus.t())

Closes a conversation.

create_conversation(client, token)

@spec create_conversation(ConvergerClient.t(), String.t()) ::
  result(ConvergerClient.ConversationToken.t())

Starts a conversation; the returned token is bound to it.

generate_token(client, opts \\ [])

@spec generate_token(ConvergerClient.t(), keyword()) ::
  result(ConvergerClient.TokenResponse.t())

Exchanges the channel secret for a converger token.

Options: :user_id, :scope (only "channel", for agent sockets).

get_conversation(client, token, conversation_id, opts \\ [])

@spec get_conversation(ConvergerClient.t(), String.t(), String.t(), keyword()) ::
  result(ConvergerClient.ConversationToken.t())

A new conversation-bound token for an existing conversation. Options: :watermark.

list_activities(client, token, conversation_id, opts \\ [])

@spec list_activities(ConvergerClient.t(), String.t(), String.t(), keyword()) ::
  result(ConvergerClient.ClientActivityPage.t())

Activities after a watermark, oldest first. Options: :watermark (the integer seq or a legacy opaque string, sent as is), :limit.

post_activity(client, token, conversation_id, attrs, opts \\ [])

@spec post_activity(
  ConvergerClient.t(),
  String.t(),
  String.t(),
  map() | keyword(),
  keyword()
) ::
  result(ConvergerClient.ResourceResponse.t())

Posts an activity as the end user.

attrs (map or keyword): :type, :text, :from_id, :attachments, :reply_to_id, :channel_data. Options: :idempotency_key.

refresh_token(client, token)

@spec refresh_token(ConvergerClient.t(), String.t()) ::
  result(ConvergerClient.TokenResponse.t())

Exchanges a valid token for a fresh one.

reopen_conversation(client, token, conversation_id)

@spec reopen_conversation(ConvergerClient.t(), String.t(), String.t()) ::
  result(ConvergerClient.ConversationStatus.t())

Reopens a conversation.