Personalization API
Personalize conversation for your user by passing personal data to Molin automatically. Also, instruct the AI dynamically with custom AI instructions.
Intro
You can pass 2 types of data to your AI on your website:
-
User data (e.g. your customer’s email, name, ID) in a simple JSON format
-
Custom instructions for the AI to follow (in addition to the instructions configured via our dashboard on the Personality page)
Both of these will appear in the dashboard (on the Inbox page) for your agents to see. Both of these will be passed to your AI to help it generate relevant responses to your user.
Demo
We prepared a demo environment that shows you an example implementation: Demo: Personalization API | StackBlitz.
How to pass data
You will pass data through the Molin AI widget. The widget is either installed automatically (if your platform uses our plugin, e.g. Shopify, UNAS, Shoprenter) or it is embedded manually (if you use a custom platform).
The snippet for manually embedding the widget looks like this:
You can always find yours on the Publish page in our dashboard.
Option 1. Automatic injection (recommended)
Simply include your data in a <script>
tag, placed anywhere inside the <head></head>
section of your website:
When the widget loads, it will automatically read the data from window.molinSettings
.
Using this method, you must ensure that the <script>
snippet above exists inside the <head></head>
section of your website before the browser emits the load event. Ideally, it should be rendered on the server.
Option 2. Inject directly into the component (advanced)
If you manually render the custom components <molin-shop-ai>
or <molin-shop-ai-chat>
, you can assign data programmatically:
Pay attention to the type of each property: userData
is an object, customInstructions
is a string. Please see below the data format section.
Data formats
User data
You must pass user data as a stringified JSON object. Only primitve types are allowed, no nested objects or arrays.
The user data must satisfy this TypeScript type:
And this valibot schema:
This is an example of valid user data:
This is an example of bad user data (it contains nested objects/arrays):
Custom instructions
You must pass custom instructions as a string, in plain text or markdown.
The minimum length is 1 character and the maximum is 5000 characters. If you pass an empty string, the attribute will be ignored.
Data persistence
Molin’s client side widget remembers the most recently active conversation. If you inject user data or custom instructions, they will be remembered for the duration of the conversation. Therefore, it is mandatory to reset the widget when the user logs out:
Security
Data handling
You must understand how user data and custom instructions are handled by Molin:
-
Both are stored in our database, encrypted at rest and in transit.
-
Both are visible to your agents in the dashboard. Verify the Settings > Members page in our dashboard to check who has access to view this data.
-
Both are shown to the LLM we use to generate AI responses. Assume that this data can be shown to the user in its entirety, even if the AI is usually smart enough to only disclose the specific information the user is asking for.
Protection against session reuse
You must ensure that you reset the widget when the user logs out. This is to prevent the next user from seeing the previous user’s data when continuing the conversation. See Data persistence.