alavers/smooch-bot

Send image to users from smooch-bot

qadirsuh opened this issue · 9 comments

I have gone through the source code of smooch-bot.
there is a method bot.say()

i.e https://github.com/smooch/smooch-bot/blob/master/lib/bot.js#L15
say(text) { return new Promise((resolve) => { // Do nothing resolve(); }); }

and is responsible to send the text message to user. Right?

I want to send the image to users from smooch-bot
is there anything like that in this smooch-bot?

something like

sendImage(image) { return new Promise((resolve) => { // Do nothing resolve(); }); }

I got it

bot.say(![]("http://3540eob9sfqvwwmw3ldxigj4.wpengine.netdna-cdn.com/wp-content/uploads/2014/03/Phew-man-575.jpg"))

Suddenly I got error in sending image i.e

(node:17) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: Bad Request

here is my code.

bot.say(![]("http://3540eob9sfqvwwmw3ldxigj4.wpengine.netdna-cdn.com/wp-content/uploads/2014/03/Phew-man-575.jpg"))

Please need urgent reply

Your "s seem misplaced. Maybe you wanted this?

bot.say("![](http://3540eob9sfqvwwmw3ldxigj4.wpengine.netdna-cdn.com/wp-content/uploads/2014/03/Phew-man-575.jpg)")

Oop. Oh my God.
This worked. Thanks your help.

I want to ask one more question.
Can I send multiple images in a single bot.say() method, Something like
bot.say("![](http://3540eob9sfqvwwmw3ldxigj4.wpengine.netdna-cdn.com/wp-content/uploads/2014/03/Phew-man-575.jpg) ![](http://3540eob9sfqvwwmw3ldxigj4.wpengine.netdna-cdn.com/wp-content/uploads/2014/03/Phew-man-575.jpg) ![](http://3540eob9sfqvwwmw3ldxigj4.wpengine.netdna-cdn.com/wp-content/uploads/2014/03/Phew-man-575.jpg) ![](http://3540eob9sfqvwwmw3ldxigj4.wpengine.netdna-cdn.com/wp-content/uploads/2014/03/Phew-man-575.jpg) ![](http://3540eob9sfqvwwmw3ldxigj4.wpengine.netdna-cdn.com/wp-content/uploads/2014/03/Phew-man-575.jpg)")

I tried like above, here is the result
http://prntscr.com/dlm657

Only first Image is shown. Please help me in this regard.
thanks

Can I send multiple images in a single bot.say() method

No, but you can send separate messages of 1 image each.

I must say, thanks for your time first.
OK, I have shown the multiple images with separate messages of 1 image each. (as suggested you above).

OK. one more question. I want the Image to be clickable. Like in my scenario I want to show user/guest some list of foods available in our Restaurant with images. Now user click on a food image they like, and food will be ordered.

I can't see any method to make image clickable. is there any way to do so. or any alternate method. please share with some code

Regards
Qadir

This is not currently possible. What you can do is include a link action button below each image message.

If you must have the image itself be clickable, the closest thing we support is a list message with a default behavior (default: true). However, list messages are only supported on facebook messenger and LINE, and default image tap behavior is only currently supported on facebook messenger.

The Smooch web messenger does not yet built support for list messages natively, but I suspect work will begin on this in the new year.

@alavers is there any cheat sheet (syntax) to show list message like we show image using below code
bot.say(![]("http://3540eob9sfqvwwmw3ldxigj4.wpengine.netdna-cdn.com/wp-content/uploads/2014/03/Phew-man-575.jpg"))