How I track timestamp from a user input?

Hi! I have a custom action where I can track the user id, his input, confidence and bot reply, but I don’t understood yet how to get the timestamp.

from pickletools import int4
from typing import Any, Text, Dict, List

import rasa.core.tracker_store
from rasa.shared.core.trackers import DialogueStateTracker
from rasa_sdk import Action, Tracker
from rasa_sdk.executor import CollectingDispatcher

class ActionSaveConversation(Action):

    def name(self) -> Text:
        return "action_save_conversation"

    def run(self, dispatcher: CollectingDispatcher,
            tracker: Tracker,
            domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:

        conversation = tracker.events
        senderid = tracker.sender_id
        latestmessage = tracker.latest_message
        latestactionname = tracker.latest_action_name

        print(f'\nconversation: {conversation} \n')
        print(f'senderid: {senderid} \n')
        print(f'latestmessage: {latestmessage} \n')
        print(f'latestactionname: {latestactionname} \n')

        
        import os
        import io
        from datetime import datetime

        if not os.path.isfile('chats.csv'):
            with io.open('chats.csv','w',encoding='utf8') as file:
                file.write("user_id,intent_name,confidence,user_input,action,bot_reply,timestamp,data\n")
        chat_data=''
        for i in conversation:
            if i['event'] == 'user':
                user_input = '"' +  i['text'] + '"'
                print(f'\n\nuser_input: {user_input}')
                user_id = '"' + str(senderid) + '"'
                confidence = str(i['parse_data']['intent']['confidence']) 
                chat_data += user_id + ',' + i['parse_data']['intent']['name'] + ',' + confidence + ',' + user_input + ','
                #print(f'\n\nChatData: {chat_data}')
                #print('user: "{}"'.format(i['text']))
            elif i['event'] == 'bot':
                bot_reply = '"' + i['text'] + '"'
                print(f'\n\nbot_reply: {bot_reply}')
                #print('Bot: "{}"'.format(i['text']))
                data = '"' + str(latestmessage) + '"'
                try:
                    chat_data += i['metadata']['utter_action'] + ',' + bot_reply + ',' + ',' + data + '\n'
                except KeyError:
                    pass
        else:
            with open('chats.csv','a',encoding='utf8') as file:
                file.write(chat_data)

        return []

Hi @phcsouza

events object has a ‘timestamp’. Can you print i[‘event’] and see if you have a timestamp field.