Authentication
Providing customer details
By default, customers chatting with you will be anonymous. You can pass customer details, if you know them, in the Plain.init
function call:
These details will be shown to you in the Plain app when you are chatting with the customer but they will not be matched to an existing customer even if they have the same details.
Matching chat users to existing customers
If you want to match the customer to an existing customer in your workspace, you will need to pass their email. To avoid security issues around impersonation you will also need to provide the email address hashed using a shared secret. You can generate this secret in the Chat settings page in the Plain app.
Once you have this secret, you can calculate the hash. This must be done in backend code to avoid leaking the secret. If your secret is leaked malicious users will be able to impersonate your customers in chats.
Backend code:
Then you can request the hash from your backend and init Plain:
Customer verification
If you want to see the name and email of customers who get in touch via chat you can require them to provide their details
by setting requireAuthentication
to true in Plain init:
When enabled, any customer getting in touch will first be presented with a form allowing them to enter their name and email address.
The customer will then receive a verification code to that email which they can enter to start a chat.
If an emailHash
is already set in customerDetails
, then the verification screen will not appear since the customer has already been authenticated.
Was this page helpful?