An in-depth guide on how to use $sitegpt to control the SiteGPT chatbot from your javascript code.
$sitegpt
object allows you to interact with and control the SiteGPT chatbot widget embedded on your website. You can use it to customize appearance, provide context, manage user sessions, and control the widget’s visibility.
Commands are sent using the push
method: window.$sitegpt.push([command, ...args])
.
window.$sitegpt.push(["set", "css", "css_string"])
window.$sitegpt.push(["set", "context", ["prompt_prefix_string", "prompt_suffix_string"]])
window.$sitegpt.push(["set", "user:email", ["email_string", "email_signature_string"]])
HMAC-SHA256
signature algorithm, a standard and secure method for authenticating data.
When setting a user email via the $sitegpt
object, you must provide the signature computed on your backend. This signature uses your secret API key, known only to you and SiteGPT. Because only you and SiteGPT can generate valid signatures for a given email, an attacker without your API key cannot impersonate users.
hideBubble=true
in the embed script) and want to trigger the chat from your own UI elements (like a button).
window.$sitegpt.push(["open"])
window.$sitegpt.push(["close"])
window.$sitegpt.push(["toggle"])