# ChatFlow "responseExpected": it does not work

**URL:** <https://community.hubspot.com/t/chatflow-responseexpected-it-does-not-work/28919>\
**Category:** APIs & Integrations\
**Tags:** workflows, object\
**Created:** [December 8, 2020, 11:10pm UTC](https://community.hubspot.com/t/chatflow-responseexpected-it-does-not-work/28919 "2020-12-08T23:10:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlexCornejo](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alexcornejo/32/29892_2.png) [@AlexCornejo](https://community.hubspot.com/u/AlexCornejo)\
**Post date:** [December 8, 2020, 11:10pm UTC](https://community.hubspot.com/t/chatflow-responseexpected-it-does-not-work/28919/1 "2020-12-08T23:10:21Z")

</div>

Dear,

I’m doing a chatflow with code snippet 🙂 Using your own example:

_exports.main = (event, callback) =\> {_  
_var responseJson = {_

_“botMessage”: “Select one option”,_  
_“quickReplies”: [{ value:'op1 ', label:‘op1’ }, { value:‘op2’, label:‘op2’}],_  
_“responseExpected”: false_  
_};_  
_callback(responseJson);_  
_};_

This one won’t let me respond.

I’ve looked for documentation and it doesn’t exist. Do you have any idea how to make it work?

Thanks a lot.

---

<div class="post-metadata">

**Author:** ![zaklein](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/zaklein/32/44431_2.png) [@zaklein](https://community.hubspot.com/u/zaklein)\
**Post date:** [December 9, 2020, 3:21pm UTC](https://community.hubspot.com/t/chatflow-responseexpected-it-does-not-work/28919/2 "2020-12-09T15:21:28Z")

</div>

Hi Alex,

I think changing the value of the _ **responseExpected** _ key to _ **true** _ will do the trick, i.e. --\>

_“responseExpected”: true_

Hope that helps 🙂

Zach

---

<div class="post-metadata">

**Author:** ![AlexCornejo](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alexcornejo/32/29892_2.png) [@AlexCornejo](https://community.hubspot.com/u/AlexCornejo)\
**Post date:** [December 9, 2020, 4:51pm UTC](https://community.hubspot.com/t/chatflow-responseexpected-it-does-not-work/28919/3 "2020-12-09T16:51:43Z")

</div>

Hi Zaklein 🙂

- **False** doesn’t let me respodner but it goes to the next node.
- **True** lets me answer but asks me the same infinitely. if here it could go to the next node it would work perfect. Try "nextModuleNickname: ‘nextNode’ but it doesn’t work.

Do you have any idea how to make it work?

Thank

---

<div class="post-metadata">

**Author:** ![zaklein](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/zaklein/32/44431_2.png) [@zaklein](https://community.hubspot.com/u/zaklein)\
**Post date:** [December 9, 2020, 5:29pm UTC](https://community.hubspot.com/t/chatflow-responseexpected-it-does-not-work/28919/4 "2020-12-09T17:29:52Z")

</div>

Hi again AlexCornejo,

If _ **responseExpected** _ is set to _true_, the _ **exports.main** _ block is called again after the chatflow visitor has responded. This gives you the chance to change the chatflow’s behaviour based on the visitor’s response to the questions you ask using _ **quickReplies** _.

If you want to move to a specific module after the visitor has responded to your _ **quickReplies** _ question, try using _ **nextModuleNickname** _ --\> to find the target chatflow module’s “nickname”, go out to your chatflow view, click the module and copy the value in the “Action name (internal only)\*” field.

```lia-code-sample
exports.main = (event, callback) => {
 var responseJson = {
 "botMessage": "Select one option",
 "quickReplies": [{ value:'op1', label:'op1' }, { value:'op2', label:'op2' }],
 "nextModuleNickname": "Target next module 'Action name' / nickname",
 "responseExpected": true
 };
 callback(responseJson);
};

```

If you would like to change the chatflow’s behaviour based on how the visitor responds to your _ **quickReplies** _ question, you could try doing something like this …

```lia-code-sample
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 one option",
 quickReplies: [{ value:'option_1', label:'Option 1' }, { value:'option_2', label:'Option 2' }],
 responseExpected: true
 };
 callback(responseJson);
 } else if (event.userMessage.quickReply.quickReplies[0].value == "option_1") {
 // this block will run if the visitor has selected "Option 1" (value "option_1")
 const responseJson = {
 botMessage: "Thanks for selecting " + event.userMessage.quickReply.quickReplies[0].label,
 nextModuleNickname: "Target next module 'Action name' / nickname",
 responseExpected: false
 };
 callback(responseJson);
 } else if (event.userMessage.quickReply.quickReplies[0].value == "option_2") {
 // this block will run if the visitor has selected "Option 2" (value "option_2")
 const responseJson = {
 botMessage: "Thanks for selecting " + event.userMessage.quickReply.quickReplies[0].label,
 nextModuleNickname: "Target next module 'Action name' / nickname",
 responseExpected: false
 };
 callback(responseJson);
 }
};

```

Of course, the exact logic you’ll need to use will depend on the chatflow question immediately preceding your cope snippet module.

Hope this helps 😄

Zach

---

<div class="post-metadata">

**Author:** ![AlexCornejo](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alexcornejo/32/29892_2.png) [@AlexCornejo](https://community.hubspot.com/u/AlexCornejo)\
**Post date:** [December 9, 2020, 6:25pm UTC](https://community.hubspot.com/t/chatflow-responseexpected-it-does-not-work/28919/5 "2020-12-09T18:25:13Z")

</div>

wow!

Thank you very much,

it worked very well, when the user finishes responding, it goes to the next node.

But anyway ignore the part of the “nextModuleNickname” that I am missing? Can you help me with an example of this? am I doing the node wrong?

Greetings.

 ![35187iED37DFB183775070.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/e/c/ecdb98805becf741cc5c497b40d24e26a3f1f295.png)

 ![35188iFDE12C134688A197.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/3/f/3fef04f6ceff319e13889898ab57f3858e10dd74.png)

---

<div class="post-metadata">

**Author:** ![zaklein](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/zaklein/32/44431_2.png) [@zaklein](https://community.hubspot.com/u/zaklein)\
**Post date:** [December 11, 2020, 11:51am UTC](https://community.hubspot.com/t/chatflow-responseexpected-it-does-not-work/28919/6 "2020-12-11T11:51:24Z")

</div>

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 😄

```lia-code-sample
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

---

<div class="post-metadata">

**Author:** ![AlexCornejo](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/alexcornejo/32/29892_2.png) [@AlexCornejo](https://community.hubspot.com/u/AlexCornejo)\
**Post date:** [December 15, 2020, 3:35am UTC](https://community.hubspot.com/t/chatflow-responseexpected-it-does-not-work/28919/7 "2020-12-15T03:35:31Z")

</div>

Thank you very much for your help with this if I can pass the following module
