Initiate User
To start using the LikeMinds Chat and enable personalized experiences for your users, you need to initiate them within the system. This process associates a user in your application with a user in the LikeMinds Chat, allowing for seamless integration and realtime messaging in your application.
Steps to initiate a User
- To initialise a user, use the method
initiateSDK()
provided by the LikeMinds client you created. - Pass in the required
userUniqueId
anduserName
to the function. An optional parameterisGuest
to be provided if the logging profile is of the guest user. - Use the response as per your requirement
//Set userId to custom user ID present in your database,
//or keep it blank to get one generated by the SDK
const userUniqueId = "YOUR_USER_UNIQUE_ID";
const userName = "YOUR_USERNAME";
const payload: any = {
isGuest: false, // true for guest user
userUniqueId: "", // user unique ID you get from dashboard
userName: "name", // user name
};
const response = await lmChatClient.initiateUser(payload);
if (response.success) {
// your function to process the response data
processResponse(response);
} else {
// your function to process error message
processError(response);
}
Initiate User Request
List of parameters provided by initiateUser()
Variable | Type | Description | Optional |
---|---|---|---|
userUniqueId | string | Unique ID for the userId | |
userName | string | Name of the userName | |
isGuest | boolean | Is the user a guest? | ✔️ |
Initiate User Response
List of parameters for the response
Variable | Type | Description | Optional |
---|---|---|---|
success | boolean | API success status | |
errorMessage | string | Error message in case of failure | ✔️ |
user | object | User details | |
community | object | Community details |
Member State
When building out your chat experience, you might want to moderate some actions based on the state of a community member. That's where member state comes in. With a single getMemberState()
function you can determine if a member is a CM, or not.
const payload: any = {
memberId: 23233, // id of the current user
};
const response = await lmChatClient.getMemberState(payload);
if (response.success) {
// your function to process the response data
processResponse(response);
} else {
// your function to process error message
processError(response);
}
Get Member State Payload
List of parameters provided by initiateUser
Variable | Type | Description | Optional |
---|---|---|---|
memberId | string | ID for the user |
Get Member State Response
List of parameters for the response
Variable | Type | Description |
---|---|---|
success | boolean | API success status |
error_message | string | Error message in case of failure |
member | object | Member details |
member_rights | object | Member rights |