Skip to main content

Initiate User

Initializes a user session in the community. This method creates a user session and provides an access token for the user to interact with the community.

Steps to Initiate a User

  1. Call the initiateUser() method using an instance of LMChatClient.
  2. Pass the necessary InitiateUserRequest object containing the user details.
  3. Handle the response using the completion handler to check for success or errors.
let request = InitiateUserRequest.builder()
.userName("YOUR_USER_NAME")
.uuid("YOUR_UUID")
.isGuest(false)
.apiKey("YOUR_API_KEY")
.build()

LMChatClient.shared.initiateUser(request) { response in
switch response {
case .success(let result):
print("User successfully initiated. Access Token: \(result.accessToken)")
case .failure(let error):
print("Failed to initiate user: \(error.localizedDescription)")
default:
print("No response received")
}
}

Parameters

InitiateUserRequest

The InitiateUserRequest model encapsulates the necessary details to initialize a user.

VARIABLETYPEDESCRIPTIONOPTIONAL
isGuestBool?Indicates if the user is a guest✔️
uuidString?Unique identifier for the user✔️
userNameString?Name of the user✔️
apiKeyString?API key for authentication✔️

Response

The method returns an LMResponse<InitiateUserResponse> object.

InitiateUserResponse

This model contains the details of the initialized user.

VARIABLETYPEDESCRIPTIONOPTIONAL
accessTokenStringAccess token for the user session
appAccessBool?Indicates if the user has app access✔️
communityCommunity?Community details of the user✔️
hasAnswersBool?Indicates if the user answered prompts✔️
refreshTokenString?Refresh token for the user session✔️
userUser?Details of the initialized user✔️