Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use setMuted from within the Widget #22

Open
TediMcboy opened this issue Apr 19, 2024 · 0 comments
Open

Unable to use setMuted from within the Widget #22

TediMcboy opened this issue Apr 19, 2024 · 0 comments

Comments

@TediMcboy
Copy link

TediMcboy commented Apr 19, 2024

As instructed by the widget docs, i am utilizing the script of "https://cdn.jsdelivr.net/gh/VapiAI/html-script-tag@latest/dist/assets/index.js" which i was told could be outdated.

the vapiInstance object can access start(), stop(), send(), etc.. but setMuted is not accessible despite it being built directly from the sdk. It appears that function was simply not exposed but even when i tried the following:

function initializeVapi(vapiObject, assistant, buttonConfig) {
          console.log("Vapiobject: ", vapiObject);
          var vapiInstance = vapiObject.run({
          apiKey: "my api key",
          assistant: assistant,
          config: buttonConfig,
          });
         console.log("setMuted directly:", vapiInstance.setMuted);

         vapiInstance.setMuted = function(muted) {
           const sdk = window["@vapi-ai/web"]|| window.vapiSDK;
           console.log("vapiInstance methods: ", Object.keys(vapiInstance));
           console.log("SDK methods: ", Object.keys(vapiObject));
  
            if (sdk && sdk.setMuted) {
              sdk.setMuted(muted);
            } else {
              console.error("setMuted function not available in the SDK");
            }
           };

        console.log("vapiInstance methods: ", Object.keys(vapiInstance));
        const vapi_widget = document.getElementById("vapi-support-btn");
        vapi_widget.classList.add("override-position");
        setupEventListeners(vapiInstance);
        setupPauseButton(vapiInstance);
      }

setMuted is not accessible via that sdk object either which is just the script. when i add that, setMuted becomes an accessible method in Object Keys but thts just in the vapiInstance object. That does not fix the issue that the sdk object itself cannot access it. To clarify, it doesn't matter wether i use window["@vapi-ai/web"] or window.vapiSDK, setMuted is not accessible in either. That was more of debugging code a while back and i'm using django framework and just installed npm so my setup is a little wonky. everything works perfectly except for whatever reason i cannot access setMuted() or isMuted(). Can anyone help me with this? It appears to just not be exposed in the vapiInstance object so i thought i could access directly from the sdk object and define the function myself through vapiInstance but all that does is make the function an accessible method but not actually functional. This is the very last thing I need to complete my web app and it's the only thing thats giving me a headache about this. I love the platform so much and it's fantastic, I really need to find a way to make this work in the widget as soon as possible. I can provide all of my code if needed, the fact of the matter is that through the sdk object i can't even access it which is a red flag off the bat. If it's not accessible there, there's nowhere else I would be able to get it. Thanks so much!

Screenshot 2024-04-19 at 11 13 45 AM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant