Skip to main content

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

  1. Create a InitiateUserRequest object using user credentials.
  2. For initiating a user, call initiateUser() function using the instance of LMChatClient class.
  3. 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
String userId = "3000";
String userName = "Tony Stark";

InitiateUserRequest request = (InitiateUserRequestBuiler()
..userName(userName)
..userId(userId)).build();

final LMResponse<InitiateUserResponse> response = await lmChatClient.initiateUser(request);
tip

We suggest that you use the unique ID from your database for the user so that you do not have to save the one we generate.

Models

InitiateUserRequest

List of parameters for the InitiateUserRequest class

VariableTypeDescriptionOptional
userIdStringUnique ID for the userId
userNameStringName of the userName
imageUrlStringURL of the user's profile image✔️
isGuestboolIs the user a guest?✔️

InitiateUserResponse

List of parameters for the InitiateUserResponse class

VariableTypeDescriptionOptional
successboolAPI success status
errorMessageString?Error message in case of failure✔️
initiateUserInitiateUser?User and community details✔️

Initiate User

List of parameters used in InitiateUser

VariableTypeDescriptionOptional
userUseruser data
communityCommunitycommunity data

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.

final bool isCM = await lmChatClient.getMemberState();