Is it possible to import conversation id from to another file?

Hi, I wonder if it is possible to import conversation id from to another python file as a variable? I’ve tried to do that by doing:

class ActionTellID(Action):

    """Informs the user about the conversation ID."""

    def name(self) -> Text:

        return "action_tell_id"

    async def run(

        self, dispatcher, tracker: Tracker, domain: Dict[Text, Any]

    ) -> List[Dict[Text, Any]]:

        conversation_id = tracker.sender_id


from actions.actions import ActionTellID


It didn’t work. Do you have an idea how to do that?

I’ve tried also this option but it didn’t work too:

from actions.actions import ActionTellID

conversation_id = ActionTellID()
print conversation_id

Do I have to use async def run in Or ActionTellID is okay?

The first problem here is that you are not using the run method, you’re just instantiating an instance of the ActionTellID class.

Secondly, even if you used the run method ActionTellID().run (which yes, needs to be await ed since it is async), it is not returning anything, so you will not get back the conversation ID.

Finally, a custom action is expected to be run by being called in a conversation; see the expected arguments for the run method.

Maybe it’s better to start with what you want to accomplish in where you are trying to import the conversation ID?

My goal is to simply get conversation_id at the beginning of the conversation without using custom action like ActionTellID so I can save it to the database for example.

Ok, in that case what you’d want to do is create a custom ActionSessionStart which saves the conversation ID to wherever you want. See the documentation for customizing action_session_start