Skip to main content

Groups

Last updated on

Overview

AccelByte Cloud's Groups service allows players to gather to chat and play together. This service allows players to create, join, and invite other players to groups. Group admins can also manage join requests and add members to or remove members from their group. The Groups service can be integrated with other services such as Lobby, Statistics, and Leaderboards, to extend its functionality. For example, you can create groups for players that have achieved a specific level or rank in your game.

Group Types

There are three types of groups that can be created:

  • Open Groups are searchable and do not require any approval to join. A player can search for the group using the Group Name or Group Code, and then join the group without waiting for a group admin to approve their request.
  • Public Groups are searchable but require permission to join. When a player tries to join, they must first wait for a group admin to approve their request. These groups often have membership requirements, such as only allowing players with an MMR of more than 100 to join the group.
  • Private Groups can't be searched and require permission to join. Players can only join these groups if they've been invited by an admin.

Prerequisites

Make sure you've read about Roles Management to know the basics of creating a role.

Permissions

Permissions are used to grant access to specific resources within our services. Make sure your account has the following permissions before you attempt to manage groups in the Admin Portal. For a full list of permissions that impact groups management, see the Groups tab of the Permissions Reference.

UsageResourceAction
List Group ConfigurationADMIN:NAMESPACE:{namespace}:GROUP:CONFIGURATIONRead
Create New ConfigurationADMIN:NAMESPACE:{namespace}:GROUP:CONFIGURATIONCreate
Initiate ConfigurationADMIN:NAMESPACE:{namespace}:GROUP:CONFIGURATIONCreate
Get Existing ConfigurationADMIN:NAMESPACE:{namespace}:GROUP:CONFIGURATIONRead
Delete Group ConfigurationADMIN:NAMESPACE:{namespace}:GROUP:CONFIGURATIONDelete
Update Existing ConfigurationADMIN:NAMESPACE:{namespace}:GROUP:CONFIGURATIONUpdate
Update Existing Configuration Global RuleADMIN:NAMESPACE:{namespace}:GROUP:CONFIGURATIONUpdate
Delete Existing Configuration Global Rule Based On Allowed ActionADMIN:NAMESPACE:{namespace}:GROUP:CONFIGURATIONUpdate
Get List Of GroupsADMIN:NAMESPACE:{namespace}:GROUPRead
Get Single GroupADMIN:NAMESPACE:{namespace}:GROUPRead
Delete Existing GroupADMIN:NAMESPACE:{namespace}:GROUP:{groupId}Delete
Get a List Of Group MembersADMIN:NAMESPACE:{namespace}:GROUP:MEMBERRead
Get All List Of Member RolesADMIN:NAMESPACE:{namespace}:GROUP:ROLERead
Create New Member RoleADMIN:NAMESPACE:{namespace}:GROUP:ROLECreate
Get the Member RoleADMIN:NAMESPACE:{namespace}:GROUP:ROLERead
Delete Member RoleADMIN:NAMESPACE:{namespace}:GROUP:ROLEDelete
Update Member RoleADMIN:NAMESPACE:{namespace}:GROUP:ROLEUpdate
Update Member Role PermissionADMIN:NAMESPACE:{namespace}:GROUP:ROLEUpdate

Permissions work slightly differently depending on whether they are assigned to IAM Clients or Roles assigned to users. For more information, read the Authentication and Authorization documentation.

Manage Groups in the Admin Portal

Create a New Group Role

  1. On the Group Roles page in the Admin Portal, click the Add Role button.

  2. A pop-up window appears. Here, input the Role Name for your new role. Note that Role will appear when you add the Group Configuration later.

    Once completed, click Submit.

Add New Permissions to a Group Role

  1. In the Admin Portal, go to the Group Role you created earlier, and in the Group Role Detail click the Add Permission button.

  2. A pop-up window appears. Fill in the required fields:

    • Input the Permission with the appropriate format.

    • Choose the Action of the permission.

    Once completed, click Add. The permission will be added to the group role.

Create a New Group Configuration

  1. On the Group Configurations page of the Admin Portal, click the Add Configuration button.

  2. Once the form appears, fill in the fields as shown below:

    • Input the configuration Code with the appropriate format. E.g. group-clan.

    • Input the configuration Name.

    • Input a Description of the configuration.

    • Input the Maximum Group Members.

    • Select the Group Admin Role and Group Member Role. Make sure you've created a Group Role as it would be displayed in the drop-down list.

    Once you've done, click Add. Here you can see your new configuration has been added to the list.

Add Custom Attributes

You can add custom attributes or custom parameters to customize your group information based on your preferences.

  1. In the Group Management dropdown of the Admin Portal, click the List menu.

  2. Choose the Group you want to add the custom attributes to by clicking the View button. Make sure that you have permission to add attributes to a group.

  3. In the Group Details, click the Add Custom Attributes button.

  4. Fill out the custom attributes in JSON format.

    When you're done, click Save.

Implement Groups using the Unity SDK

Manage Groups

Create a New Group

You can create a new group once you have a group configuration in your namespace. The members of your group will be admins by default.

RuleInformation ruleInformation = new RuleInformation
{
ruleAttribute = "MyRuleAttribute",
ruleCriteria = RuleCriteria.MAXIMUM,
ruleValue = 50.0f
};

Rules rules = new Rules
{
allowedAction = AllowedAction.joinGroup,
ruleDetail = [ruleInformation]
};

GroupRules groupRules = new GroupRules
{
groupCustomRule = {},
groupPredefinedRules = [rules]
};

CreateGroupRequest createGroupRequest = new CreateGroupRequest
{
groupName = "MyNewGroupName",
groupType = GroupType.OPEN,
groupMaxMember = 25,
groupDescription = "MyNewGroupDescription",
groupIcon = "https://example.com",
groupRegion = "US",
groupRules = groupRules,
configurationCode = "MyConfiguration Code",
customAttributes = new Dictionary<string, object>
{
{ "sword", 3 },
{ "armor", 7 }
}
};

AccelBytePlugin.GetGroup().CreateGroup(createGroupRequest, result =>
{
if (result.IsError)
{
// Do something if CreateGroup has an error
Debug.Log($"Error CreateGroup, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if CreateGroup has been successful
}
});

Retrieve a List of Groups

Search for a group by its name or region. The results will be paginated, and you can use offset and limit parameters to limit the list. This function only shows PUBLIC and OPEN groups.

string groupName = "SomeGroupName"; // You can leave it blank if you want to fetch all the groups
string groupRegion = "US"; // You can leave it blank if you want to fetch all the groups
int offset = 0;
int limit = 99;

AccelBytePlugin.GetGroup().SearchGroups(groupName, groupRegion, offset, limit, result =>
{
if (result.IsError)
{
// Do something if SearchGroups has an error
Debug.Log($"Error SearchGroups, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if SearchGroups has been successful
}
});

Retrieve Group Information

Get information about a group by using the Group ID.

string groupId = "SomeGroupId";

AccelBytePlugin.GetGroup().GetGroup(groupId, result =>
{
if (result.IsError)
{
// Do something if GetGroup has an error
Debug.Log($"Error GetGroup, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if GetGroup has been successful
}
});

Retrieve a Player's Group Information

You can get your current player's group information by using this function. If the player you requested doesn't belong to any group, the returned status will be ErrorCode.UserNotBelongToAnyGroup, and the player will be able to be invited to a group.

AccelBytePlugin.GetGroup().GetMyGroupInfo(result =>
{
if (result.IsError)
{
// Do something if GetMyGroupInfo has an error
Debug.Log($"Error GetMyGroupInfo, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if GetMyGroupInfo has been successful
}
});

Retrieve Other Player's Group Information

This function is to call the group information of other users with a specific user ID.

string userid = "SomeUserId";

AccelBytePlugin.GetGroup().GetOtherGroupInfo(userId, result =>
{
if (result.IsError)
{
// Do something if GetOtherGroupInfo has an error
Debug.Log($"Error GetOtherGroupInfo, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if GetOtherGroupInfo has been successful
}
});

Retrieve a Group's Member List

Use this function to get a group's member list.

string groupId = "SomeGroupId";

AccelBytePlugin.GetGroup().GetGroupMemberList(groupId, result =>
{
if (result.IsError)
{
// Do something if GetGroupMemberList has an error
Debug.Log($"Error GetGroupMemberList, Error Code: {result.Error.Code} Error Code: {result.Error.Message}");
}
else
{
// Do something if GetGroupMemberList has been successful
}
});

Update Group Information

A group's information such as its name, icon, description, region, and type can be updated with this function. Only members with an admin role can update the group's information.

string groupId = "SomeGroupId";

AccelBytePlugin.GetGroup().UpdateGroup(groupId, updateGroupRequest, result =>
{
if (result.IsError)
{
// Do something if UpdateGroup has an error
Debug.Log($"Error UpdateGroup, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if UpdateGroup has been successful
}
});

Update a Group's Custom Attributes

You can also update a group's custom attributes separately using this function. Just like the group information update, only members with an admin role can update the group's custom attributes.

Dictionary<string, object> customAttributes = new Dictionary<string, object>
{
{ "requirementLevel", 50 },
{ "requirementItem", 25 }
};

string groupId = "SomeGroupId";

AccelBytePlugin.GetGroup().UpdateGroupCustomAttributes(groupId, customAttributes, result =>
{
if (result.IsError)
{
// Do something if UpdateGroupCustomAttributes has an error
Debug.Log($"Error UpdateGroupCustomAttributes, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if UpdateGroupCustomAttributes has been successful
}
});

Group Interaction

Join Group

Players can request to join open or public groups. An OPEN group will allow players to automatically join, whereas a join request to a PUBLIC group will need to be approved by an admin before the player can join.

string groupId = "SomeGroupId";

AccelBytePlugin.GetGroup().JoinGroup(groupId, result =>
{
if (result.IsError)
{
// Do something if JoinGroup has an error
Debug.Log($"Error JoinGroup, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if JoinGroup has been successful
}
});

Cancel Join Request

After a player requests to join a group, that request can be canceled.

string groupId = "SomeGroupId";

AccelBytePlugin.GetGroup().CancelJoinGroupRequest(groupId, result =>
{
if (result.IsError)
{
// Do something if CancelJoinGroupRequest has an error
Debug.Log($"Error CancelJoinGroupRequest, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if CancelJoinGroupRequest has been successful
}
});

Leave Group

To leave a group, you can use this function.

AccelBytePlugin.GetGroup().LeaveGroup(result =>
{
if (result.IsError)
{
// Do something if LeaveGroup has an error
Debug.Log($"Error LeaveGroup, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if LeaveGroup has been successful
}
});

Invite a Player to a Group

Group admins can also invite players to join their group. A PRIVATE group can use this function to add new members. Players need to accept the invitation before they can join the group.

string otherUserId = "SomeOtherUserId";

AccelBytePlugin.GetGroup().InviteOtherUserToGroup(otherUserId, result =>
{
if (result.IsError)
{
// Do something if InviteOtherUserToGroup has an error
Debug.Log($"Error InviteOtherUserToGroup, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if InviteOtherUserToGroup has been successful
}
});
string userId = "123456789";
AccelBytePlugin.GetGroup().InviteOtherUserToGroup(userId, result =>
{
Debug.Log("Successfully invite user to the group!");
});

Kick a Group Member

Group admins can also kick group members out of the group.

string otherUserId = "SomeOtherUserId";

AccelBytePlugin.GetGroup().KickGroupMember(otherUserId, result =>
{
if (result.IsError)
{
// Do something if KickGroupMember has an error
Debug.Log($"Error KickGroupMember, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if KickGroupMember has been successful
}
});

Get a List of Group Invitation Requests

Players can get the list of group invitation requests, to either accept or reject these invitations.

AccelBytePlugin.GetGroup().GetGroupInvitationRequests(result =>
{
if (result.IsError)
{
// Do something if GetGroupInvitationRequests has an error
Debug.Log($"Error GetGroupInvitatioNRequests, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if GetGroupInvitationRequests has been successful
}
});

Accept Group Invitation Request

After getting the invitation list, players can accept an invitation.

string groupId = "SomeGroupId";

AccelBytePlugin.GetGroup().AcceptGroupInvitation(groupId, result =>
{
if (result.IsError)
{
// Do something if AcceptGroupInvitation has an error
Debug.Log($"Error AcceptGroupInvitation, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if AcceptGroupInvitation hasbeen successful
}
});

Reject Group Invitation Request

Players can also reject any invitation request.

string groupId = "SomeGroupId";

AccelBytePlugin.GetGroup().RejectGroupInvitation(groupId, result =>
{
if (result.IsError)
{
// Do something if RejectGroupInvitation has an error
Debug.Log($"Error RejectGroupInvitation, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if RejectGroupInvitation has been successful
}
});

Get List of Group Member Join Requests

Group admins can get the list of group member join requests, to either approve or reject them.

string groupId = "123456789";
AccelBytePlugin.GetGroup().GetGroupJoinRequests(groupId, result =>
{
foreach(var request in result.Value.data)
{
Debug.Log("UserId: " + request.userId);
}
});

Accept Group Member Join Request

After getting the list of join requests, a group admin can accept them to the group.

string otherUserId = "SomeOtherUserId";

AccelBytePlugin.GetGroup().AcceptOtherJoinRequest(otherUserId, result =>
{
if (result.IsError)
{
// Do something if AcceptOtherJoinRequest has an error
Debug.Log($"Error AcceptOtherJoinRequest, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if AcceptOtherJoinRequest has been successful
}
});

Reject Group Member Join Request

Group admin can also reject any member join request.

string otherUserId = "SomeOtherUserId";

AccelBytePlugin.GetGroup().RejectOtherJoinRequest(otherUserId, result =>
{
if (result.IsError)
{
// Do something if RejectOtherJoinRequest has an error
Debug.Log($"Error RejectOtherJoinRequest, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if RejectOtherJoinRequest has been successful
}
});

Get Bulk Users' Presence

You can use this endpoint to get users' presence information in bulk.

var userIds = new List<string>();
userIds.Add("SomeTargetUserId1");
userIds.Add("SomeTargetUserId2");
userIds.Add("SomeTargetUserId3");

AccelBytePlugin.GetLobby().Connect();
AccelBytePlugin.GetLobby().BulkGetUserPresence(userIds.ToArray(), result =>
{
if (result.IsError)
{
// Do something if BulkGetUserPresence has an error
Debug.Log($"Error BulkGetUserPresence, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if BulkGetUserPresence has been successful
}
});

Group Roles

Every group member has roles assigned to them, which can be used to restrict or allow access to features such as: inviting a member, kicking a member, etc. Every group member will automatically be assigned to the default member role that is already defined in the group configuration. This can be either an admin group role or a member group role.

Get a List of Group Member Roles

An admin can get a list of the member roles that have already been created in the Admin Portal.

AccelBytePlugin.GetGroup().GetMemberRoles(result =>
{
if (result.IsError)
{
// Do something if GetMemberRoles has an error
Debug.Log($"Error GetMemberRoles, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if GetMemberRoles has been successful
}
});

Promote a Member to a Role

An admin can promote a member to a specific role, as long as the role has been defined for that group.

string memberRoleId = "SomeMemberRoleId";
string userId = "SomeUserId";

AccelBytePlugin.GetGroup().AssignRoleToMember(memberRoleId, userid, result =>
{
if (result.IsError)
{
// Do something if AssignRoleToMember has an error
Debug.Log($"Error AssignRoleToMember, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if AssignRoleToMember has been successful
}
});

Remove a Member's Role

An admin can also remove a role from a member.

string memberRoleId = "SomeMemberRoleId";
string userId = "SomeUserId";

AccelBytePlugin.GetGroup().RemoveRoleFromMember(memberRoleId, userid, result =>
{
if (result.IsError)
{
// Do something if RemoveRoleFromMember has an error
Debug.Log($"Error RemoveRoleFromMember, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if RemoveRoleFromMember has been successful
}
});

Group Notifications

Some group activity will trigger notifications that will be sent to individual players, to group admins, or to all group members. The notification payload will be a JSON formatted string that contains data related to the triggered activity. To retrieve these notifications, you need to add a callback to the OnNotification function.

AccelBytePlugin.GetLobby().Connect();
AccelBytePlugin.GetLobby().OnNotification += result =>
{
if (result.IsError)
{
// Do something if OnNotification has an error
Debug.Log($"Error OnNotification, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if OnNotification has been successful
}
};
Group Invitation Notifications

Here's an example of the payload for a notification sent to a player when they've been invited to join a group:

{
"groupName": "nameOfGroup",
"groupId": "groupId",
"kind": "invitation"
}
Group Acceptance Notifications

Here's an example of the payload for a notification sent to a player when their request to join a group has been accepted:

{
"groupName": "nameOfGroup",
"groupId": "groupId",
"kind": "accepted-request"
}
Group Rejection Notifications

Here's an example of the payload for a notification sent to a player when their request to join a group has been rejected:

{
"groupName": "nameOfGroup",
"groupId": "groupId",
"kind": "rejected-request"
}
New Group Member Notifications

Here's an example of the payload for a notification sent to all group members when a new member has joined their group:

{
"groupName": "nameOfGroup",
"groupId": "groupId",
"newGroupMember": "newGroupMemberId",
"kind": "new-member"
}
Member Request Notifications

Here's an example of the payload for a notification sent to group admins when a player has requested to join their group:

{
"groupName": "nameOfGroup",
"groupId": "groupId",
"newGroupMember": "newGroupMemberId",
"kind": "join-request"
}
Member Role Assignment Notifications

Here's an example of the payload for a notification sent to a player when a group admin has assigned a role to them:

{
"groupName": "nameOfGroup",
"groupId": "groupId",
"newGroupMember": "newGroupMemberId",
"roleId": "roelId",
"kind": "assigned-role"
}

And here's the payload if a group admin removes a role from a player:

{
"groupName": "nameOfGroup",
"groupId": "groupId",
"newGroupMember": "newGroupMemberId",
"roleId": "roelId",
"kind": "removed-role"
}

Connect Custom Services to Groups using the Server SDKs

SDK Initialization

Before using the Cloud Groups service from the SDK, you will need to initialize your server-side SDK to ensure you are authorized and able to perform create, read, update, and delete actions.

Golang SDK Initialization

Before using the Groups service from the Golang SDK, you will need to initialize the SDK by following the steps below:

groupService := &g.GroupService{
Client: factory.NewGroupClient(&repository.ConfigRepositoryImpl{}),
TokenRepository: &repository.TokenRepositoryImpl{},
}

Once completed, you can use the Golang SDK to create, read, update and delete Groups from your serverless app.

Python SDK Initialization

Before using the Groups service from the Python SDK, you will need to initialize the SDK by following the steps below:

Once completed, you can use the Python SDK to create, read, update, and delete Groups from your serverless app.

.NET (C#) SDK Initialization

Before using the Group service, you will need to set some permissions. Use the following .NET namespaces:

    using AccelByte.Sdk.Api.Group.Model;
using AccelByte.Sdk.Api.Group.Operation;
using AccelByte.Sdk.Api.Group.Wrapper;

Java SDK Initialization

Before using the Group service, you will need to set some permissions. Initialize the Group wrapper from the Group service using the following code:

Group wGroup = new Group(sdk);

Once completed, you can use the SDK to create, read, update, or delete groups.

To use the Group Service, make sure you have the necessary permissions.

Create a Group

Use the following function to create a group:

err := groupService.PublicCreateNewGroupV1(input)
if err != nil {
return err
}
return nil

Delete a Group

Use the following function to delete a group:

err := groupService.DeleteGroupPublicV1(input)
if err != nil {
return err
}
return nil

Retrieve a Group

Use the following function to retrieve a group:

err := groupService.DeleteGroupPublicV1(input)
if err != nil {
return err
}
return nil

Update a Group

Use the following function to update a group:

err := groupService.DeleteGroupPublicV1(input)
if err != nil {
return err
}
return nil