howdyai / botkit-starter-web

Botkit Anywhere - a starter kit for building a bot that lives in your website or app
https://botkit.ai
MIT License
113 stars 75 forks source link

How to spawn a webbot - to start / go back to a conversation #40

Open tidjee opened 6 years ago

tidjee commented 6 years ago

Hi, In my conversation, I want to show a webpage to the user, so that he can check items he wants to order. I need to go back to the conversation afterward. When I try to spawn an instance of the bot, I'm having an error in bot.createconversation.

It use " let bot = controller.spawn({}); " which works well with facebook bot but does not seems to be enough for web bot.

I'm having the following error 👍 "info: An error occurred while sending a message: TypeError: Cannot read property 'json' of undefined"

When I look at the code, it's bot.http_response that is undefined.

Here is the code :

goto_checkout: function (controller, message) {
    let bot = controller.spawn({});
    bot.createConversation(message, this.checkout);
},

Many thanks !

DnsFilth commented 6 years ago

Hi, I'm getting the same error, did you find out how to do it?

peterswimm commented 6 years ago

Take a look over here: https://github.com/howdyai/botkit-starter-web/blob/master/docs/botkit_web_client.md#embed-botkit-in-a-website-with-iframes

DnsFilth commented 6 years ago

so this function doesn't work?

function sendAlertToBot(alert_message) { controller.spawn({}, function(bot) { bot.say(alert_message); }); }