Send a message to a WhatsApp group from n8n
Post a message into an existing WhatsApp group from n8n on a schedule or when something happens elsewhere. The group id is the recipient, so the same HTTP Request node that sends to a person sends to the group; a Schedule Trigger, a Code node that writes the digest and one send node are the whole workflow.
Before you start
- An n8n instance with a Header Auth credential already holding your Wapito channel token.
- The id of the target group, ending in @g.us, read from the groups endpoint or from the group's own create response.
- The linked number has to be a member of the group; it does not need to be an admin unless the group is set to admins-only posting.
Step by step in n8n
Find the group id once and keep it
Add a one-off HTTP Request node that calls GET https://api.wapito.com/v1/groups with the Wapito credential, run it, and copy the id of the group you want from the results. Paste it into a workflow variable or a Set node at the top of the real workflow rather than into every send node, because a group id is text you will want to change in exactly one place.
Field map Wapito field Where it comes from group_idThe id field of the matching entry in the GET /groups response, for example 120363041234567890@g.us Trigger on a schedule or on an event
For a daily digest use a Schedule Trigger set to the hour your team reads the group; for an alert use whatever node observes the event, such as a Postgres trigger or a Webhook node. Either way the trigger should fire once per message you intend to send, because a loop that produces one item per row will send one group message per row.
Compose the message in a Code node
Write the body in a Code node so the formatting lives in one place: join the rows into lines, use WhatsApp markdown such as asterisks for bold, and keep it under a screen or two, since a group reads a wall of text as noise. If you want to notify specific members, put their numbers in a mentions array and write each one as an at sign followed by the digits inside the body.
Field map Wapito field Where it comes from bodyThe string the Code node returns as json.body, with *bold* and _italic_ passed through mentionsOptional array of digit-only numbers, each also written as @15551234567 in the body Send it to the group with an HTTP Request node
Add an HTTP Request node with POST https://api.wapito.com/v1/messages/text, the Wapito credential under Generic Credential Type, and a JSON body built from expressions. The recipient is the stored group id; nothing else about the request differs from a message to a person. A typing_time of a few seconds spaces the send out on a busy morning.
Field map Wapito field Where it comes from body{{ $json.body }} — the text from the Code node mentions{{ $json.mentions }} — omit the field when there are none to{{ $('Set').item.json.group_id }} — the @g.us id typing_time2 Record the message id and branch on the outcome
The 201 response carries the message id, chat_id and a status of sent; write the id somewhere with a Set node so a later status event can be matched to this send. Turn on Continue On Fail and route the error output to a notification node, and read error.code there, because a send_rate_limited or reachout_timelocked answer means the number needs slowing down rather than retrying.
Field map Wapito field Where it comes from error.code{{ $json.error.code }} on the failure branch message_id{{ $json.id }} from the send response Aggregate the delivery receipts, do not store them all
In a group, the messages.status event arrives once per participant, so a single digest to a large group produces a burst of receipts on your Webhook node. If you subscribe to status events, follow the Webhook node with an Aggregate node keyed on the message id and count delivered versus failed, rather than writing every receipt to a table that will fill up within a week.
Field map Wapito field Where it comes from status.message_idThe id you stored in the previous step, used as the aggregate key
Test it
Point the workflow at a test group that contains only your own two numbers and execute it manually. The HTTP Request node should return a 201 with a message id, the text should appear in the group on both phones with the bold formatting intact, and if a mention was included the mentioned phone should show a notification.
Errors you may hit
- invalid_recipient 400Recipient is not valid
- send_rate_limited 429Send queue saturated
- rate_limited 429Too many requests
- channel_not_connected 409Channel not connected
- forbidden 403Action not allowed
Frequently asked questions
Can I send an image or a document to the group from n8n?
Yes, with the same shape: post to the media endpoint for the type you want, with the group id as the recipient and a media id or a public URL for the file. Upload the file once and reuse its media id when the same asset goes to several groups, rather than re-uploading it in every execution, which is slower and counts against the same quotas.
What happens if the group only allows admins to post?
The send is refused with a forbidden error unless the linked number is an admin of that group. Wapito cannot promote itself; another admin has to do it from the phone or through the admins endpoint from a channel that is already an admin. Check the group's settings once before the workflow goes live rather than discovering it from the failure branch.
How often can a workflow post to a group without getting the number restricted?
There is no published number, and the honest answer is that a group message is one send against the same per-channel queue as everything else. A daily digest is unremarkable; a message every few minutes from a number that joined the group last week is the pattern that draws a restriction. Wapito paces the queue, but it cannot make a burst look like a person.
Related
Endpoints this recipe calls
Try it on your own number
Create a channel, link a WhatsApp number by QR or pairing code, and call the API in a couple of minutes. The Sandbox plan is free and needs no card.