optimistic-gold
optimistic-gold•2y ago

Custom Actions Youtube Tutorial question

Hello Voiceflow team, I'm reposting my question from the #šŸ’¬ā”ƒgeneral-chat channel here: This is regarding custom actions. Hi I'm following the custom action youtube tutorial for rendering custom actions and I noticed that last_event is returning null after I make a carousel selection. Is last_event still being populated after custom action step executes? Video source: https://www.youtube.com/watch?v=2V46rOkkprg&t=130s This is the javascript code I used from the tutorial:
const makeCard = (name, sku) => ({
"title": name,
"description": {
"text": "something about tea 1"
},
"imageUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d3/Longjing_tea_steeping_in_gaiwan.jpg/1920px-Longjing_tea_steeping_in_gaiwan.jpg",
"buttons": [
{
"name": "button " + name,
"request": {
// corresponds with the path selected
"type": "tea_selected",
"payload": {
"sku": sku,
"label": "button " + name,
"actions": []
}
}
}
]
});

for (let i = 1;i <= 10; ++i) {
carousel_dynamic.cards.push(makeCard(`tea ${i}`, `t-${i}`));
}

// must stringify json data so other nodes know the shape of this object
carousel_dynamic = JSON.stringify(carousel_dynamic);



// last_event returns null
tea_selection = JSON.stringify(last_event);
const makeCard = (name, sku) => ({
"title": name,
"description": {
"text": "something about tea 1"
},
"imageUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d3/Longjing_tea_steeping_in_gaiwan.jpg/1920px-Longjing_tea_steeping_in_gaiwan.jpg",
"buttons": [
{
"name": "button " + name,
"request": {
// corresponds with the path selected
"type": "tea_selected",
"payload": {
"sku": sku,
"label": "button " + name,
"actions": []
}
}
}
]
});

for (let i = 1;i <= 10; ++i) {
carousel_dynamic.cards.push(makeCard(`tea ${i}`, `t-${i}`));
}

// must stringify json data so other nodes know the shape of this object
carousel_dynamic = JSON.stringify(carousel_dynamic);



// last_event returns null
tea_selection = JSON.stringify(last_event);
2 Replies
Tico | Voiceflow Assistant
The last_event system variable is designed to capture the trace of the last user event such as a button selection, carousel button selection, and when an intent is triggered. The type of this is { type: string, payload: object | string }. In the context of a Custom Action, the last_event should indeed be populated after the execution of the Custom Action step, capturing the user's interaction with the Carousel. If it's returning null, it might be due to the absence of a user event after the Custom Action step. However, it's important to note that the last_event variable will only capture events that are interacted with when the Global Listen setting is enabled. By default, Voiceflow listen steps actively listen for user events only until the event is detected. When Global Listen is enabled, any of the Custom Action’s elements that can be interacted with will continue to listen for a user event such as a button click. If you've ensured that the Global Listen setting is enabled and you're still experiencing this issue, it might be a good idea to revisit the code and ensure that the last_event variable is being called correctly. Source: Voiceflow Developer Documentation
optimistic-gold
optimistic-goldOP•2y ago
I've tried to set the Global Listen setting as enabled and I still get a null last_event back.
No description

Did you find this page helpful?