Hi @RyanL - I’m not a coder but try adding this to your JavaScript section.
(function() {
var script = document.createElement('script');
script.src = 'https://cdn.customgpt.ai/js/chat.js';
script.defer = true;
script.onload = function() {
CustomGPT.init({
p_id: '#####', // Replace ##### with your project ID
p_key: '################' // Replace ################ with your project key
});
};
document.head.appendChild(script);
})();
Don’t forget to replace your placeholders:
This code creates a new element dynamically and sets its src attribute to the CustomGPT library URL. It should initialise the CustomGPT chat using your provided Project ID and Project Key once the script has loaded. By doing this, you should be able to effectively embed the CustomGPT chatbot in your Knack application.
@CarlHolmes@RyanL, I don’t have an alternate solution, but be mindful that anyone can access your chatbot’s project ID/API key if you specify it in the Knack JavaScript editor.
@BradStevens would storing the API key in a Zapier, Make, or Power Automate flow, and making a webhook to return the key suffice? Ideally it should only occur on page load if it’s a chatbot widget, so as not to consume too many third-party API calls/operations.
@StephenChapman I think that’d help obfuscate it but not prevent someone from setting a breakpoint in the browser and then read the variable unfortunately. Happy to be proven wrong on this!