User conversations
Link Askocto conversations to your own users with userId, list the conversations of one user and delete them all when asked.
Working draft. These docs are illustrative: names, endpoints and examples describe the intended behaviour and can change before launch.
A user is a person on your side, identified by a userId that starts with usr_. When you send the same userId with every chat request, all conversations of that person are grouped together. That gives you two things: a history you can show in your app, and one place to find or remove everything a person said.
Attach a user to a conversation
Pass userId in the body of Chat with an agent:
{
"messages": [{ "role": "user", "content": "Where is my order?" }],
"userId": "usr_3b6t0z"
}
Use a stable value for each person, such as the ID of the account in your own database with the usr_ prefix. Do not reuse one userId for several people.
List the conversations of a user
List conversations for a user returns a page of conversation objects, newest first:
curl "https://api.askocto.co/v2/agents/agt_8f3k2m/users/usr_3b6t0z/conversations?limit=10" \
-H "Authorization: Bearer $OCTO_API_KEY"
const response = await fetch(
"https://api.askocto.co/v2/agents/agt_8f3k2m/users/usr_3b6t0z/conversations?limit=10",
{ headers: { Authorization: `Bearer ${process.env.OCTO_API_KEY}` } },
)
const { data, nextCursor } = await response.json()
console.log(`${data.length} conversations`, nextCursor)
The response uses the usual envelope with data and nextCursor, see Pagination. Each item has id, agentId, userId, channel, status, messageCount, createdAt and updatedAt. To show the text of one conversation in your app, call List conversation messages with its id.
Delete all conversations of a user
Delete all conversations for a user removes every conversation of the userId for this agent:
curl -X DELETE https://api.askocto.co/v2/agents/agt_8f3k2m/users/usr_3b6t0z/conversations \
-H "Authorization: Bearer $OCTO_API_KEY"
{
"userId": "usr_3b6t0z",
"deletedCount": 3
}
Deleting cannot be undone. List the conversations first if you want to keep a copy, or export them with Export conversations.
Use this call as one step when you honor a request from a person to remove their data. Whether a request is valid, and what else you must delete, is a question for your own advisers. This page is not legal advice.
Things to keep in mind
- The deletion applies to one agent. If the person talked to several agents, call the endpoint for each of them.
- A user without any conversation returns an empty
dataarray when you list, not an error. - To confirm that a person is who they say they are on a website, use identity verification rather than trusting a
userIdsent from the browser.