Conversations

A conversation is one thread of one contact on one channel: WhatsApp, Instagram, Facebook, email, web chat or a chat created through the Chat API. Its messages are read apart, page by page, and never include system events.

This reference documents Conversations V2 (/v2/conversations). Every V2 action answers the conversation as it is afterwards, says whether anything changed, and is safe to repeat.

Comment threads on Instagram and Facebook posts are not conversations: they have their own resource, Posts.

Example

const page = await platic.conversations.list({
  status: ["active"],
  operation: ["supervised"],
  include: ["agents"],
});

const first = page.data[0];
if (first) {
  const messages = await platic.conversations.messages.list(first.id, { limit: 20 });
  for (const message of messages.data) console.log(message.sender?.type, message.content);
}

What you need to know

  • One workspace per call. A credential acts on its workspace; an API key that covers several sends ?workspace=.
  • One ID. id is always the conversation's ID. V2 never accepts a phone number or the old V1 conversationId key.
  • You choose the fields. fields replaces the default fields and include resolves agents, channels, assignees or message authors once per response in included. Unknown names answer 400; nothing is ignored silently.
  • The history is separate. Get a conversation does not return messages. List messages pages through them.
  • Lists use tokens. Send nextPageToken as pageToken until it is null. A page can be short, or empty, and still have a token. See Pagination.
  • You only see what you may read. A conversation out of reach answers 404, like one that does not exist. See Who sees what.

Endpoints

Read

MethodEndpointDescription
GET/v2/conversationsList conversations with filters, sorting and field selection
POST/v2/conversations/searchSearch by words, meaning or both, with filters
GET/v2/conversations/countsExact counts by operation, status, agent or channel
GET/v2/conversations/{conversationId}Get one conversation, without its messages
GET/v2/conversations/{conversationId}/messagesList the visible messages of a conversation
GET/v2/conversations/{conversationId}/messages/{messageId}Get one message

Act

MethodEndpointDescription
PATCH/v2/conversations/{conversationId}Change the topic, or the title of a team chat
PUT/v2/conversations/{conversationId}/tagsReplace the tags of a conversation
PATCH/v2/conversations/{conversationId}/tagsAdd or remove tags
PUT/v2/conversations/{conversationId}/assigneesReplace the team members assigned
PATCH/v2/conversations/{conversationId}/assigneesAdd or remove assignees
POST/v2/conversations/{conversationId}/pausePause the agent so a person handles the conversation
POST/v2/conversations/{conversationId}/resumeGive the conversation back to the agent
POST/v2/conversations/{conversationId}/waitHand it back to the agent on the contact's next message
POST/v2/conversations/{conversationId}/finishFinish a conversation
POST/v2/conversations/{conversationId}/archiveArchive a conversation
POST/v2/conversations/{conversationId}/reopenReopen a conversation
PUT/v2/conversations/{conversationId}/agentChange the main agent
PUT/v2/conversations/{conversationId}/spamMark or unmark a conversation as spam
POST/v2/conversations/bulkRun one action on up to 100 conversations

How IDs work

FieldWhat it identifies
idThe conversation. Use it in every /v2/conversations/{conversationId} call
contactIdThe contact (clients in the API). One contact can have several conversations, on different channels or with different agents
channelIdThe channel the conversation runs on
agentIdThe main agent. A subagent taking a turn does not change it; that one is activeAgentId
legacyConversationKeyThe old V1 conversationId key, a phone number or thread key on some channels. Ask for it in fields for diagnosis only: V2 never accepts it as an ID

A message's id is Platica's own ID, never the provider's. The provider's ID is providerMessageId.

Status and operation

A conversation has two separate dimensions:

  • status is its visible state: initiated, active, finished, archived or spam. spam wins over everything; otherwise a closed conversation is archived; otherwise it is initiated, active or finished. A stored state the API does not recognize comes back as null, with an UNKNOWN_STATUS warning in meta.warnings.
  • operation says who answers: automatic (the agent), supervised (a person) or assistance (the agent asked a person for help).

A supervised conversation is still active. Pausing and resuming change operation; finishing, archiving and reopening change status.

Who sees what

  • An API key reads every conversation in its workspace.
  • An OAuth connection acts as the person who authorized it, with their current permissions. If their role only reaches assigned conversations, they only see conversations assigned to them or to team, in lists, search, counts and included. Any other conversation answers 404 CONVERSATION_NOT_FOUND, exactly like one that does not exist.
  • A permission revoked or an assignment changed applies on the next call, even with a page token in hand.
  • A credential without access to conversations in the workspace gets 403. Reads, including search, work with read-only credentials; actions need write access.