ChatFlow "responseExpected": it does not work

Hi AlexCornejo,

Again, the reason you’re stuck in a loop is because the exports.main function is called again when responseExpected is set to true. The reason it behaves like this is to give you a chance to do something based on the visitor’s response.

For the purpose of getting your example to work, the below should do the trick. It’s not particularly useful because it doesn’t change the chatflow’s behaviour based on the visitor’s selection --> it simply let’s the visitor choose an option and then goes to the “next_module” without acting on the visitor’s choice. But hopefully, it’ll get you on the right track :grinning_face_with_smiling_eyes:

exports.main = (event, callback) => {
 if (event.userMessage.quickReply == null) {
 // this block will run if there are no quick replies in the event object
 const responseJson = {
 botMessage: "select an option",
 quickReplies: [ { value:'option_1', label:'Option 1' }, { value:'option_2', label:'Option 2' } ],
 nextModuleNickname: "next_module",
 responseExpected: true
 };
 callback(responseJson);
 } else {
 // this block will run if the event object contains quick reply messages
 // (i.e. when someone has selected any option in their most recent reply)
 const responseJson = {
 nextModuleNickname: "next_module"
 };
 callback(responseJson);
 }
};

All the best,

Zach