Hi @mrepot33. You can set the details extracted by one action as slots. Then in your other action, you can extract the values of those slots using the method tracker.get_slot("slot_name")
Hi @Juste, I’ve already tried that but the slot was then empty. This is my code.
“data” is a big json containing a lot of data from an item that I’d like to share between actions, avoiding making third party API requests each time. Sharing this data across actions would be the ideal solution.
A workaround solution would be to use a cache (redis in this case) in order to store the data there, using the “itemid” as the key. Then in the other action I could retrieve the data by using that id. The problem is that “itemid” is then empty.
class ActionA(Action):
def name(self) -> Text:
return "actiona"
def run(self, dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
price = tracker.get_slot('price')
itemid = tracker.get_slot('itemid')
data = rcache.get(itemid)
if not data:
data = get_item_data(itemid)
rcache.mset({itemid: data})
....
return [SlotSet('offer', offer)]
Using the method tracker.get_slot() you are extracting the values from tracker. That’s why, for this to work, your custom action actiona should return an event SlotSet for the itemid slot as well (just like you are doing it for the slot offer). You can do it by modifying the last line of actiona as follows: