Hi Stephen
Tried what you suggested, but same result.
Hi Stephen
Tried what you suggested, but same result.
Based on the logs, trigger_relevance
is receiving a 401 status code.
{"message":"Authorization header must be in the format: api_key, project:api_key, project:api_key:region, or project:api_key:region:firebaseid"}
Hi @ihmunro,
Are you using the API trigger in Relevance?
I’ve created an action and works fine. I have attached the action code, the response from Pickaxe (the Relevance action is only returning a status), and screenshot from Relevance showing it has received the request.
Let me know if you have issues replicating it
import requests
import json
def relevance_ai(title: str):
"""
The Relevance AI agent
Args:
title (string): the article title
"""
# Insert your PYTHON code below. You can access environment variables using os.environ[].
# Currently, only the requests library is supported, but more libraries will be available soon.
# Use print statements or return values to display results to the user.
# If you save a png, pdf, csv, jpg, webp, gif, or html file in the root directory, it will be automatically displayed to the user.
# You do not have to call this function as the bot will automatically call and fill in the parameters.
# Replace this with Pickaxe secrets or secure storage
API_KEY = "YOUR RELEVANCE API KEY" # Replace this with a secure method
AGENT_ID = "adf56a67-8583-45cc-967a-ad4889aa15c2"
ENDPOINT = "https://api-f1db6c.stack.tryrelevance.com/latest/agents/trigger"
headers = {
"Content-Type": "application/json",
"Authorization": API_KEY
}
payload = {
"message": {
"role": "user",
"content": title
},
"agent_id": AGENT_ID
}
try:
response = requests.post(ENDPOINT, headers=headers, data=json.dumps(payload))
if response.status_code == 200:
result = response.json()
message = result.get("message", {}).get("content", "Agent triggered successfully but no message returned.")
return f"✅ Relevance AI agent triggered successfully.\n\nAgent response:\n{message}"
else:
return f"❌ Failed to trigger agent. Status code: {response.status_code}\nResponse: {response.text}"
except Exception as e:
return f"❌ An error occurred: {str(e)}"