Skip to content

Feedback

Collect feedback on agent responses and agent types to improve quality over time.

Overview

Ag2Trust supports two types of feedback:

Type Scope Rating Use Case
Response feedback Individual response Thumbs up/down (-1 or 1) "Was this response helpful?"
Agent type feedback Agent type overall 1-5 stars "How would you rate this agent?"

Response Feedback

Submit feedback on a specific agent response using the response_id returned in the pool endpoint response.

Endpoint

POST /api/v1/response-feedback

Request

curl -X POST https://api.ag2trust.com/api/v1/response-feedback \
  -H "X-API-Key: cust_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "response_id": "550e8400-e29b-41d4-a716-446655440000",
    "rating": 1,
    "comment": "Very helpful response"
  }'
Field Type Required Description
response_id string (UUID) Yes The response_id from the pool endpoint response
rating integer Yes -1 (thumbs down) or 1 (thumbs up)
comment string No Optional text feedback

Response

{
  "success": true,
  "feedback_id": "fb_abc123"
}

Response ID TTL

The response_id is valid for 24 hours after the response was generated. Feedback submitted after this window will be rejected.

Agent Type Feedback

Rate an agent type overall using its endpoint slug.

Endpoint

POST /api/v1/feedback/{endpoint_slug}

Request

curl -X POST https://api.ag2trust.com/api/v1/feedback/support \
  -H "X-API-Key: cust_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"rating": 5}'
Field Type Required Description
rating integer Yes 1-5 star rating

Response

{
  "success": true,
  "feedback_id": "fb_xyz789",
  "agent_type_name": "Customer Support",
  "rating": 5,
  "running_instances": 3
}

Integration Examples

Python — Inline Feedback

import requests

API_KEY = "cust_your_api_key"
BASE_URL = "https://api.ag2trust.com"

# Send a message
response = requests.post(
    f"{BASE_URL}/api/v1/ask/support",
    headers={"X-API-Key": API_KEY},
    json={"content": "How do I reset my password?"}
)
data = response.json()
response_id = data["response_id"]

# ... show response to user, collect feedback ...

# Submit feedback
requests.post(
    f"{BASE_URL}/api/v1/response-feedback",
    headers={"X-API-Key": API_KEY},
    json={
        "response_id": response_id,
        "rating": 1,
        "comment": "Clear instructions, worked perfectly"
    }
)

JavaScript — Feedback Widget

async function submitFeedback(responseId, rating, comment = null) {
  const body = { response_id: responseId, rating };
  if (comment) body.comment = comment;

  const res = await fetch(
    'https://api.ag2trust.com/api/v1/response-feedback',
    {
      method: 'POST',
      headers: {
        'X-API-Key': API_KEY,
        'Content-Type': 'application/json'
      },
      body: JSON.stringify(body)
    }
  );
  return res.json();
}

// Usage: user clicks thumbs up
await submitFeedback(responseId, 1);

// Usage: user clicks thumbs down with comment
await submitFeedback(responseId, -1, "Response was off-topic");

API Reference

Method Endpoint Description
POST /api/v1/response-feedback Submit response feedback (thumbs up/down)
POST /api/v1/feedback/{endpoint_slug} Submit agent type rating (1-5 stars)

Best Practices

  1. Collect feedback promptly — The response_id expires after 24 hours
  2. Use both feedback types — Response feedback identifies specific issues; agent type feedback tracks overall satisfaction
  3. Include comments on negative feedback — Comments help identify what went wrong
  4. Track feedback trends — Monitor in the dashboard to identify agents that need prompt tuning

Next Steps