Smooch.io .createConversation() is not a method

348 Views Asked by At

I have a chatbot based on Smooch.io and I am trying to show a menu on chat initialization so user can start from here instead of typing anything.

As far as I understand from the docs, to do that I need to create conversation Smooch.startConversation(); and then send stuff from my backend app. However it gives me "Smooch.startConversation();" error.

So my question is 1) What I am doing wrong here?; 2) Is there any other way to show initial menu instead of starting conversation without user yet messaging anything?

1

There are 1 best solutions below

2
On BEST ANSWER

Assuming you're using the latest version of the SDK, you're probably calling startConversation before the SDK has finished initializing.

You should wait for the promise returned by init to resolve before calling startConversation. Like this:

Smooch.init({appId: '<app-id>'})
  .then(() => {
    Smooch.startConversation();
  })