Send Automated Messages On WhatsApp Using Powershell

May 20, 2024

Imagine automating your WhatsApp messages to easily send reminders, notifications, shipping confirmations, promotions and more to your customers, saving time, and costs, effective deliverability, and ensuring a great customer experience.

With Wassenger’s, you can effortlessly integrate WhatsApp messaging using Powershell to automate messages. In this tutorial, you can learn how to do that in simple steps and benefit from just a portion of Wassenger’s API potential 🥳🥳

🤩 🤖 Wassenger is a complete communication platform and API solution for WhatsApp. Explore more than 100+ API use cases and automate anything on WhatsApp by signing up for a free trial and getting started in minutes!

Requirements

  • To have a WhatsApp number already linked to the platform and online.
  • Message recipient phone number with international prefix in E164 format. Example: +12345678900. Validate the phone number format here.

API endpoint

We will use the following API endpoint to send messages to a group:

Prepare the request

Target API URL using the POST method

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

Required HTTPS headers > Obtain your API key here

Content-Type: application/json
Token: $API_TOKEN

Use body in JSON format

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

🖥️ Looking for a code example? Go to the API live tester and get ready-to-use code examples in 15+ programming languages, including Python, JavaScript, PHP, C#, Java, Ruby, Go, Powershell, cURL and more.

Send automated messages with Powershell

  1. API Key Replacement: Ensure that you replace "ENTER API KEY HERE" with your actual API key.
  2. Check for Errors: Add error handling to capture any issues that might occur during the API call (check the error message in the response body), and try the request if needed.
  3. Verify Endpoint and Payload: Confirm that the endpoint URL and payload format are correct according to the API documentation.

$headers = @{ "Content-Type" = "application/json" "Token" = "YOUR_ACTUAL_API_KEY" }

$body = @{ "phone" = "+1234567890" "message" = "Hello world, this is a sample message" } | ConvertTo-Json

try { $response = Invoke-WebRequest -Uri 'https://api.wassenger.com/v1/messages' -Method POST -Headers $headers -Body $body if ($response.StatusCode -eq 200) { Write-Host "Message sent successfully." } else { Write-Host "Failed to send message. Status code:" $response.StatusCode } } catch { Write-Host "An error occurred:" $_.Exception.Message }

🤩 🤖 Wassenger is a complete API solution for WhatsApp. Sign up for a 7-day free trial and get started in minutes!

Live API testing

You can live-test and play with the API directly from your browser in minutes.

Once you are done testing, get the auto-generated code example in your preferred programming language and you will be ready to go.

FAQ

How to send messages to multiple phone numbers

You just have to send multiple API requests, one per target phone number.

For instance, if you want to send a message to 10 phone numbers, you should send 10 independent HTTPS requests to the API.

There is no option to send multiple messages in a single API request.

How to validate if a phone number can receive WhatsApp messages

You can validate if a given phone number is linked to a WhatsApp account and can receive messages.

The API provides an endpoint that can validate whether a given phone number exists in WhatsApp or not.

The only requirement is to have at least one WhatsApp number connected to the platform in your current account.

For more details, please check out the API endpoint documentation here.

Before you check if a phone number exists on WhatsApp, you can also validate and normalize the format of a list of phone numbers by using the numbers validator API endpoint. This endpoint only validates the correct E164 format, but it does not check whether the phone number effectively exists on WhatsApp.

Note: The number of WhatsApp check validations is limited per month based on your subscription plan. Please check out the pricing table for more details about the limits.

Looking for more answers? Check out the extended FAQs.

Further useful resources

API Documentation

For more details about the endpoint API, please check the documentation where you will find all the details about the accepted request params, possible success or error responses and ready-to-use code examples in multiple programming languages:

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