Add custom css to your chatbot widget

  • Description: Apply your own css to the chatbot widget and style it as per your branding.
  • Syntax: window.$sitegpt.push(["set", "css", "css_string"])
// Example: Setting the primary color of chatbot widget to green.

window.$sitegpt.push(['set', 'css', ':root { --chat-color: green; }'])

Give extra context to your chatbot

  • Description: Give more information to your SiteGPT bot for contextual conversations.
  • Syntax: window.$sitegpt.push(["set", "context", ["prompt_prefix_string", "prompt_suffix_string"]])
// Example: Giving the current page URL as extra context to the chatbot

window.$sitegpt.push([
  'set',
  'context',
  [
    'You are an experienced sales executive. You need to guide the user to book a demo call.',
    'Current Page: Pricing Page \n Current Page URL: https://sitegpt.ai/pricing',
  ],
])

Automatically log the user in

  • Description: Automatically log the user in, in the chatbot widget. The users need not enter/verify their email manually.
  • Syntax: window.$sitegpt.push(["set", "user:email", ["email_string", "email_signature_string"]])
// Example: Automatically logging in the user with email user@company.com.

window.$sitegpt.push([
  'set',
  'user:email',
  [
    'user@company.com',
    'cd7cc422ea97c82d844b2373fdcd6259c9ee6e135af65ab6fe6ca85e3f07abb1',
  ],
])

To generate the signature, you can use the following code:

const crypto = require('crypto')

// Put you api key here (keep it private!)
// Note: the one below is an example, yours will be different and can be found on sitegpt.ai/billing page
const apiKey = '6338d1ac-9afc-4a7c-8812-ba9e3f8c48eb'

// This method signs an email, using your own 'API Key'
function signEmail(email) {
  return crypto.createHmac('sha256', apiKey).update(email).digest('hex')
}

// Sign your email
// Notice: the email below is an example, yours will be sourced from the logged-in user
var signature = signEmail('user@company.com')

console.log('signature is:', signature)

Make sure you generate signatures with the HMAC-SHA256 algorithm.
Any other HMAC digest is not accepted and will be refused by SiteGPT chatbot when provided.

What makes User Verification secure?

User Verification makes use of the HMAC-SHA256 signature algorithm. It is recognized as secure and is widely used to authenticate data across the internet.

When setting a user email via the SiteGPT’s JavaScript SDK, you should also set the signature parameter with the signature computed on your backend.

This signature is computed using your API key, that only you and SiteGPT know. So, only SiteGPT and you are able to generate valid signatures for a given email. An attacker without your API key will not be able to generate valid signatures, and thus will not be able to impersonate users chatting with you.

Never generate signatures directly in your front-end.
If you do that, your API key will be exposed and anyone who has the API key can impersonate other users.
Always generate all your signatures on your backend, and never leak your API key.