-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
correct mustache rendering from causing mutation of initial dialog script #1761
Conversation
prevent mustache.render or parseTemplatesRecursive to change back line objects or dc objects by copying by value to outgoing instead of by reference
Adding example for better clarity : Sample rendering without deepcopy (QR text is fixed as initial value) : Sample rendering with deepcopy (QR text can be translated using mustache in each turn) : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried with the following code
let replies = new BotkitConversation('replies', controller);
replies.ask({
text: 'Click one of these suggestions!',
quick_replies: [
{
title: 'Foo',
payload: 'foo',
},
{
title: 'Bar',
payload: 'bar',
}
]
}, [], 'reply');
replies.say({
channelData: {
attachment: {
type: 'template',
payload: {
template_type: 'generic',
elements: [
{
title: '{{vars.reply}}',
subtitle: '{{vars.reply}}',
image_url: `https://image.com`,
buttons: [
{
type: 'web_url',
url: 'https://google.com',
title: '{{vars.reply}}'
}
]
}
]
}
}
}});
controller.addDialog(replies);
controller.hears('qqq', 'message', async(bot, message) => {
await bot.beginDialog('replies');
});
Running twice, without changes, results in the same card clicking on diferent quick replies each time.
With @InnoraG changes running as expected!
Thank you!! |
prevent
mustache.render
orparseTemplatesRecursive
to mutate backline
objects through copying tooutgoing
by value instead of reference using deepcopy formatJSON.parse(JSON.stringify(line.xxxxx))
of objets like attachments, quick_replies or blocks