There are four ways a user record can be created on the Sunshine Conversations platform:
createConversation
is called.login
is called.See below for an explanation of each of these four ways.
You can create user records by calling the create user endpoint. For example, using the Node.js API library:
const apiInstance = new SunshineConversationsApi.UsersApi();
const data = SunshineConversationsApi.UserCreateBody();
data.externalId = "<new_external_id>";
apiInstance.createUser("<sunshine_conversations_app_id>", data)
.then(response => /* success */)
.catch(error => /* failure */);
You would create users in order to pre-populate them with data from your platform, authenticate them, and add them as participants to conversations.
When you integrate a messaging channel to Sunshine Conversations, and a person initiates a conversation with a business over that messaging channel, the Sunshine Conversations platform will automatically create a user record to represent the person your business is talking to.
That user will appear as a participant in the conversation, and can be accessed by listing the conversation participants as usual.
The Messaging SDKs for Android, iOS, and Web expose methods to create a new default conversation when none exists. This can be used if you want to programatically initiate a conversation between your business and someone on a device or webpage.
If no user record already exists to support that conversation, the Sunshine Conversations platform will automatically create a user record to represent the person your business is talking to.
That user will appear as a participant in the conversation, and can be accessed by listing the conversation participants as usual.
For example, using the Web SDK, the following call would create a new user record if none existed on the platform:
Smooch.init({ integrationId: '<sunshine_conversations_integration_id>' })
.then(() => Smooch.createConversation());
The Messaging SDKs for Android, iOS, and Web expose login
methods to authenticate users.
The authentication is performed by pairing a unique externalId
property with a JSON Web Token created for that particular external ID and signed with a Sunshine Conversation app key. For more information on authenticating users see this guide.
Even if no user record exists with that externalId
property, a valid ID/token pair will result in a sucessful login, and a user record will be automatically created on the Sunshine Conversations platform with the ID used to login.
For example, using the Web SDK, the following call would create a new user record if none existed on the platform:
Smooch.init({integrationId: "<sunshine_conversations_integration_id>"})
.then(() => Smooch.login("<external_id>", "<json_web_token>"));