Skip to main content

Groups

Last updated on

Overview

AccelByte Gaming Services (AGS) Starter Groups service allows players to gather together to chat and play matches with one another. 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 from their groups. AGS Starter’ Groups service can be integrated with other services such as the 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, helping to make groups more evenly balanced and boost player engagement and enjoyment in your games.

How It Works

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 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 for and require permission to join. Players can only join these groups if they’ve been invited by an admin.

Managing Groups in the Admin Portal

Create a New Group Role

  1. Open the desired game title and expand the Game Management, select Group Management, and click Roles.

  2. On the Group Roles page, click Add Role.

    group

  3. The Add Role form will appear. Type the name for your new role and click Submit when you’re done.

    group

Add New Permissions to a Group Role

  1. Go to the Group Role you created earlier and click the Add Permission button.

    group

  2. The Add Permission form will appear.

    group

    • Input the type of Permission by using the standard resource format, e.g., GROUP:JOIN, GROUP:KICK. Separate permissions with a comma (,).

    • Choose the Action of the permission.

    Refer to the table below for the types of permissions you can implement.

    UsagePermissionAction
    Delete and update existing groupGROUPRead, Update, Delete
    Invite a player to a groupGROUP:INVITECreate
    Accept and reject group join requestGROUP:JOINCreate
    Kick a player from a groupGROUP:KICKCreate
    Get list of all member rolesGROUP:ROLERead
    Assign a role to a memberGROUP:ROLEUpdate
  3. Click Add when you’re done.

Create a New Group Configuration

  1. Expand the Group Management menu and click the Create Configuration button.

    group

  2. The Create Configuration form will appear. Fill in the required fields:

    • 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 as a number.
    • Select the Group Admin Role associated with this group.
    • Select the Group Member Role associated with this group.

    group

  3. Click Add. Your new configuration will be added to the list.

Add Custom Attributes

  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 the required attributes to a group.

    group

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

  4. Fill out the custom attributes in JSON format.

    group

  5. Once completed, click Save.

Implement Groups using the Client SDKs

Managing 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.

FAccelByteModelsGroupRules GroupRules;

FAccelByteModelsCreateGroupRequest GroupConfiguration;

GroupConfiguration.GroupName = "MyNewGroupName";
GroupConfiguration.GroupType = EAccelByteGroupType::OPEN;
GroupConfiguration.GroupMaxMember = 25;
GroupConfiguration.GroupDescription = "MyNewGroupDescription";
GroupConfiguration.GroupIcon = "https://example.com";
GroupConfiguration.GroupRegion = "US";
GroupConfiguration.GroupRules = GroupRules;
GroupConfiguration.ConfigurationCode = "MyConfiguration Code";

FRegistry::Group.CreateGroup(
GroupConfiguration,
THandler<FAccelByteModelsGroupInformation>::CreateWeakLambda(this, [this](const FAccelByteModelsGroupInformation& Result)
{
// Do something if CreateGroup has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if CreateGroup has an error
}));

Retrieve a List of Groups

Use the following function to 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.

FAccelByteModelsGetGroupListRequest SearchConfiguration;

SearchConfiguration.GroupName = "SomeGroupName"; // You can leave it blank if you want to fetch all the groups
SearchConfiguration.GroupRegion = "US"; // You can leave it blank if you want to fetch all the groups
SearchConfiguration.Offset = 0;
SearchConfiguration.Limit = 99;

FRegistry::Group.GetGroupList(
SearchConfiguration,
THandler<FAccelByteModelsGetGroupListResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsGetGroupListResponse& Result)
{
// Do something if GetGroupList has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetGroupList has an error
}));

Retrieve Group Information

Use the following function to retrieve information about a group by using the Group ID.

FString groupId = "SomeGroupId";

FRegistry::Group.GetGroup(
groupId,
THandler<FAccelByteModelsGroupInformation>::CreateWeakLambda(this, [this](const FAccelByteModelsGroupInformation& Result)
{
// Do something if GetGroup has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetGroup has been successful
}));

Retrieve a Player’s Group Information

Use the following function to retrieve a player’s group information. If the player you requested doesn’t belong to any group, the returned status will be ErrorCode.UserNotBelongToAnyGroup.

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 Players' Group Information

Use the following function to call the group information of other users with a specific user ID.

FString UserId = "OtherPlayerUserId";

FRegistry::Group.GetUserGroupInfoByUserId(
UserId,
THandler<FAccelByteModelsGetUserGroupInfoResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsGetUserGroupInfoResponse& Result)
{
// Do something if GetUserGroupInfoByUserId has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetUserGroupInfoByUserId has an error
}));

Retrieve a Group’s Member List

Use the following function to retrieve a group’s member list.

FString GroupId = "SomeGroupId";
FAccelByteModelsGetGroupMembersListByGroupIdRequest SearchGroupMemberConfiguration;

FRegistry::Group.GetGroupMembersListByGroupId(
GroupId,
SearchGroupMemberConfiguration,
THandler<FAccelByteModelsMemberRequestGroupResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsMemberRequestGroupResponse& Result)
{
// Do something if GetGroupMembersListByGroupId has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetGroupMembersListByGroupId has an error
}));

Update Group Information

Use the following function to update a group’s information, such as its name, icon, description, region, or type. Only members with an admin role can update the group’s information.

FString GroupId = "SomeGroupId";
FAccelByteModelsGroupUpdatable UpdateGroupConfiguration;

FRegistry::Group.UpdateGroup(
GroupId,
True, // set True if you want to replace all group informations
UpdateGroupConfiguration,
THandler<FAccelByteModelsGroupInformation>::CreateWeakLambda(this, [this](const FAccelByteModelsGroupInformation& Result)
{
// Do something if UpdateGroup has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if UpdateGroup has an error
}));

Update a Group’s Custom Attributes

Use the following function to update a group’s custom attributes. Only members with an admin role can update the group’s custom attributes.

FString GroupId = "SomeGroupId";
FAccelByteModelsUpdateGroupCustomAttributesRequest UpdateGroupCustomAttributeGroup;

FRegistry::Group.UpdateGroupCustomAttributes(
GroupId,
UpdateGroupCustomAttributeGroup,
THandler<FAccelByteModelsGroupInformation>::CreateWeakLambda(this, [this](const FAccelByteModelsGroupInformation& Result)
{
// Do something if UpdateGroupCustomAttributes has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if UpdateGroupCustomAttributes has an error
}));

Group Interaction

Join a 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.

FString GroupId = "SomeGroupId";

FRegistry::Group.JoinGroup(
GroupId,
THandler<FAccelByteModelsJoinGroupResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsJoinGroupResponse& Result)
{
// Do something if JoinGroup has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if JoinGroup has an error
}));

Cancel Join Request

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

FString GroupId = "SomeGroupId";

FRegistry::Group.CancelJoinGroupRequest(
GroupId,
THandler<FAccelByteModelsMemberRequestGroupResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsMemberRequestGroupResponse& Result)
{
// Do something if CancelJoinGroupRequest has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if CancelJoinGroupRequest has an error
}));

Leave a Group

To leave a group, you can use this function.

FRegistry::Group.LeaveGroup(
THandler<FAccelByteModelsMemberRequestGroupResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsMemberRequestGroupResponse& Result)
{
// Do something if LeaveGroup has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if LeaveGroup has an error
}))

Invite a Player o 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.

FString UserId = "SomeUserId";

FRegistry::Group.InviteUserToGroup(
UserId,
THandler<FAccelByteModelsMemberRequestGroupResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsMemberRequestGroupResponse& Result)
{
// Do something if InviteUserToGroup has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if InviteUserToGroup has an error
}));

Kick a Group Member

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

FString UserId = "SomeUserId";

FRegistry::Group.KickGroupMember(
UserId,
THandler<FAccelByteModelsKickGroupMemberResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsKickGroupMemberResponse& Result)
{
// Do something if KickGroupMember has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if KickGroupMember has an error
}));

Get a List of Group Invitation Requests

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

FAccelByteModelsLimitOffsetRequest GroupInvitationListConfiguration;

FRegistry::Group.GetGroupInvitationRequests(
GroupInvitationListConfiguration,
THandler<FAccelByteModelsGetMemberRequestsListResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsGetMemberRequestsListResponse& Result)
{
// Do something if GetGroupInvitationRequests has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetGroupInvitationRequests has an error
}));

Accept Group Invitation Request

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

FString GroupId = "SomeGroupId";

FRegistry::Group.AcceptGroupInvitation(
GroupId,
THandler<FAccelByteModelsMemberRequestGroupResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsMemberRequestGroupResponse& Result)
{
// Do something if AcceptGroupInvitation has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if AcceptGroupInvitation has an error
}));

Reject Group Invitation Request

Players can also reject any invitation request.

FString GroupId = "SomeGroupId";

FRegistry::Group.RejectGroupInvitation(
GroupId,
THandler<FAccelByteModelsMemberRequestGroupResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsMemberRequestGroupResponse& Result)
{
// Do something if RejectGroupInvitation has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if RejectGroupInvitation has an error
}));

Get List of Group Member Join Requests

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

FString GroupId = "SomeGroupId";
FAccelByteModelsLimitOffsetRequest GroupRequestListConfiguration;

FRegistry::Group.GetGroupJoinRequests(
GroupId,
GroupRequestListConfiguration,
THandler<FAccelByteModelsGetMemberRequestsListResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsGetMemberRequestsListResponse& Result)
{
// Do something if GetGroupJoinRequests has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetGroupjoinRequests has an error
}));

Accept Group Member Join Request

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

FString UserId = "SomeUserId";

FRegistry::Group.AcceptGroupJoinRequest(
UserId,
THandler<FAccelByteModelsMemberRequestGroupResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsMemberRequestGroupResponse& Result)
{
// Do something if AcceptGroupJoinRequest has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if AcceptGroupJoinRequest has an error
}));

Reject Group Member Join Request

Group admin can also reject any member join request.

FString UserId = "SomeUserId";

FRegistry::Group.RejectGroupJoinRequest(
UserId,
THandler<FAccelByteModelsMemberRequestGroupResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsMemberRequestGroupResponse& Result)
{
// Do something if RejectGroupJoinRequest has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if RejectGroupJoinRequest has an error
}));

Retrieve Bulk Users’ Presence

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

TArray<FString> UserIds;

FRegistry::Lobby.BulkGetUserPresence(
UserIds,
THandler<FAccelByteModelsBulkUserStatusNotif>::CreateWeakLambda(this, [this](const FAccelByteModelsBulkUserStatusNotif& Result)
{
// Do something if BulkGetUserPresence has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if BulkGetUserPresence has an error
}));

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.

Retrieve 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.

FAccelByteModelsLimitOffsetRequest GroupRoleListConfiguration;

FRegistry::Group.GetMemberRoles(
GroupRoleListConfiguration,
THandler<FAccelByteModelsGetMemberRolesListResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsGetMemberRolesListResponse& Result)
{
// Do something if GetMemberRoles has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetMemberRoles has an error
}));

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.

FString TargetRoleId = "SomeRoleId";
FAccelByteModelsUserIdWrapper MemberId;

MemberId.UserId = "SomeMemberId";

FRegistry::Group.AssignMemberRole(
TargetRoleId,
MemberId,
THandler<FAccelByteModelsGetUserGroupInfoResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsGetUserGroupInfoResponse& Result)
{
// Do something if AssignMemberRole has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if AssignMemberRole has an error
}));

Remove a Member’s Role

An admin can also remove a role from a member.

FString TargetRoleId = "SomeRoleId";
FAccelByteModelsUserIdWrapper MemberId;

MemberId.UserId = "SomeMemberId";

FRegistry::Group.DeleteMemberRole(
TargetRoleId,
MemberId,
THandler<FAccelByteModelsGetUserGroupInfoResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsGetUserGroupInfoResponse& Result)
{
// Do something if DeleteMemberRolehas been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if DeleteMemberRolehas an error
}));

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"
}

Here’s an example of the payload for a notification if a group admin removes a role from a player:

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