Invia messaggi WhatsApp automatici utilizzando C NET La guida definitiva

25 agosto 2025

Oggi ti mostriamo la guida definitiva per inviare diversi tipi di messaggi WhatsApp usando C# (.NET)

La comunicazione efficace è vitale per il coordinamento dei progetti, il coinvolgimento delle community e un supporto clienti reattivo. Wassenger migliora questo processo offrendo strumenti per la gestione e l'interazione senza soluzione di continuità all'interno dei messaggi WhatsApp. Con la sua API intuitiva e le funzionalità di automazione, inviare messaggi, video, immagini, documenti e memo vocali diventa semplice ed efficiente.

In questo articolo troverai:

  • Invia messaggio immagine 🖼️
  • Invia messaggi video 📹
  • Invia messaggi documento 📄
  • Invia registrazione vocale audio 🎙️
  • Invia un messaggio multimediale con un file caricato 📤
  • Invia un messaggio GIF 🎞️
  • Invia un messaggio sondaggio 📊
  • Invia un messaggio programmato con data e ora 📅
  • Invia messaggi con pulsanti nativi dinamici 🔘
  • Invia un elenco di elementi da selezionare 📝
  • Invia un messaggio con formattazione del testo ✍️
  • Invia un messaggio con localizzazione tramite coordinate 📍
  • Invia un messaggio con localizzazione tramite indirizzo 🗺️
  • Invia un messaggio con variabili 🔄
  • Invia messaggi con link 🔗
  • Invia messaggi biglietto da visita 📇
  • Rispondi a un messaggio 💬
  • Inoltra un messaggio 🔁
  • Invia un messaggio catalogo 📒
  • Invia un messaggio in tempo reale senza accodamento ⏱️
  • Invia un messaggio con numero massimo di ritentativi 🔄
  • Invia un messaggio con tempo di scadenza ⏳
  • Invia un messaggio entro un intervallo di giorno e ora 🕰️
  • Invia una reazione a un messaggio 😊
  • Rimuovi una reazione a un messaggio 🚫
  • Invia un messaggio per conto di un agente e assegna una chat 👤
  • Invia un messaggio e risolvi la chat ✅
  • Invia un messaggio e aggiungi un'etichetta alla chat 🏷️

🤩 🤖 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 a una prova gratuita e iniziando in pochi minuti!

Requisiti

  • Avere un numero WhatsApp già collegato alla piattaforma e online.
  • Numero di telefono del destinatario con prefisso internazionale in formato E164. Esempio: +12345678900. Valida il formato del numero di telefono qui.

Endpoint API

Useremo il seguente endpoint API per inviare messaggi a un gruppo:

Prepara la richiesta

URL target dell'API usando il metodo POST

https://api.wassenger.com/v1/messages

Header HTTPS richiesti > Ottieni qui la tua chiave API

Content-Type: application/json
Token: $API_TOKEN

Usa il body in formato JSON

{
  "phone": "+1234567890",
  "message": "Hello world, this is a sample message"
}

🖥️ Cerchi un esempio di codice? Vai al tester API live e ottieni esempi di codice pronti all'uso in più di 15 linguaggi di programmazione, tra cui JavaScript, PHP, C#, Java, Ruby, Go, Powershell, cURL e altri.

Invia messaggi di testo con C# (.NET)

// 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/messages");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Token", "ENTER API KEY HERE");
request.AddParameter("application/json", "{\"phone\":\"+1234567890\", \"message\":\"Hello world, this is a sample message\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);

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

Altri esempi per messaggi di gruppo con C# (.NET)

Per esempi completi, visita il nostro API Live Tester

Invia messaggio immagine con C# (.NET)

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; // Create a RestClient instance with the API endpoint var client = new RestClient("https://api.wassenger.com/v1/messages"); // Set up the request with the POST method var request = new RestRequest(Method.POST); // Add headers for content type and authentication request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key // Define the request body for sending a text message var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number message = "Hello world, this is a sample message" // Message content }; // Add the request body as JSON request.AddJsonBody(requestBody); // Execute the request and store the response IRestResponse response = client.Execute(request); // Output the response content (optional for debugging) Console.WriteLine(response.Content);

Invia messaggi video con C# (.NET)

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp;

// Create a RestClient instance with the API endpoint var client = new RestClient("https://api.wassenger.com/v1/messages");

// Set up the request with the POST method var request = new RestRequest(Method.POST);

// Add headers for content type and authentication request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key

// Define the request body for sending a video message var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number message = "This is a caption for a video message", // Add a caption for the video media = new { url = "https://download.samplelib.com/mp4/sample-5s.mp4", // URL of the video file expiration = "7d" // Set expiration time (e.g., 7 days) } };

// Add the request body as JSON request.AddJsonBody(requestBody);

// Execute the request and store the response IRestResponse response = client.Execute(request);

// Output the response content (optional for debugging) Console.WriteLine(response.Content);

Invia messaggi documento con C# (.NET)

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp;

// Create a RestClient instance with the API endpoint var client = new RestClient("https://api.wassenger.com/v1/messages");

// Set up the request with the POST method var request = new RestRequest(Method.POST);

// Add headers for content type and authentication request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key

// Define the request body for sending a PDF with expiration var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number media = new { url = "https://www.africau.edu/images/default/sample.pdf", // URL of the PDF file expiration = "30d" // Set expiration time (e.g., 30 days) } };

// Add the request

Invia registrazione vocale audio con C# (.NET)

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp;

// Create a RestClient instance with the API endpoint var client = new RestClient("https://api.wassenger.com/v1/messages");

// Set up the request with the POST method var request = new RestRequest(Method.POST);

// Add headers for content type and authentication request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key

// Define the request body for sending an audio message (PTT) var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number media = new { url = "https://download.samplelib.com/mp3/sample-9s.mp3", // URL of the audio file format = "ptt" // Format type for audio message (PTT - Push to Talk) } };

// Add the request body as JSON request.AddJsonBody(requestBody);

// Execute the request and store the response IRestResponse response = client.Execute(request);

// Output the response content (optional for debugging) Console.WriteLine(response.Content);

Invia un messaggio multimediale con un file caricato usando C# (.NET)

*{{UPLOADED FILE ID}}* : Sostituisci questa espressione con il valore specifico

  • Puoi caricare il file qui
  • L'ID del file sarà qualcosa di simile a: 57443b8773c036f2bae0cd96

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp;

// Create a RestClient instance with the API endpoint var client = new RestClient("https://api.wassenger.com/v1/messages");

// Set up the request with the POST method var request = new RestRequest(Method.POST);

// Add headers for content type and authentication request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key

// Define the request body for sending an image message var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number message = "This is a caption for an image message", // Caption for the image media = new { file = "{{UPLOADED FILE ID}}" // Replace with the actual uploaded file ID } };

// Add the request body as JSON request.AddJsonBody(requestBody);

// Execute the request and store the response IRestResponse response = client.Execute(request);

// Output the response content (optional for debugging) Console.WriteLine(response.Content);

Invia un messaggio GIF con C# (.NET)

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp;

// Create a RestClient instance with the API endpoint var client = new RestClient("https://api.wassenger.com/v1/messages");

// Set up the request with the POST method var request = new RestRequest(Method.POST);

// Add headers for content type and authentication request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key

// Define the request body for sending a GIF message var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number message = "This is a sample caption for a GIF message", // Caption for the GIF media = new { url = "https://i.giphy.com/vKHKDIdvxvN7vTAEOM.mp4", // URL of the GIF in MP4 format format = "gif" // Specify the media format } };

// Add the request body as JSON request.AddJsonBody(requestBody);

// Execute the request and store the response IRestResponse response = client.Execute(request);

// Output the response content (optional for debugging) Console.WriteLine(response.Content);

Invia un messaggio sondaggio con C# (.NET)

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; // Create a RestClient instance with the API endpoint var client = new RestClient("https://api.wassenger.com/v1/messages"); // Set up the request with the POST method var request = new RestRequest(Method.POST); // Add necessary headers for content type and authentication request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key // Define the request body for the poll var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number poll = new { name = "Vote for your favorite color", // Title of the poll options = new[] { "Red", "Green", "Blue", "Yellow", "Grey", "Black", "Orange", "Purple", "White" // Poll options } } }; // Add the request body as JSON request.AddJsonBody(requestBody); // Execute the request and store the response IRestResponse response = client.Execute(request); // Output the response content (optional for debugging) Console.WriteLine(response.Content);

Invia un messaggio programmato con data e ora usando C# (.NET)

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; // Create a RestClient instance with the API endpoint var client = new RestClient("https://api.wassenger.com/v1/messages"); // Set up the request with method type POST var request = new RestRequest(Method.POST); // Add headers for content type and authentication request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key // Define the request body var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number message = "This is a scheduled message to be sent to a phone number in 10 minutes", deliverAt = "2024-12-02T13:52:32.396Z" // Replace with your desired delivery time (ISO 8601 format) }; // Add the request body as JSON request.AddJsonBody(requestBody); // Execute the request and store the response IRestResponse response = client.Execute(request); // Output the response (optional) Console.WriteLine(response.Content);

Invia messaggi con pulsanti nativi dinamici usando C# (.NET)

WhatsApp non accetta più messaggi con pulsanti nativi. I messaggi con pulsanti saranno automaticamente convertiti nell'equivalente in testo semplice. Scopri di più qui

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; // Create a RestClient instance with the API endpoint var client = new RestClient("https://api.wassenger.com/v1/messages"); // Set up the request with the POST method var request = new RestRequest(Method.POST); // Add headers for content type and authentication request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key // Define the request body for sending a message with dynamic reply buttons var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number message = "This is a message with dynamic reply buttons", // Message content header = "Optional message header", // Optional header footer = "Optional message footer", // Optional footer buttons = new[] { new { id = "id1", text = "Say hello" }, new { id = "id2", text = "Say goodbye" }, new { id = "id3", text = "Get help" } } }; // Add the request body as JSON request.AddJsonBody(requestBody); // Execute the request and store the response IRestResponse response = client.Execute(request); // Output the response content (optional for debugging) Console.WriteLine(response.Content);

Invia un elenco di elementi da selezionare con C# (.NET)

WhatsApp non accetta più messaggi lista. I messaggi lista saranno automaticamente convertiti nell'equivalente in testo semplice. Scopri di più qui

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp;

// Create a RestClient instance with the API endpoint var client = new RestClient("https://api.wassenger.com/v1/messages");

// Set up the request with the POST method var request = new RestRequest(Method.POST);

// Add headers for content type and authentication request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key

// Define the request body for sending a list message var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number list = new { button = "Select one option", // Button text description = "Select which type of vehicle you are interested in", // Description of the list title = "Motor Business", // Title of the list footer = "Since 1990", // Footer text sections = new[] { new { title = "Select a car type", rows = new[] { new { title = "Coupe", id = "a1", description = "This a description for coupe cars" }, new { title = "Sports", id = "a2", description = "This a description for sports cars" }, new { title = "SUV", id = "a3", description = "This a description for SUV cars" }, new { title = "Minivan", id = "a4", description = "This a description for minivan cars" }, new { title = "Crossover", id = "a5", description = "This a description for crossover cars" }, new { title = "Wagon", id = "a6", description = "This a description for wagon cars" } } }, new { title = "Select a motorbike type", rows = new[] { new { title = "Touring", id = "b1", description = "Designed to excel at covering long distances" }, new { title = "Cruiser", id = "b2", description = "Harley-Davidsons largely define the cruiser category" }, new { title = "Standard", id = "b3", description = "Motorcycle intended for use on streets and commuting" } } } } } };

// Add the request body as JSON request.AddJsonBody(requestBody);

// Execute the request and store the response IRestResponse response = client.Execute(request);

// Output the response content (optional for debugging) Console.WriteLine(response.Content);

Invia un messaggio con formattazione del testo usando C# (.NET)

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; // Create a RestClient instance with the API endpoint

var client = new RestClient("https://api.wassenger.com/v1/messages"); // Set up the request with the POST method

var request = new RestRequest(Method.POST); // Add headers for content type and authentication

request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key

// Define the request body for sending a formatted text message var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number message = "This message is formatted using _italic format_, *bold format*, strikethrough format and ```monospace format```" };

// Add the request body as JSON request.AddJsonBody(requestBody);

// Execute the request and store the response IRestResponse response = client.Execute(request);

// Output the response content (optional for debugging) Console.WriteLine(response.Content);

Invia un messaggio con coordinate usando C# (.NET)

Scopri di più su come inviare messaggi di localizzazione con coordinate in questo tutorial

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; // Create a RestClient instance with the API endpoint var client = new RestClient("https://api.wassenger.com/v1/messages"); // Set up the request with the POST method var request = new RestRequest(Method.POST); // Add headers for content type and authentication request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key // Define the request body for sending a location message with coordinates var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number location = new { coordinates = new[] { 40.7583748, -73.9891184 } // Latitude and longitude }, message = "This is a location message using coordinates" // Optional message }; // Add the request body as JSON request.AddJsonBody(requestBody); // Execute the request and store the response IRestResponse response = client.Execute(request); // Output the response content (optional for debugging) Console.WriteLine(response.Content);

Invia un messaggio di localizzazione con indirizzo usando C# (.NET)

Scopri di più su come inviare messaggi di localizzazione con indirizzi in questo tutorial

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; // Create a RestClient instance with the API endpoint var client = new RestClient("https://api.wassenger.com/v1/messages"); // Set up the request with the POST method var request = new RestRequest(Method.POST); // Add headers for content type and authentication request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key // Define the request body for sending a location message with an address var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number location = new { address = "Santa Claus Main Post Office, Tähtikuja 1, 96930 Arctic Circle, Finland" // Address }, message = "This is a location message using an address" // Optional message }; // Add the request body as JSON request.AddJsonBody(requestBody); // Execute the request and store the response IRestResponse response = client.Execute(request); // Output the response content (optional for debugging) Console.WriteLine(response.Content);

Invia un messaggio con variabili usando C# (.NET)

Scopri di più su come inviare messaggi con variabili nei template in questo tutorial.

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; // Create a RestClient instance with the API endpoint var client = new RestClient("https://api.wassenger.com/v1/messages"); // Set up the request with the POST method var request = new RestRequest(Method.POST); // Add headers for content type and authentication request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key // Define the request body for sending a personalized message template var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number message = @"Dear {{ contact.name | customer }}, Thanks for contacting us! We will answer your query shortly. Your message was received on {{ date.humanize.full }}" // Template with placeholders }; // Add the request body as JSON request.AddJsonBody(requestBody); // Execute the request and store the response IRestResponse response = client.Execute(request); // Output the response content (optional for debugging) Console.WriteLine(response.Content);

Invia un messaggio con un URL usando C# (.NET)

Scopri di più su come inviare messaggi con link URL in questo tutorial

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; // Create a RestClient instance with the API endpoint var client = new RestClient("https://api.wassenger.com/v1/messages"); // Set up the request with the POST method var request = new RestRequest(Method.POST); // Add headers for content type and authentication request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key // Define the request body for sending a message with a link var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number message = "Check out this cool link: https://www.youtube.com" // Message with link }; // Add the request body as JSON request.AddJsonBody(requestBody); // Execute the request and store the response IRestResponse response = client.Execute(request); // Output the response content (optional for debugging) Console.WriteLine(response.Content);

Invia messaggi biglietto da visita con C# (.NET)

Scopri di più su come inviare messaggi biglietto da visita in questo tutorial

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; // Create a RestClient instance with the API endpoint var client = new RestClient("https://api.wassenger.com/v1/messages"); // Set up the request with the POST method var request = new RestRequest(Method.POST); // Add headers for content type and authentication request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key // Define the request body for sending contact information var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number contacts = new[] { new { phone = "+1234567890", name = "John Doe" } // Contact details } }; // Add the request body as JSON request.AddJsonBody(requestBody); // Execute the request and store the response IRestResponse response = client.Execute(request); // Output the response content (optional for debugging) Console.WriteLine(response.Content);

Rispondi a un messaggio con C# (.NET)

{{MESSAGE ID}} : Sostituisci con l'effettivo ID del messaggio WhatsApp a cui rispondere (valore esadecimale di 18, 20, 22 o 32 caratteri)

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; // Create a RestClient instance with the API endpoint var client = new RestClient("https://api.wassenger.com/v1/messages"); // Set up the request with the POST method var request = new RestRequest(Method.POST); // Add headers for content type and authentication request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key // Define the request body for sending a reply message var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number quote = "{{MESSAGE ID}}", // Replace with the actual message ID message = "This message is a reply to another message within the same chat" // Reply message content }; // Add the request body as JSON request.AddJsonBody(requestBody); // Execute the request and store the response IRestResponse response = client.Execute(request); // Output the response content (optional for debugging) Console.WriteLine(response.Content);

Inoltra un messaggio con C# (.NET)

{{MESSAGE ID}} : Sostituisci con l'effettivo ID del messaggio WhatsApp da inoltrare (valore esadecimale di 18, 20, 22 o 32 caratteri)

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; var client = new RestClient("https://api.wassenger.com/v1/messages"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number forward = new { message = "{{MESSAGE ID}}", // Replace with the message ID to forward chat = "+1234567890" // Replace with the chat ID to forward to }, message = "The given message by ID will be forwarded to another chat" }; request.AddJsonBody(requestBody); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content);

Invia un messaggio catalogo con C# (.NET)

{{PRODUCT CATALOG ID TO SEND}} : Sostituisci questa espressione con il valore specifico

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; var client = new RestClient("https://api.wassenger.com/v1/messages"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number product = "{{PRODUCT CATALOG ID TO SEND}}" // Replace with the product catalog ID }; request.AddJsonBody(requestBody); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content);

Invia un messaggio in tempo reale senza accodamento usando C# (.NET)

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; var client = new RestClient("https://api.wassenger.com/v1/messages"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); var requestBody = new { live = true, phone = "+1234567890", message = "This message will be delivered in real-time if the session is online, otherwise the API will return an error" }; request.AddJsonBody(requestBody); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content);

Invia un messaggio con numero massimo di ritentativi usando C# (.NET)

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; var client = new RestClient("https://api.wassenger.com/v1/messages"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); var requestBody = new { retries = 2, phone = "+1234567890", message = "This message will be retried only twice. If the delivery fails twice, it will be flagged as deleted and removed from the queue" }; request.AddJsonBody(requestBody); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content);

Invia un messaggio con tempo di scadenza usando C# (.NET)

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; var client = new RestClient("https://api.wassenger.com/v1/messages"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); var requestBody = new { expiration = new { seconds = 90 }, phone = "+1234567890", message = "This message will be deleted if it cannot be delivered within 90 seconds after being queued. This is useful for time-sensitive messages." }; request.AddJsonBody(requestBody); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content);

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

Invia un messaggio entro un intervallo di giorno e ora usando C# (.NET)

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; var client = new RestClient("https://api.wassenger.com/v1/messages"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); var requestBody = new { phone = "+1234567890", message = "Restricted message example that will only be delivered between 9 am to 5 pm from Monday to Friday.", restrict = new { start = 9, end = 17, timezone = "CEST", weekdays = new[] { 1, 2, 3, 4, 5 } } }; request.AddJsonBody(requestBody); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content);

Invia una reazione a un messaggio usando C# (.NET)

{{WHATSAPP MESSAGE ID}} : Sostituisci questa espressione con il valore specifico

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; var client = new RestClient("https://api.wassenger.com/v1/messages"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); var requestBody = new { phone = "+1234567890", reaction = "👍", reactionMessage = "{{WHATSAPP MESSAGE ID}}" // Replace with the message ID }; request.AddJsonBody(requestBody); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content);

Rimuovere reazione a messaggio:

{{WHATSAPP MESSAGE ID}} : Sostituisci questa espressione con il valore specifico

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; var client = new RestClient("https://api.wassenger.com/v1/messages"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); var requestBody = new { phone = "+1234567890", reaction = "-", // Use "-" to remove a reaction reactionMessage = "{{MESSAGE WHATSAPP ID}}" // Replace with the message ID }; request.AddJsonBody(requestBody); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content);

Invia un messaggio per conto di un agente e assegna una chat usando C# (.NET)

{{USER ID}} : Sostituisci con l'effettivo ID utente (valore esadecimale di 24 caratteri)

{{ASSIGNED USER ID}} : Sostituisci con l'effettivo ID utente a cui assegnare la chat (valore esadecimale di 24 caratteri)

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; var client = new RestClient("https://api.wassenger.com/v1/messages"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number agent = "{{USER ID}}", // Replace with the agent's user ID message = "This message is sent via API on behalf of an agent." }; request.AddJsonBody(requestBody); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content);

Invia un messaggio e risolvi la chat con C# (.NET)

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; var client = new RestClient("https://api.wassenger.com/v1/messages"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number message = "Once this message is delivered, the chat will be reported as resolved in the web chat interface.", actions = new[] { new { action = "chat:resolve" } } }; request.AddJsonBody(requestBody); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content);

Invia un messaggio e aggiungi un'etichetta alla chat con C# (.NET)

// Required: RestSharp package // Documentation: https://restsharp.dev // Installation: https://www.nuget.org/packages/RestSharp

using RestSharp; var client = new RestClient("https://api.wassenger.com/v1/messages"); var request = new RestRequest(Method.POST); request.AddHeader("Content-Type", "application/json"); request.AddHeader("Token", "ENTER API KEY HERE"); // Replace with your API key var requestBody = new { phone = "+1234567890", // Replace with the recipient's phone number message = "Once this message is delivered, the given labels will be added to the chat automatically.", actions = new[] { new { action = "labels:add", params = new { labels = new[] { "new", "sales" } // Labels to be added } } } }; request.AddJsonBody(requestBody); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content);

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

Test API live

Puoi testare l'API in tempo reale e sperimentare direttamente dal tuo browser in pochi minuti.

Una volta terminati i test, puoi ottenere l'esempio di codice auto-generato nel linguaggio di programmazione che preferisci e sarai pronto a partire.

FAQ

Come inviare messaggi a più numeri di telefono

Devi inviare molteplici richieste API, una per ogni numero di telefono target.

Ad esempio, per inviare un messaggio a 10 numeri di telefono, dovresti inviare 10 richieste HTTPS indipendenti all'API.

Non esiste un'opzione per inviare più messaggi in una singola richiesta API.

Come verificare se un numero di telefono può ricevere messaggi WhatsApp

Puoi verificare se un dato numero di telefono è collegato a un account WhatsApp e può ricevere messaggi.

L'API fornisce un endpoint per validare se un dato numero di telefono esiste su WhatsApp.

L'unico requisito è avere almeno un numero WhatsApp connesso alla piattaforma nel tuo account attuale.

Per maggiori dettagli, consulta la documentazione dell'endpoint API qui.

Prima di verificare se un numero esiste su WhatsApp, puoi anche validare e normalizzare il formato di una lista di numeri di telefono usando l'endpoint numbers validator API. Questo endpoint valida solo il corretto formato E164 ma non verifica se il numero di telefono è effettivamente su WhatsApp.

Nota: il numero di verifiche WhatsApp è limitato mensilmente in base al tuo piano di abbonamento. Consulta la tabella dei prezzi per maggiori dettagli sui limiti.

Cerchi altre risposte? Consulta le FAQ estese.

Risorse utili aggiuntive

Documentazione API

Per maggiori dettagli sull'endpoint API, consulta la documentazione, dove troverai tutti i dettagli sui parametri di richiesta accettati, le possibili risposte di successo o errore e esempi di codice pronti all'uso in più linguaggi di programmazione:

https://app.wassenger.com/docs/#tag/Messages/operation/createMessage

Ready to transform your WhatsApp communication?

Start automating your customer interactions today with Wassenger

Get Started Free