Skip to content

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 participants

Create 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:

AttributeTypeDescription
idStringGroup JID (e.g. "[email protected]")
subjectStringGroup name
descriptionStringGroup description
ownerStringOwner JID
creationIntegerCreation timestamp
sizeIntegerNumber of participants
participantsArrayParticipant 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..."])

MIT License