Skip to main content

Conversations & sessions

Conversations (with their events and session variables) and the standalone call/automation session store. Available as mgr.conversations / mgr.Conversations / mgr.conversations and mgr.sessions / mgr.Sessions / mgr.sessions.

Conversations

for await (const c of mgr.conversations.list()) console.log(c.id);
const created = await mgr.conversations.create({ /* RestCreateConversationBody */ });
await mgr.conversations.update(created.item.id, { /* RestUpdateConversationBody */ });
await mgr.conversations.delete(created.item.id);

Events & session variables

const events = await mgr.conversations.events(conversationId);

const session = await mgr.conversations.getSession(conversationId);
await mgr.conversations.updateSession(conversationId, { /* ConversationSessionVariables */ });

Append events, open/close & event timeline

Append a custom event, open or close a conversation, fetch its first/latest event, or page the global event stream across all conversations.

await mgr.conversations.addEvent(conversationId, { /* ConversationEventRequest */ });
await mgr.conversations.open(conversationId);
await mgr.conversations.close(conversationId);
const first = await mgr.conversations.firstEvent(conversationId);
const latest = await mgr.conversations.latestEvent(conversationId);
for await (const e of mgr.conversations.allEvents()) console.log(e.id);

Sessions

The standalone session store at /api/v2/sessions.

const created = await mgr.sessions.create();
const session = await mgr.sessions.get(sessionId);
await mgr.sessions.updateVariables(sessionId, { /* UpdateSessionVariablesRequest */ });

Reference