Hello Iām new to botpress
Problem: I need a custom frontend
I am aware that botpress can be integrated into websites but that limits the customization of the looks of my bot. So I created a webpage with my desired ui and with the help of chat gpt wrote the JavaScript code to handle the sending of data from my webpage to my chatbot using Access token and bot Id.
I tested it on local host got an error. Hosted the page with ssl still got an error. So I donāt know whatās wrong š. Maybe Iām just approaching it all wrong
If there are any alternatives or solutions to this Iād love to hear it, thank you
This is a snippet from the JavaScript
// š Shared function for both voice + text input
async function handleUserMessage(userText) {
output.innerHTML += `
You:
${userText}`;
try {
// Send to Botpress API
const res = await fetch("https://api.botpress.cloud/v1/converse/YOUR_BOT_ID", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_KEY"
},
body: JSON.stringify({
user: "demo-user", // Can be dynamic per user/session
text: userText
})
});
const data = await res.json();
const botReply = data.responses?.[0]?.text || "[No reply]";
output.innerHTML += `
Bot:
${botReply}`;
// Speak reply
const utter = new SpeechSynthesisUtterance(botReply);
speechSynthesis.speak(utter);
} catch (error) {
console.error("Error talking to Botpress:", error);
output.innerHTML += `
Bot:
[Error connecting to Botpress]`;
}
}
https://cdn.discordapp.com/attachments/1410600811389648946/1410600811964403763/DD6EF73E-BDDD-431F-9287-3EF1CF66F9AB.png?ex=68b19be1&is=68b04a61&hm=febb64129d7488484a58702c95cd09e4940e5622f67a164dc58e7b722705b04d&