Ziwako Docs
Ziwako AI (Mayele)Guide développeurSDK @ziwako/ai

Conversations

Conversations avec les agents IA via @ziwako/ai — CRUD.

La ressource Conversations gère les conversations entre un utilisateur et un agent Mayele : création, lecture, mise à jour et suppression. Chaque conversation est rattachée à un agent (agentId) et à un propriétaire.

  • Factory : getConversations() (@ziwako/ai/axios)
  • Types : Conversation, ConversationResponse, ConversationListResponse, CreateConversationBody, UpdateConversationBody, ListeConversationsParams
  • Endpoints : PATCH /agents/{id} (mise à jour liée à l'agent), GET /conversations, POST /conversations, GET /conversations/{id}, DELETE /conversations/{id}
import { configure, getConversations } from '@ziwako/ai/axios';
configure({ accessToken: '...' });
const conversations = getConversations();

createConversation

Crée une conversation avec un agent. Le corps est requis.

Signature : createConversation(createConversationBody: CreateConversationBody) → Promise<ConversationResponse>

const response = await conversations.createConversation({
    agentId: '64b8f2...',
    ownerId: profilId,
    title: 'Demande de devis',
});
console.log(response.data?.id);
import { useCreateConversation } from '@ziwako/ai/react-query';

const mutation = useCreateConversation();
mutation.mutate({ data: { agentId: '64b8f2...', ownerId: profilId, title: 'Demande de devis' } });

listeConversations

Liste paginée des conversations.

Signature : listeConversations(params?: ListeConversationsParams) → Promise<ConversationListResponse>

const list = await conversations.listeConversations({ page: 1, limit: 20, filter: { ownerId: profilId } });
console.log(list.data?.docs);
import { useListeConversations } from '@ziwako/ai/react-query';

const { data } = useListeConversations({ page: 1, limit: 20 });

getConversation

Récupère une conversation par son id (y compris son historique de messages).

Signature : getConversation(id: string) → Promise<ConversationResponse>

const response = await conversations.getConversation('64b8f2...');
console.log(response.data?.title, response.data?.messages);
import { useGetConversation } from '@ziwako/ai/react-query';

const { data } = useGetConversation(conversationId, { query: { enabled: !!conversationId } });

updateConversation

Met à jour une conversation (titre, contexte...). Note : le SDK généré route cet appel vers PATCH /agents/{id}.

Signature : updateConversation(id: string, updateConversationBody: UpdateConversationBody) → Promise<ConversationResponse>

await conversations.updateConversation(conversationId, {
    title: 'Demande de devis — suivi',
});
import { useUpdateConversation } from '@ziwako/ai/react-query';

const mutation = useUpdateConversation();
mutation.mutate({ id: conversationId, data: { title: 'Demande de devis — suivi' } });

deleteConversation

Supprime une conversation.

Signature : deleteConversation(id: string) → Promise<DeleteConversation200>

await conversations.deleteConversation(conversationId);
import { useDeleteConversation } from '@ziwako/ai/react-query';

const mutation = useDeleteConversation();
mutation.mutate({ id: conversationId });