crisp-im / crisp-sdk-web

:package: Include the Crisp chat widget from using frameworks such as React, VueJS, Angular...
https://www.npmjs.com/package/crisp-sdk-web
MIT License
39 stars 13 forks source link

Add `setChatView()` alongside `setHelpdeskView()` method #25

Open partyparrotgreg opened 9 months ago

partyparrotgreg commented 9 months ago

Hey, I see I can set the Helpdesk View (Crisp.chat.setHelpdeskView()) but I can't do a similar thing to switch to Chat View (e.g. Crisp.chat.setChatView()). This could be handy for hooking up my UI elements to the desired action (either talking to someone or checking the helpdesk topics). Small thing but IMHO it improves the experience.

I tried to fork and add it on my own, but it looks like I can't toggle between Chat and Helpdesk view with the $crisp.push(["do", "chat:open"]) method.

  setHelpdeskView() {
    this.parent.createSingletonIfNecessary();

    window.$crisp.push(['do', 'helpdesk:search']);
  }

  setChatView() {
    this.parent.createSingletonIfNecessary(); // or this.parent.autoInjectIfNecessary(); ?

    window.$crisp.push(['do', 'chat:open']);
  }

Let me know what am I doing wrong 😅 Cheers

eliottvincent commented 5 months ago

Hey! The thing is that this is simply not natively possible with our underlying JS SDK, yet.