question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nested conversation.ask() don't fire

See original GitHub issue

Hello,

When i execute this code , the program get stucked on the second recursion of getResponse(). Both someFunctionWhoGenerateResponse and generateGreeting function return valid string and work perfectly.

` const bot = new BootBot({ accessToken: config.get(‘accessToken’), verifyToken: config.get(‘verifyToken’), appSecret: config.get(‘appSecret’) });

function getResponse(txt, convo) { var rps = someFunctionWhoGenerateResponse(txt); convo.sendTypingIndicator(); convo.ask(rps, (payload, convo, data) => { convo.say(“hum”); getResponse(payload.message.text, convo); }); }

function sendGreeting(response, convo) { var init = generateGreeting(); convo.ask(init, (payload, convo, data) => { getResponse(payload.message.text, convo); }); }

bot.hear(‘hello’, (payload, chat) => { chat.conversation((convo)=> { sendGreeting(payload.message.text, convo); }); }); `

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
hudginscommented, Dec 19, 2016

@Charca I think there’s a small bug here that might be related to this issue:

https://github.com/Charca/bootbot/blob/master/lib/Conversation.js#L105

If you synchronously call ask() again inside the listener, your callback is assigned to this.listeningAnswer, but upon return to the above line of code, your newly added listener is thrown away. This was causing a similar issue for me and changing it to do something more like:

  const listeningAnswer = this.listeningAnswer
  this.listeningAnswer = null
  listeningAnswer.apply(this, [ payload, this, data]) // eslint-disable-line

solved the problem. I can make a pull request at some point but am kinda in a crunch at the moment.

Thanks for the very nice library!

@andrijdavid Heads up, FYI.

0reactions
Charcacommented, Mar 28, 2017
Read more comments on GitHub >

github_iconTop Results From Across the Web

ngOnChanges not firing for nested object - Stack Overflow
Then ngOnChanges() will be called because the array (reference) will appear as a change. In your answer, you came up with another solution....
Read more >
Understanding Nested Conversations - Andy Gibson
In summary, nested conversations do for regular conversations what conversations do for session scope. With session scope, you cannot have mutliple instances of ......
Read more >
How to submit the form outside the form · Issue #566 - GitHub
You have two options: If you don't have access to the handleSubmit method. You can submit a form programatically by passing a ref...
Read more >
EventWML - The Battle for Wesnoth Wiki
This event will be fired before the moveto event. Villages becoming neutral (via [capture_village]) do not fire capture events. The variable $ ...
Read more >
Working with nested data - Splunk Documentation
Flatten fields with nested data. Extract, create, and delete a nested map. Extract a list of nested keys or values from a top-level...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found