I want to tag conversations from custom actions in Rasa X. I see that this does not require any authentication, but deleting tags and viewing existing tags does. The docs say that authentication works with tokens, so I send username and password and get the token back. That seems to work fine.
def get_rasax_token():
try:
response = requests.post(
RASA_X_API + "/auth",
json = {"username": RASA_X_USER_NAME, "password": RASA_X_PASSWORD}
)
if response.status_code is not 200:
raise Exception(f"Could not fetch a Rasa X API Token {response.text}")
return response.json().get("access_token")
except Exception as e:
logging.exception(e)
RASA_X_TOKEN = get_rasax_token()
But I’m not sure how to include this token in the following calls.
def fetch_existing_tags():
"""
Helper function to fetch existing tags from Rasa X,
used to find to corresponding color, since both are needed to add a tag
"""
try:
response = requests.get(
f"{RASA_X_API}/conversations/tags",
headers={"api_token": RASA_X_TOKEN}
)
except Exception as e:
logging.exception(e)
return {}
if response.status_code is not 200:
print(response)
logging.exception(f"Could not fetch existing conversation tags: {response.text}")
return {}
print(response.json())
return {
entry["tag"]: entry["color"]
for entry in response.json()
}
RASA_X_TAG_COLORS = fetch_existing_tags()
How do I correctly embedd the token in the call? I get a 401:
{"reasons":["Authorization header not present."],"exception":"Unauthorized"}