Une communication efficace est essentielle pour toute entreprise, et avec la fonctionnalité Départements de Wassenger, vous pouvez organiser les membres de votre équipe par spécialité, en veillant à ce que les conversations soient attribuées aux bonnes personnes sans effort. 🚀
Dans ce guide, nous vous montrons comment utiliser PHP et l'API Wassenger pour :
- Obtenir les départements d'équipe
- Créer un nouveau département
- Mettre à jour un département
- Supprimer un département
- Affecter des chats aux départements
🤩 🤖 Wassenger est une solution API complète pour WhatsApp. Inscrivez-vous pour un essai gratuit de 7 jours et commencez en quelques minutes !
Pourquoi utiliser les départements dans Wassenger ? 🤔
Avec les Départements, vous pouvez :
✅ Organiser votre équipe — Regrouper les membres par fonction ou expertise.
✅ Améliorer le routage des chats — Affecter automatiquement les chats entrants au bon département ou utilisateur.
✅ Accroître l'efficacité — Réduire le temps de réponse en envoyant les chats directement aux personnes les mieux placées pour y répondre.
✅ S'intégrer parfaitement aux rôles d'équipe — Fonctionne avec les rôles admin, superviseur et agent sans modifier leurs permissions par défaut.
🔗 Vous voulez en savoir plus sur les Départements ? Consultez le guide complet ici
Prérequis
- Avoir un numéro WhatsApp déjà lié à la plateforme et en ligne.
- En utilisant l'API, interrogez les départements disponibles sur votre appareil via cet endpoint.
1. Obtenir les départements avec PHP
URL cible de l'API en utilisant la méthode GET
http://api.wassenger.com/v1/devices/{device_id}/departments
En-têtes HTTPS requis > Obtenez votre clé API ici
Content-Type: application/json
Token: $API_TOKEN
Récupérer les départements
Récupérer les départements avec PHP (Guzzle)
// This code example requires to have installed Guzzle package, a flexible and elegant HTTP client for PHP.
// Install it first following these instructions:
// https://docs.guzzlephp.org/en/stable/overview.html#installation
<?php
$client = new \GuzzleHttp\Client();
$response = $client->request(
'GET',
'https://api.wassenger.com/v1/devices/device.id/departments',
[
'headers' => [
'Token' => 'ENTER API KEY HERE',
],
]
);
echo $response->getBody();
Récupérer les départements avec PHP (http2)
// This code example requires to have installed pecl_http package, a simple and elegant HTTP client for PHP.
// Install it by running: pecl install pecl_http
// More information: https://mdref.m6w6.name/http
<?php
$client = new http\Client();
$request = new http\Client\Request();
$request->setRequestUrl(
'https://api.wassenger.com/v1/devices/device.id/departments'
);
$request->setRequestMethod('GET');
$request->setHeaders([
'Token' => 'ENTER API KEY HERE',
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
Récupérer les départements avec PHP (curl)
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.wassenger.com/v1/devices/{{device.id}}/departments',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => ['Token: ENTER API KEY HERE'],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo 'cURL Error #:' . $err;
} else {
echo $response;
}
2. CRÉER un nouveau département avec PHP
URL cible de l'API en utilisant la méthode POST
http://api.wassenger.com/v1/devices/{device_id}/departments
En-têtes HTTPS requis > Obtenez votre clé API ici
Content-Type: application/json
Token: $API_TOKEN
Créer un département
{{AGENT_ID}} : Remplacez cette expression par la valeur spécifique
Créer un département avec PHP (Guzzle)
// This code example requires to have installed Guzzle package, a flexible and elegant HTTP client for PHP.
// Install it first following these instructions:
// https://docs.guzzlephp.org/en/stable/overview.html#installation
<?php
$client = new \GuzzleHttp\Client();
$response = $client->request(
'POST',
'https://api.wassenger.com/v1/devices/device.id/departments',
[
'body' =>
'{"name":"Sales", "color":"orange", "description":"Department for the Sales team", "agents":["{{AGENT_ID}}"]}',
'headers' => [
'Content-Type' => 'application/json',
'Token' => 'ENTER API KEY HERE',
],
]
);
echo $response->getBody();
Créer un département avec PHP (http2)
// This code example requires to have installed pecl_http package, a simple and elegant HTTP client for PHP.
// Install it by running: pecl install pecl_http
// More information: https://mdref.m6w6.name/http
<?php
$client = new http\Client();
$request = new http\Client\Request();
$body = new http\Message\Body();
$body->append(
json_encode([
'name' => 'Sales',
'color' => 'orange',
'description' => 'Department for the Sales team',
'agents' => ['{{AGENT_ID}}'],
])
);
$request->setRequestUrl(
'https://api.wassenger.com/v1/devices/device.id/departments'
);
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders([
'Content-Type' => 'application/json',
'Token' => 'ENTER API KEY HERE',
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
Créer un département avec PHP (curl)
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.wassenger.com/v1/devices/{{device.id}}/departments',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Sales',
'color' => 'orange',
'description' => 'Department for the Sales team',
'agents' => ['{{AGENT_ID}}'],
]),
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'Token: ENTER API KEY HERE',
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo 'cURL Error #:' . $err;
} else {
echo $response;
}
🤩 🤖 Wassenger est une solution API complète pour WhatsApp. Inscrivez-vous pour un essai gratuit de 7 jours et commencez en quelques minutes !
3. METTRE À JOUR un département avec PHP
URL cible de l'API en utilisant la méthode PATCH
http://api.wassenger.com/v1/devices/{device_id}/departments
En-têtes HTTPS requis > Obtenez votre clé API ici
Content-Type: application/json
Token: $API_TOKEN
Mettre à jour un département
{{DEPARTMENT_ID}} : Remplacez cette expression par la valeur spécifique
{{AGENT_ID}} : Remplacez cette expression par la valeur spécifique
Mettre à jour un département avec PHP (Guzzle)
// This code example requires to have installed Guzzle package, a flexible and elegant HTTP client for PHP.
// Install it first following these instructions:
// https://docs.guzzlephp.org/en/stable/overview.html#installation
<?php
$client = new \GuzzleHttp\Client();
$response = $client->request('PATCH', 'https://api.wassenger.com/v1/team', [
'body' =>
'{"department":"{{DEPARTMENT_ID}}", "name":"Marketing", "color":"purple", "description":"Department for the Marketing team", "agents":["{{AGENT_ID}}"]}',
'headers' => [
'Content-Type' => 'application/json',
'Token' => 'ENTER API KEY HERE',
],
]);
echo $response->getBody();
Mettre à jour un département avec PHP (http2)
// This code example requires to have installed pecl_http package, a simple and elegant HTTP client for PHP.
// Install it by running: pecl install pecl_http
// More information: https://mdref.m6w6.name/http
<?php
$client = new http\Client();
$request = new http\Client\Request();
$body = new http\Message\Body();
$body->append(
json_encode([
'department' => '{{DEPARTMENT_ID}}',
'name' => 'Marketing',
'color' => 'purple',
'description' => 'Department for the Marketing team',
'agents' => ['{{AGENT_ID}}'],
])
);
$request->setRequestUrl('https://api.wassenger.com/v1/team');
$request->setRequestMethod('PATCH');
$request->setBody($body);
$request->setHeaders([
'Content-Type' => 'application/json',
'Token' => 'ENTER API KEY HERE',
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
Mettre à jour un département avec PHP (curl)
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.wassenger.com/v1/team',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'PATCH',
CURLOPT_POSTFIELDS => json_encode([
'department' => '{{DEPARTMENT_ID}}',
'name' => 'Marketing',
'color' => 'purple',
'description' => 'Department for the Marketing team',
'agents' => ['{{AGENT_ID}}'],
]),
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'Token: ENTER API KEY HERE',
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo 'cURL Error #:' . $err;
} else {
echo $response;
}
4. SUPPRIMER un département avec PHP
URL cible de l'API en utilisant la méthode DELETE
http://api.wassenger.com/v1/devices/{device_id}/departments
En-têtes HTTPS requis > Obtenez votre clé API ici
Content-Type: application/json
Token: $API_TOKEN
Supprimer un département
{{DEPARTMENT_ID}} : Remplacez cette expression par la valeur spécifique
Supprimer un département avec PHP (Guzzle)
// This code example requires to have installed Guzzle package, a flexible and elegant HTTP client for PHP.
// Install it first following these instructions:
// https://docs.guzzlephp.org/en/stable/overview.html#installation
<?php
$client = new \GuzzleHttp\Client();
$response = $client->request(
'DELETE',
'https://api.wassenger.com/v1/devices/device.id/departments',
[
'body' => '{"department":"{{DEPARTMENT_ID}}"}',
'headers' => [
'Content-Type' => 'application/json',
'Token' => 'ENTER API KEY HERE',
],
]
);
echo $response->getBody();
Supprimer un département avec PHP (http2)
// This code example requires to have installed pecl_http package, a simple and elegant HTTP client for PHP.
// Install it by running: pecl install pecl_http
// More information: https://mdref.m6w6.name/http
<?php
$client = new http\Client();
$request = new http\Client\Request();
$body = new http\Message\Body();
$body->append(
json_encode([
'department' => '{{DEPARTMENT_ID}}',
])
);
$request->setRequestUrl(
'https://api.wassenger.com/v1/devices/device.id/departments'
);
$request->setRequestMethod('DELETE');
$request->setBody($body);
$request->setHeaders([
'Content-Type' => 'application/json',
'Token' => 'ENTER API KEY HERE',
]);
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
Supprimer un département avec PHP (curl)
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.wassenger.com/v1/devices/{{device.id}}/departments',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_POSTFIELDS => json_encode([
'department' => '{{DEPARTMENT_ID}}',
]),
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'Token: ENTER API KEY HERE',
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo 'cURL Error #:' . $err;
} else {
echo $response;
}
🤩 🤖 Wassenger est une plateforme de communication complète et une solution API pour WhatsApp. Explorez plus de 100 cas d'utilisation API et automatisez tout sur WhatsApp en vous inscrivant pour un essai gratuit et en commençant en quelques minutes!
Test en direct pour envoyer un message à un groupe via l'API
Essayez notre testeur API en direct maintenant !
Gérer les départements avec l'API Wassenger en PHP permet aux entreprises de rationaliser l'affectation des chats, d'améliorer l'efficacité et de garder les conversations organisées sans tracas.
📌 Arrêtez de jongler manuellement avec les affectations de chats ! Automatisez, optimisez et développez votre entreprise sans effort avec Wassenger. Commencez votre essai gratuit dès maintenant !







