Come gestire i reparti WhatsApp con C NET

27 febbraio 2025

La comunicazione efficiente è fondamentale per ogni azienda, e con la funzionalità Departments di Wassenger’s puoi organizzare i membri del team per specialità, assicurando che le chat vengano assegnate alle persone giuste senza sforzo. 🚀

In questa guida ti mostreremo come usare C# e l'API di Wassenger per:

  1. Recuperare i reparti del team
  2. Creare un nuovo reparto
  3. Aggiornare un reparto
  4. Eliminare un reparto
  5. Assegnare le chat ai reparti

🤩 🤖 Wassenger è una soluzione API completa per WhatsApp. Iscriviti per una prova gratuita di 7 giorni e inizia in pochi minuti!

Perché usare i Departments in Wassenger? 🤔

Con i Departments, puoi:

Organizzare il tuo team — Raggruppa i membri del team per funzione o competenza.
Migliorare il routing delle chat — Assegna automaticamente le chat in arrivo al reparto o all'utente giusto.
Aumentare l'efficienza — Riduci i tempi di risposta inviando le chat direttamente a chi è più adatto a gestirle.
Integrazione trasparente con i ruoli del team — Funziona insieme ai ruoli di amministratore, supervisore e agente senza modificare le loro autorizzazioni predefinite.

🔗 Vuoi saperne di più sui Departments? Consulta la guida completa qui

Requisiti

  1. Usando l'API, interroga i reparti disponibili nel tuo dispositivo con questo endpoint.

1. GET Departments con C# (.NET)

URL API di destinazione usando il metodo GET

http://api.wassenger.com/v1/devices/{device_id}/departments

Header HTTPS richiesti > Ottieni la tua API key qui

Content-Type: application/json
Token: $API_TOKEN

Recupera i reparti

  • C# (RestClient)
// This code requires you to have installed RestSharp package.
// Documentation: https://restsharp.dev
// Installation: https://www.nuget.org/packages/RestSharp
var client = new RestClient("https://api.wassenger.com/v1/devices/%7Bdevice_id%7D/departments");
var request = new RestRequest(Method.GET);
request.AddHeader("Token", "API TOKEN GOES HERE");
IRestResponse response = client.Execute(request);
  • C# (HttpClient)
// This code uses the built-in HttpClient package in the.NET framework.
// Documentation: https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient?view=net-6.0
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Get, 
RequestUri = new Uri("https://api.wassenger.com/v1/devices/%7Bdevice_id%7D/departments"), 
Headers =
{
{ "Token", "API TOKEN GOES HERE" }, 
}, 
};
using(var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}

2. CREATE un nuovo reparto con C# (.NET)

URL API di destinazione usando il metodo POST

http://api.wassenger.com/v1/devices/{device_id}/departments

Header HTTPS richiesti > Ottieni la tua API key qui

Content-Type: application/json
Token: $API_TOKEN

Crea reparto

{{AGENT_ID}} : Sostituisci questa espressione con il valore specifico

  • C# (RestClient)
// This code requires you to have installed RestSharp package.
// Documentation: https://restsharp.dev
// Installation: https://www.nuget.org/packages/RestSharp
var client = new RestClient("https://api.wassenger.com/v1/devices/{device_id}/departments");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Token", "API TOKEN GOES HERE");
request.AddParameter("application/json", "{\"name\":\"Sales\", \"color\":\"orange\", \"description\":\"Department for the Sales team\", \"agents\":[\"{{AGENT_ID}}\"]}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
  • C# (HttpClient)
// This code uses the built-in HttpClient package in the.NET framework.
// Documentation: https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient?view=net-6.0
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Post, 
RequestUri = new Uri("https://api.wassenger.com/v1/devices/{device_id}/departments"), 
Headers =
{
{ "Token", "API TOKEN GOES HERE" }, 
}, 
Content = new StringContent("{\"name\":\"Sales\", \"color\":\"orange\", \"description\":\"Department for the Sales team\", \"agents\":[\"{{AGENT_ID}}\"]}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using(var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}

🤩 🤖 Wassenger è una soluzione API completa per WhatsApp. Iscriviti per una prova gratuita di 7 giorni e inizia in pochi minuti!

3. UPDATE un reparto con C# (.NET)

URL API di destinazione usando il metodo PATCH

http://api.wassenger.com/v1/devices/{device_id}/departments

Header HTTPS richiesti > Ottieni la tua API key qui

Content-Type: application/json
Token: $API_TOKEN

Aggiorna reparto

{{DEPARTMENT_ID}} : Sostituisci questa espressione con il valore specifico

{{AGENT_ID}} : Sostituisci questa espressione con il valore specifico

  • C# (RestClient)
// This code requires you to have installed RestSharp package.
// Documentation: https://restsharp.dev
// Installation: https://www.nuget.org/packages/RestSharp
var client = new RestClient("https://api.wassenger.com/v1/devices/{device_id}/departments");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Token", "API TOKEN GOES HERE");
request.AddParameter("application/json", "{\"department\":\"{{DEPARTMENT_ID}}\", \"name\":\"Marketing\", \"color\":\"purple\", \"description\":\"Department for the Marketing team\", \"agents\":[\"{{AGENT_ID}}\"]}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
  • C# (HttpClient)
// This code uses the built-in HttpClient package in the.NET framework.
// Documentation: https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient?view=net-6.0
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Patch, 
RequestUri = new Uri("https://api.wassenger.com/v1/devices/{device_id}/departments"), 
Headers =
{
{ "Token", "API TOKEN GOES HERE" }, 
}, 
Content = new StringContent("{\"department\":\"{{DEPARTMENT_ID}}\", \"name\":\"Marketing\", \"color\":\"purple\", \"description\":\"Department for the Marketing team\", \"agents\":[\"{{AGENT_ID}}\"]}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using(var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}

4. DELETE un reparto con C# (.NET)

URL API di destinazione usando il metodo DELETE

http://api.wassenger.com/v1/devices/{device_id}/departments

Header HTTPS richiesti > Ottieni la tua API key qui

Content-Type: application/json
Token: $API_TOKEN

Elimina reparto

{{DEPARTMENT_ID}} : Sostituisci questa espressione con il valore specifico

  • C# (RestClient)
// This code requires you to have installed RestSharp package.
// Documentation: https://restsharp.dev
// Installation: https://www.nuget.org/packages/RestSharp
var client = new RestClient("https://api.wassenger.com/v1/devices/{device_id}/departments");
var request = new RestRequest(Method.DELETE);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Token", "API TOKEN GOES HERE");
request.AddParameter("application/json", "{\"department\":\"{{DEPARTMENT_ID}}\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
  • C# (HttpClient)
// This code uses the built-in HttpClient package in the.NET framework.
// Documentation: https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient?view=net-6.0
using System.Net.Http.Headers;
var client = new HttpClient();
var request = new HttpRequestMessage
{
Method = HttpMethod.Delete, 
RequestUri = new Uri("https://api.wassenger.com/v1/devices/{device_id}/departments"), 
Headers =
{
{ "Token", "API TOKEN GOES HERE" }, 
}, 
Content = new StringContent("{\"department\":\"{{DEPARTMENT_ID}}\"}")
{
Headers =
{
ContentType = new MediaTypeHeaderValue("application/json")
}
}
};
using(var response = await client.SendAsync(request))
{
response.EnsureSuccessStatusCode();
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine(body);
}

🤩 🤖 Wassenger è una piattaforma di comunicazione completa e una soluzione API per WhatsApp. Esplora oltre 100 casi d'uso API e automatizza qualsiasi cosa su WhatsApp *iscrivendoti per una prova gratuita e iniziando in pochi minuti!***

Test live per inviare un messaggio a un gruppo via API

Prova il nostro tester API-Live ora!

Gestire i reparti con l'API di Wassenger in C# permette alle aziende di semplificare l'assegnazione delle chat, migliorare l'efficienza e mantenere le conversazioni organizzate senza problemi.

📌 Smetti di gestire manualmente le assegnazioni delle chat! Automatizza, ottimizza e scala il tuo business senza sforzo con Wassenger. Inizia la tua prova gratuita ora!

Ready to transform your WhatsApp communication?

Start automating your customer interactions today with Wassenger

Get Started Free