Setting the user type
WebPlanetKit provides a feature to set a user type when joining a group call, enabling your application to distinguish between different categories of users.
You can define custom user types (for example, regular users and bots) and tailor your application's behavior or UI based on the user type. Additionally, LINE Planet reserves certain user type values for built-in agent roles.
Supported call type | Minimum SDK version |
---|---|
Group call (conference) | WebPlanetKit 5.4 |
User types
User types are classified as follows:
- Custom user types
- User types defined and managed by your application
- Value range: 1 to 9999
- PlanetKit user types
- User types used internally by LINE Planet to represent agent roles, defined in
PLANET_KIT_USER_TYPE
- Value range: 0, 10000 to 99999
- For more information, see the Agent call documentation.
- User types used internally by LINE Planet to represent agent roles, defined in
Sample code
The following sample code shows how to use the feature to set the user type.
Define and set the user type
Define the application user types according to your requirements. When joining a group call, set a user type using customUserType
property of ConferenceParams
.
const SAMPLE_BOT_TYPE = 100;
const conferenceParams = {
...,
customUserType: SAMPLE_BOT_TYPE
};
planetKit.joinConference(conferenceParams)
.then(() => {
// Successfully joined a conference
})
.catch((joinConferenceError) => {
// If the value of `customUserType` is invalid, joining a conference will fail with the reason code `INVALID_CUSTOM_USER_TYPE`.
});
Implement actions for each user type
Implement actions to be processed according to each user type. You can use the APIs of UserTypeContainer
to check for the user type.
const onEvtPeerListUpdated = (peerListUpdatedParam) => {
const { addedPeers, removedPeers, totalPeersCount } = peerListUpdatedParam;
addedPeers.forEach((peer) => {
if (peer.userType.getCustomUserType() === SAMPLE_BOT_TYPE) {
console.log("Sample bot has joined.");
}
});
removedPeers.forEach((peer) => {
if (peer.userType.getCustomUserType() === SAMPLE_BOT_TYPE) {
console.log("Sample bot has left.");
}
});
};