1

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?

alv_721
  • 305
  • 3
  • 18

1 Answers1

1

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();
  })
Spasiu
  • 185
  • 2
  • 9
  • actually I am calling `Smooch.startConversation();` in onReady block (and i assume it means Smooch is initialized already) – alv_721 Dec 05 '17 at 13:07
  • onReady doesn't mean that Smooch is initialized. The `Smoochinit` call is asynchronous and returns a Promise which it resolves when complete. – Spasiu Dec 05 '17 at 20:01