If you’re loading the
Smile.js script asynchronously, you should wrap your initialization code within a loaded event to ensure it doesn’t encounter an error due to the script not yet being present on the page.Parameters
A required object with the following keys:
channel_key- Your Smile.io Public Key. This is used for identifying your store and can be made public. Refer to the help docs for where to find it.customer_identity_jwt- A signed JWT for the currently logged in customer on your site. See instructions below for generating a signed JWT. This should be null if no customer is currently logged in.
Generating a signed JWT
The signed JWT is what’s used to verify your store is the one requesting information from Smile.io on behalf of a customer. It should be generated using your platform’s server side language so your Smile.io Private Key remains secret. It must also have an expiration, for which we recommend 5 minutes.Payload of the JWT
The payload of the JWT should be a hash containing the unique identifier in your system for the currently logged in customer. For example, if your Smile account is connected to Shopify, the unique identifier would be the Shopify Customer ID (e.g.123456, not gid://shopify/Customer/123456). This value should never be the Smile Customer ID.
We require the following format, where 100 is the customer’s unique identifier. Depending on the backend language and JWT library you’re using, you may need to include the JWT’s expiry directly in the payload.
JSON
Code sample
Ruby