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

Canaux (IA)

Canaux de diffusion IA via @ziwako/ai — CRUD, activation et plateformes.

La ressource Channels du package @ziwako/ai gère les canaux de diffusion des agents IA (WhatsApp, Telegram, Slack, ...) : CRUD, activation/désactivation et liste des plateformes supportées.

  • Factory : getChannels() (@ziwako/ai/axios)
  • Types : Channel, ChannelResponse, ChannelListResponse, CreateChannelBody, UpdateChannelBody, ListChannelParams
  • Endpoints : POST /channels, GET /channels, GET /channels/{id}, DELETE /channels/{id}, PATCH /channels/{id}, POST /channels/{id}/activate, POST /channels/{id}/deactivate, GET /channels/platforms
import { configure, getChannels } from '@ziwako/ai/axios';
configure({ accessToken: '...' });
const channels = getChannels();

createChannel

Crée un canal de diffusion pour un agent. Le corps est requis.

Signature : createChannel(createChannelBody: CreateChannelBody) → Promise<ChannelResponse>

const response = await channels.createChannel({
    name: 'WhatsApp boutique',
    platform: 'whatsapp',
    agentId: '64b8f2...',
    config: { phoneNumber: '+243990000000' },
});
console.log(response.data?.id);
import { useCreateChannel } from '@ziwako/ai/react-query';

const mutation = useCreateChannel();
mutation.mutate({
    data: { name: 'WhatsApp boutique', platform: 'whatsapp', agentId: '64b8f2...' },
});

listChannel

Liste paginée des canaux.

Signature : listChannel(params?: ListChannelParams) → Promise<ChannelListResponse>

const list = await channels.listChannel({ page: 1, limit: 20, filter: { agentId: agentId } });
console.log(list.data?.docs);
import { useListChannel } from '@ziwako/ai/react-query';

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

getChannel

Récupère un canal par son id.

Signature : getChannel(id: string) → Promise<ChannelResponse>

const response = await channels.getChannel('64b8f2...');
console.log(response.data?.name, response.data?.status);
import { useGetChannel } from '@ziwako/ai/react-query';

const { data } = useGetChannel(channelId, { query: { enabled: !!channelId } });

deleteChannel

Supprime un canal.

Signature : deleteChannel(id: string) → Promise<DeleteChannel200>

await channels.deleteChannel(channelId);
import { useDeleteChannel } from '@ziwako/ai/react-query';

const mutation = useDeleteChannel();
mutation.mutate({ id: channelId });

updateChannel

Met à jour un canal (config, nom...).

Signature : updateChannel(id: string, updateChannelBody: UpdateChannelBody) → Promise<ChannelResponse>

await channels.updateChannel(channelId, { config: { phoneNumber: '+243991111111' } });
import { useUpdateChannel } from '@ziwako/ai/react-query';

const mutation = useUpdateChannel();
mutation.mutate({ id: channelId, data: { config: { phoneNumber: '+243991111111' } } });

activateChannel

Active un canal (le rend réceptif aux messages).

Signature : activateChannel(id: string) → Promise<ChannelResponse>

await channels.activateChannel(channelId);
import { useActivateChannel } from '@ziwako/ai/react-query';

const mutation = useActivateChannel();
mutation.mutate({ id: channelId });

desactivateChannel

Désactive un canal.

Signature : desactivateChannel(id: string) → Promise<ChannelResponse>

await channels.desactivateChannel(channelId);
import { useDesactivateChannel } from '@ziwako/ai/react-query';

const mutation = useDesactivateChannel();
mutation.mutate({ id: channelId });

listPlatforms

Liste les plateformes supportées (WhatsApp, Telegram, ...).

Signature : listPlatforms() → Promise<ListPlatforms200>

const platforms = await channels.listPlatforms();
console.log(platforms.data);
import { useListPlatforms } from '@ziwako/ai/react-query';

const { data } = useListPlatforms();