facebook messenger - How to answer back with images in wit.ai? -


i trying create fb_messenger bot using wit.ai.in wit.ai,i can answering , question text.but want answering user showing images.how it?please guide me. thank much.

you need send image in wit action using messenger bot:

example if you're using node js:

const actions = { /**  * used "bot sends" action in wit  * @param sessionid  * @param text  * @returns {promise.<t>}  */ send({sessionid}, {text}) {     // our bot has say!     // let's retrieve facebook user session belongs     const recipientid = sessions[sessionid].fbid;     if (recipientid) {         // yay, found our recipient!         // let's forward our bot response her.         // return promise let our bot know when we're done sending         //bot simple wrapper messenger node code provided [here][1]         return bot.sendtextmessage(recipientid, text)             .catch((err) => {                 console.error(                     'oops! error occurred while forwarding response to',                     recipientid,                     ':',                     err.stack || err                 );             });     } else {         console.error('oops! couldn\'t find user session:', sessionid);         // giving wheel our bot         return promise.resolve()     } }, ['my-custom-action']({sessionid, context, entities, message}) {     //api calls ...     //now got image url want send user     return bot.sendimagemessage(recipientid, image_url);      return promise.resolve(context) }, 

don't forget delete "bot sends" part story on wit.ai, don't send both image , url.

hope helps!


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -