# Conversation log using Redis

**URL:** <https://forum.rasa.com/t/conversation-log-using-redis/3385>\
**Category:** Rasa Open Source\
**Created:** [December 9, 2018, 6:01am UTC](https://forum.rasa.com/t/conversation-log-using-redis/3385 "2018-12-09T06:01:10Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbasix2002](https://avatars.discourse-cdn.com/v4/letter/j/7bcc69/32.png) [@jbasix2002](https://forum.rasa.com/u/jbasix2002)\
**Post date:** [December 9, 2018, 6:01am UTC](https://forum.rasa.com/t/conversation-log-using-redis/3385/1 "2018-12-09T06:01:10Z")

</div>

Hi, I am not an expert programmer. My rasa core is 0.11.12. I am wondering in the tracker store, can we generate the bot log file in these two formats below. If so, can anyone suggest how I can achieve this?

Format 1

 ![example%20data%20log](https://europe1.discourse-cdn.com/flex013/uploads/rasa/original/2X/f/f445a10e2dbc982469db0193daa4297436dc75d8.png)Format 2 ![example%20data%20log%202](https://europe1.discourse-cdn.com/flex013/uploads/rasa/original/2X/3/3b7332212e785236dc50d313850abce12e1933d4.png)

Basically, I want the log file, or the log file needs to contain the information:

1. user ID
2. time
3. messages they send to the bot
4. the bot’s reply

Does the rasa tracker store store these information? and can we export the frequency of bot’s reply and intents to another log file?

Thank you 🙂

---

<div class="post-metadata">

**Author:** ![ricwo](https://avatars.discourse-cdn.com/v4/letter/r/7ea924/32.png) [@ricwo](https://forum.rasa.com/u/ricwo)\
**Post date:** [December 16, 2018, 9:11pm UTC](https://forum.rasa.com/t/conversation-log-using-redis/3385/2 "2018-12-16T21:11:45Z")

</div>

Hi @jbasix2002, yes, the Redis tracker store contains all of that information. Check out the docs on the `RedisTrackerStore` [here](https://rasa.com/docs/core/tracker_stores/#redistrackerstore)

---

<div class="post-metadata">

**Author:** ![jbasix2002](https://avatars.discourse-cdn.com/v4/letter/j/7bcc69/32.png) [@jbasix2002](https://forum.rasa.com/u/jbasix2002)\
**Post date:** [December 18, 2018, 12:11am UTC](https://forum.rasa.com/t/conversation-log-using-redis/3385/3 "2018-12-18T00:11:13Z")

</div>

Hi, thank you, @ricwo. I am wondering if there’s a way to capture the intents in the RedisTrackerStore?

I found that in the rasa tracker store, there’s file stored these pieces of information like below

 ![1545031308624](https://europe1.discourse-cdn.com/flex013/uploads/rasa/original/2X/b/bfbef21704ac1fd1615eefd71d0b1c404a5e463a.jpeg)But it does not label the intents, and the bot utterances.

Thank you so much for your help.

---

<div class="post-metadata">

**Author:** ![ricwo](https://avatars.discourse-cdn.com/v4/letter/r/7ea924/32.png) [@ricwo](https://forum.rasa.com/u/ricwo)\
**Post date:** [December 18, 2018, 1:14pm UTC](https://forum.rasa.com/t/conversation-log-using-redis/3385/4 "2018-12-18T13:14:55Z")

</div>

@jbasix2002 which version of Rasa Core are you running?

The RedisTrackerStore persists the entire conversation. User messages show up under the `events` key and have entries like

```json
{
      "timestamp": 1517821726.200036,
      "parse_data": {
        "entities": [],
        "intent": {
          "confidence": 0.54,
          "name": "greet"
        },
        "text": "/greet",
        "intent_ranking": [
          {
            "confidence": 0.54,
            "name": "greet"
          },
          {
            "confidence": 0.31,
            "name": "goodbye"
          },
          {
            "confidence": 0.15,
            "name": "default"
          }
        ]
      },
      "event": "user",
      "text": "/greet",
      "input_channel": null
    }

```

from which you can read or process the intent.

---

<div class="post-metadata">

**Author:** ![jbasix2002](https://avatars.discourse-cdn.com/v4/letter/j/7bcc69/32.png) [@jbasix2002](https://forum.rasa.com/u/jbasix2002)\
**Post date:** [December 18, 2018, 6:08pm UTC](https://forum.rasa.com/t/conversation-log-using-redis/3385/5 "2018-12-18T18:08:29Z")

</div>

@ricwo: Thank you so much. My rasa core is 0.11.12.

---

<div class="post-metadata">

**Author:** ![ricwo](https://avatars.discourse-cdn.com/v4/letter/r/7ea924/32.png) [@ricwo](https://forum.rasa.com/u/ricwo)\
**Post date:** [December 18, 2018, 9:53pm UTC](https://forum.rasa.com/t/conversation-log-using-redis/3385/6 "2018-12-18T21:53:34Z")

</div>

@jbasix2002 please upgrade to `0.12.3`, and you should be able to see events like the one I posted in your Redis tracker store

---

<div class="post-metadata">

**Author:** ![jbasix2002](https://avatars.discourse-cdn.com/v4/letter/j/7bcc69/32.png) [@jbasix2002](https://forum.rasa.com/u/jbasix2002)\
**Post date:** [December 31, 2018, 10:44pm UTC](https://forum.rasa.com/t/conversation-log-using-redis/3385/7 "2018-12-31T22:44:04Z")

</div>

> [@jbasix2002](#):
>
> 0.11.12.

@ricwo: once we updated it, then we need to re-work the whole custom action…Is there a way to log without updating it? Happy New Year…

---

<div class="post-metadata">

**Author:** ![ricwo](https://avatars.discourse-cdn.com/v4/letter/r/7ea924/32.png) [@ricwo](https://forum.rasa.com/u/ricwo)\
**Post date:** [January 2, 2019, 4:28pm UTC](https://forum.rasa.com/t/conversation-log-using-redis/3385/8 "2019-01-02T16:28:38Z")

</div>

All the event information should be included in your RedisTrackerStore, even in `0.11.12`. You can read out the tracker store with

```python
from rasa_core.tracker_store import RedisTrackerStore
import json

tracker_store = RedisTrackerStore(domain, host='localhost',
                 port=6379, db=0, password=None, event_broker=None,
                 record_exp=None)
tracker = tracker_store.retrieve(sender_id)
print(json.dumps(tracker.current_state(), indent=2))

```

---

<div class="post-metadata">

**Author:** ![ASINGH](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@ASINGH](https://forum.rasa.com/u/ASINGH)\
**Post date:** [January 3, 2019, 11:31am UTC](https://forum.rasa.com/t/conversation-log-using-redis/3385/9 "2019-01-03T11:31:51Z")

</div>

My conversation is being stored in Redis and I can see in some unreadable format. I want to read stored data from Redis I have used your and passed the sender\_id. But I am getting error

> AttributeError: ‘NoneType’ object has no attribute ‘current\_state’

In below code I am able to connect with Redis

```
tracker_store = RedisTrackerStore(domain, host='localhost',
             port=6379, db=0, password=None, event_broker=None,
             record_exp=None)

```

But beyond this it is not working. How can we read conversation for all the senders or individual sender. I am using RASA core version: 0.11. Please help and post python code for the same task

---

<div class="post-metadata">

**Author:** ![ASINGH](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@ASINGH](https://forum.rasa.com/u/ASINGH)\
**Post date:** [January 4, 2019, 4:07am UTC](https://forum.rasa.com/t/conversation-log-using-redis/3385/10 "2019-01-04T04:07:06Z")

</div>

@ricwo can you please help in above problem

---

<div class="post-metadata">

**Author:** ![ricwo](https://avatars.discourse-cdn.com/v4/letter/r/7ea924/32.png) [@ricwo](https://forum.rasa.com/u/ricwo)\
**Post date:** [January 4, 2019, 6:11am UTC](https://forum.rasa.com/t/conversation-log-using-redis/3385/11 "2019-01-04T06:11:11Z")

</div>

Please confirm that your `sender_id` exists in Redis:

```auto
import redis
r = redis.StrictRedis(host='localhost', port=6379, db=0)
for key in r.scan_iter():
       print(key)

```

---

<div class="post-metadata">

**Author:** ![ASINGH](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@ASINGH](https://forum.rasa.com/u/ASINGH)\
**Post date:** [January 4, 2019, 6:52am UTC](https://forum.rasa.com/t/conversation-log-using-redis/3385/12 "2019-01-04T06:52:41Z")

</div>

@ricwo No my sender\_id does not exist in listed keys. However I am passing sender ID to RASA HTTP server using below URL:

```
http://WEB-SER-DEVP:5005/conversations/31912110/respond

```

But I can see some information stored in Redis under a different key in Hexa format:

`127.0.0.1:6379> get 581fbc3d89dc4513a4f2a6a7f9ceaed7`

Edit:

Now what i did I thought I would clear all data from redis and will start fresh. I used command `FLUSHDB` . It cleared all data from db 0. Now when I again started communication, it is not connecting with Redis at all. But chat data is available in InMemoryTracker(Default)` which I can see using

> curl --request GET --url [http://localhost:5005/conversations/31912110/tracker](http://localhost:5005/conversations/31912110/tracker) at my rasa server.

I have defined following in endpoints.yml

```
tracker_store:
    store_type: redis
    url: 'localhost'
    port: 6379
    db: 0
    password: 'JOHN@123'

```

and While loading agent I am passing following:

` tracker_stores = RedisTrackerStore('domain.yml', host='localhost',port=6379, db=0, password="JOHN@123", event_broker=None)`

` agent = Agent('domain.yml', policies = [MemoizationPolicy(max_history = 3), KerasPolicy(),fallback],tracker_store=tracker_stores)`

` data = agent.load_data('./data/stories.md')`

However while doing interactive learning data is being stored in Redis in Hexa format under ker `default`

Kindly tell me what is the mistake I am making. Thanks

---

<div class="post-metadata">

**Author:** ![ricwo](https://avatars.discourse-cdn.com/v4/letter/r/7ea924/32.png) [@ricwo](https://forum.rasa.com/u/ricwo)\
**Post date:** [January 9, 2019, 8:50pm UTC](https://forum.rasa.com/t/conversation-log-using-redis/3385/13 "2019-01-09T20:50:01Z")

</div>

@ASINGH, interactive learning intentionally assigns user ids in hex format. this is because they’re not real user conversations

---

<div class="post-metadata">

**Author:** ![ASINGH](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@ASINGH](https://forum.rasa.com/u/ASINGH)\
**Post date:** [February 11, 2019, 7:05am UTC](https://forum.rasa.com/t/conversation-log-using-redis/3385/14 "2019-02-11T07:05:43Z")

</div>

@ricwo , Thanks. I am able to store data now into redis and it is being stored in Hexadecimal format. When I execute this below code I get key `31912110`:

```
import redis
r = redis.StrictRedis(host='localhost', port=6379, db=0)
for key in r.scan_iter():
   print(key)

```

But in below given code I am getting error:

```
tracker_store = RedisTrackerStore(domain, host='localhost',
             port=6379, db=0, password=None, event_broker=None,
             record_exp=None)
tracker = tracker_store.retrieve(sender_id)

print(json.dumps(tracker.current_state(), indent=2))

```

> Traceback (most recent call last):
> 
> File "E:\Python and Tensorflow\weatherbot\_smalltalk\ReadTracker.py", line 28, in \<module\>
> 
> tracker = tracker\_stores.retrieve(‘31912110’)
> 
> File "c:\users\31960460\appdata\local\programs\python\python36\lib\site-packages\rasa\_core\tracker\_store.py", line 180, in retrieve
> 
> return self.deserialise\_tracker(sender\_id, stored)
> 
> File "c:\users\31960460\appdata\local\programs\python\python36\lib\site-packages\rasa\_core\tracker\_store.py", line 123, in deserialise\_tracker
> 
> tracker = self.init\_tracker(sender\_id)
> 
> File "c:\users\31960460\appdata\local\programs\python\python36\lib\site-packages\rasa\_core\tracker\_store.py", line 77, in init\_tracker
> 
> self.domain.slots)
> 
> AttributeError: ‘str’ object has no attribute ‘slots’

Can you please provide code snippet to this to get this conversation in readable format.

```
    rasa-core==0.12.3

    rasa-core-sdk==0.12.1

    rasa-nlu==0.13.7
    redis==2.10.6

```

---

<div class="post-metadata">

**Author:** ![mohamedHassanKa](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/mohamedhassanka/32/3513_2.png) [@mohamedHassanKa](https://forum.rasa.com/u/mohamedHassanKa)\
**Post date:** [May 6, 2019, 10:25am UTC](https://forum.rasa.com/t/conversation-log-using-redis/3385/15 "2019-05-06T10:25:03Z")

</div>

can you share with us how you managed to connect redis with ur bot and u managed to get that output of redis because i am failling to get it

---

<div class="post-metadata">

**Author:** ![mohamedHassanKa](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/mohamedhassanka/32/3513_2.png) [@mohamedHassanKa](https://forum.rasa.com/u/mohamedHassanKa)\
**Post date:** [May 6, 2019, 12:37pm UTC](https://forum.rasa.com/t/conversation-log-using-redis/3385/16 "2019-05-06T12:37:14Z")

</div>

the information are stored in dump.rdb redis file as hexadecimal i was wandering how are you converting this file guys and how to structure exactly the data like the format 1 or in csv file

---

<div class="post-metadata">

**Author:** ![vigneshp826](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/vigneshp826/32/657_2.png) [@vigneshp826](https://forum.rasa.com/u/vigneshp826)\
**Post date:** [January 16, 2020, 9:54am UTC](https://forum.rasa.com/t/conversation-log-using-redis/3385/17 "2020-01-16T09:54:07Z")

</div>

@ASINGH , did you resolved this issue? if yes, can you share the solution?

Update:

Issue resolved by adding below two lines to the Ricwo script.

from rasa.core.domain import Domain

domain = Domain.load("/home/centos/rasa-x/domain.yml") —\>Path of domain file

---

<div class="post-metadata">

**Author:** ![ASINGH](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@ASINGH](https://forum.rasa.com/u/ASINGH)\
**Post date:** [May 28, 2020, 4:17am UTC](https://forum.rasa.com/t/conversation-log-using-redis/3385/18 "2020-05-28T04:17:36Z")

</div>

Thanks, Yes it was resolved at that time by same approach you mentioned. Missing domain file was key. Sorry for very very very late confirmation

---

<div class="post-metadata">

**Author:** ![samruddhi02](https://avatars.discourse-cdn.com/v4/letter/s/b9bd4f/32.png) [@samruddhi02](https://forum.rasa.com/u/samruddhi02)\
**Post date:** [April 17, 2021, 1:14pm UTC](https://forum.rasa.com/t/conversation-log-using-redis/3385/19 "2021-04-17T13:14:01Z")

</div>

I am using RedisTrackerStore to store all the conversations between a user and a bot in to Redis database and I tried retrieving those conversation using the following method: tracker\_store = RedisTrackerStore(domain, host=‘localhost’, port=6379, db=0, password=None, event\_broker=None, record\_exp=None) tracker = tracker\_store.retrieve(sender\_id)

print(json.dumps(tracker.current\_state(), indent=2))

after getting the key from below script: import redis r = redis.StrictRedis(host=‘localhost’, port=6379, db=0) for key in r.scan\_iter(): print(key)

but I am getting only the latest or the last message of the conversation, is there any way to retrieve the whole conversation of the bot and the user?

---

<div class="post-metadata">

**Author:** ![lokkrish](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/lokkrish/32/15493_2.png) [@lokkrish](https://forum.rasa.com/u/lokkrish)\
**Post date:** [October 4, 2021, 2:15pm UTC](https://forum.rasa.com/t/conversation-log-using-redis/3385/20 "2021-10-04T14:15:39Z")

</div>

@ricwo In the redis tracker store configuration, what does ‘record\_exp’ parameter mean? If we don’t set this, does it mean the events are saved forever and i can expect memory and latency issues in future?
