Should the tracker store not save metadata accompanying user messages?

I’m using Rasa 2.2.4, and have configured a tracker store to persist conversations. This works as expected.

However, I’ve noticed that the metadata that I’m sending along with user messages is not being stored.

Here’s an example of a user message I’m posting to the REST endpoint:

{
  "message":"/request_faq",
  "sender":"68bbbb82-dbfa-407b-9fdf-b4ed8bfd904b",
  "metadata":{"displayText":"Frequently Asked Questions"}
}

Looking at my tracker store database, I can see the message is recorded ok, but without any metadata.

See below:

{
  "event": "user",
  "timestamp": 1615467151.6927204,
  "text": "/request_faq",
  "parse_data": {
    "intent": {
      "name": "request_faq",
      "confidence": 1
    },
    "entities": [],
    "text": "/request_faq",
    "message_id": "032a7d5b0b4945108089c21a4c60906c",
    "metadata": {},
    "intent_ranking": [
      {
        "name": "request_faq",
        "confidence": 1
      }
    ]
  },
  "input_channel": "rest",
  "message_id": "032a7d5b0b4945108089c21a4c60906c",
  "metadata": {}
},

Should I expect the Tracker & RestInput channel to store metadata?

I don’t plan to do anything with the metadata property on the server, it’s more to help me configure the frontend. When I reload the tracker it would be helpful to have some of this extra data.

OK, so I figured it out. The answer is no!

I fixed this by implementing a custom channel that inherits from RestInput -

import json
from rasa.core.channels.rest import RestInput
from typing import Text, Dict, Any, Optional
from sanic.request import Request

class Inchat(RestInput):

    @classmethod
    def name(cls) -> Text:
        return "inchat"

    def get_metadata(self, request: Request) -> Optional[Dict[Text, Any]]:
        content_type = request.headers.get("content-type")
        if content_type == "application/json":
            # if JSON-encoded message is received
            request_data = request.json
            return request_data.get("metadata", {})
        return {}
2 Likes