BuildShipBBuildShip
Powered by
KadongK
BuildShip•2y ago•
3 replies
Kadong

How to add custom field for POST on chat widget assistant?

I'm trying to add a custom input inside the form when that chat widget is rendered. It doesn't show on my logs. This is the remix link https://buildship.app/remix/2618166a-add2-4e3b-9d8b-c3b1cae9490c

Here's my script:
function addCustomField() {
const inputElement = document.getElementById("buildship-chat-widget__input");
if (inputElement) {
// Check if the hidden input already exists by name or id
if (!document.querySelector('input[name="user_role"]')) {
// Create hidden input element
const hiddenInput = document.createElement("input");
hiddenInput.type = "hidden";
hiddenInput.name = "user_role"; // Add name attribute
hiddenInput.value = "default_role"; // You can customize this value as needed

// Insert the hidden input after the input element
inputElement.parentNode.insertBefore(hiddenInput, inputElement.nextSibling);

console.log("Hidden input 'user_role' added.");
} else {
console.log("Hidden input 'user_role' already exists.");
}
} else {
console.error("Chat input field not found.");
}
}

Thank you in advance!
image.png
BuildShip - Visual backend workflow builder
Visually build workflows and powerful backend logic for your apps. Powered by AI, connect to anything with or without code.
BuildShip - Visual backend workflow builder
BuildShip banner
BuildShipJoin
Join founders, builders, devs using Low-code / No-code to create backend, APIs, scheduled Jobs, automation, AI workflows
7,971Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Streaming assistant showing json in chat widget
Tim StewartTTim Stewart / ❓・buildship-help
2y ago
Widget for AI Assistant seems not to work
Luca MarchettiLLuca Marchetti / ❓・buildship-help
14mo ago
Unable to get chat widget
Answer OverflowAAnswer Overflow / ❓・buildship-help
2y ago
Chat assistant nodes is not asking for description?
RichieRRichie / ❓・buildship-help
15mo ago