Groups
List all groups
ruby
groups = client.groups
# => [#<Whatsapp::Group id="[email protected]" subject="Team">, ...]Get a single group
ruby
group = client.group("[email protected]")
group.id # "[email protected]"
group.subject # "Team"
group.description # "Our team group"
group.owner # "[email protected]"
group.creation # creation timestamp
group.size # number of participantsCreate a group
ruby
group = client.create_group(
subject: "Team",
participants: ["+33612345678", "+33698765432"]
)Update a group
ruby
client.update_group("[email protected]",
subject: "New Name",
description: "Updated description"
)Manage participants
ruby
# Add participants
client.add_group_participants("[email protected]",
participants: ["+33612345678"]
)
# Remove participants
client.remove_group_participants("[email protected]",
participants: ["+33612345678"]
)Group object
The Whatsapp::Group object provides access to group metadata:
| Attribute | Type | Description |
|---|---|---|
id | String | Group JID (e.g. "[email protected]") |
subject | String | Group name |
description | String | Group description |
owner | String | Owner JID |
creation | Integer | Creation timestamp |
size | Integer | Number of participants |
participants | Array | Participant hashes with id and admin flags |
Methods
ruby
group.admins # => ["[email protected]", ...]
group.participant_ids # => ["[email protected]", "[email protected]"]
group.to_h # => { id: "...", subject: "...", ... }Rails usage
In account mode, all group methods are available through the proxy:
ruby
hotel.whatsapp.groups
hotel.whatsapp.create_group(subject: "VIP Guests", participants: ["+336..."])