How to store messages locally

i want to run a function every time bot receives a message to store the messages and store in elasticsearch for building a search feature.

can anyone guide me achieve that?

Thank you

Hi @d_y, I do the same in my bot.

1- I created a slot called ‘question’, add it to the ‘slots’ section in ‘domain.yml’ file.

2- created a custom action to save the ‘question’ slot and return it.

3- added the slot to my stories.

[ class SaveIntentAndQuestion(Action): def name(self) -> Text: return “save_intent_question”

def run(self,
    dispatcher: CollectingDispatcher,
    tracker: Tracker,
    domain: Dict[Text, Any]) -> List[Dict]:
    question = tracker.latest_message['text']
    intent = tracker.latest_message['intent'].get('name')
    print("print following values")
    slots = []
    slots.append(SlotSet('question', question))
    slots.append(SlotSet('intent_slot', intent))
    return slots


Hi @wafaa, Thanks for the reply

do you mean to call/execute custom action every time bot gets a message?

yes and based on the intent you want its message as well. you can handle it through stories.

I am expecting a default behavior or something like TrackerStore that executes itself and stores events every time

I am not sure if they can meet my requirement.

I need a specific message within a specific intent to use it in my api call to Elasticsearch.

so, I solved it by custom action.

Yeah! I understand that. But I am looking for a better approach. If I cannot find anything. I’ll go with the same approach

yeah sure, and pleas post it if you reached any.


Yeah! definitely

1 Like