Variables don't work in squad.
# support
p
function getRandomFullName() { const first = firstNames[Math.floor(Math.random() * firstNames.length)]; const last = lastNames[Math.floor(Math.random() * lastNames.length)]; return `${first} ${last}`; } const buttonConfig = { position: "bottom-right", offset: "40px", width: "50px", height: "50px" }; (function (d, t) { var g = document.createElement(t), s = d.getElementsByTagName(t)[0]; g.src = "https://cdn.jsdelivr.net/gh/VapiAI/html-script-tag@latest/dist/assets/index.js"; g.defer = g.async = true; s.parentNode.insertBefore(g, s); g.onload = function () { window.vapiSDK.run({ apiKey: apiKey, squad: squad, config: buttonConfig, squadOverrides: { membersOverrides: [ { assistantId: "6f82fa6a-7968-4665-a739-ea758536ba80", variableOverrides: { name: getRandomFullName(), name1: getRandomFullName(), name2: getRandomFullName() } }, { assistantId: "f186d6a1-e276-44b9-ab49-d93dc1f9f24a", variableOverrides: { name: getRandomFullName(), name1: getRandomFullName(), name2: getRandomFullName() } }, { assistantId: "14f829d7-3a43-44e2-8b53-ed0f310c32bc", variableOverrides: { name: getRandomFullName(), name1: getRandomFullName(), name2: getRandomFullName() } } ] This works for assistants. (And most code has been chopped to not run over limit).
k
Your script loads the Vapi AI SDK, assigns random names to assistant variables using getRandomFullName(), and initializes the assistants with squadOverrides; it’s functional but can be optimized to load only once and trigger the assistant without reinitializing.. https://github.com/VapiAI/client-sdk-html-script-tag
p
yeah but doesn't work for squads
@Kings_big💫
k
Your code doesn’t work with squads because squadOverrides isn’t supported instead, use assistantOverrides inside each squad member to pass random variables like names..
2 Views