2

I cannot get quickreplies to work in node-wit messenger.js example. I tried may things including: 1) Updated this line of code Our bot actions (messenger.js):

const actions = { send({sessionId}, {text,quickreplies})

2) And Updated this line of code Our bot actions (messenger.js):

return fbMessage(recipientId, text,quickreplies)

3) Updated my custom action in messenger.js :

getWelcome({context, entities})
 {
      context.welcome = "how are you. Please select from the options below"; 
    context.welcome.quickreplies = [
    { 
      title: 'Choice A',
      content_type: 'text',
      payload: 'empty'
    },
    { 
      title: 'Choice B',
      content_type: 'text',
      payload: 'empty'
    },
   ]

return context;
  }, 

4) I tried so many permutations. I cant get it to work with node-wit messenger.js example. The quick repliess are not displayed I searched and read all documentation

5) Can you help with this and also exactly how to retrieve the quick reply selected in messenger.js

Thanks

1 Answers1

0

Sorry if it is late, but I guess you were looking for this:

send(request, response) {
  const {sessionId, context, entities} = request;
  let {text, quickreplies} = response;
  if(text.substring(0,6) === IDENTIFY_PAYLOAD){
    text = text.substring(6); // It is a payload, not raw text
  } else {
    text = {"text": text};
  }
  if(typeof quickreplies !== "undefined"){
    text.quick_replies = response.quickreplies
      .map(x => { return {
        "title": x, "content_type": "text", "payload": "empty"}
    });
  }
}

What I did was sending a payload with a string that identifies it is not raw text (That's why I use an identifier for a payload), then in the send action I receive the two parameters request and response, and I get their attributes. Finally, I convert the payload params using a routine which I find on internet and that in fact works well to map the quick replies.

sgelves
  • 134
  • 1
  • 12