Retrieve Response
Retrieve a single response with trace.
GET /conversations/:id/response/:response_id/
Path Parameters
Section titled “Path Parameters”id string Required
The conversation id
responseId string Required
The response id
Response Type
Section titled “Response Type”type TraceStep = | { name: "getSchemasForTables"; input: { tables: string[]; }; output: string; } | { name: "databaseRetriever"; input: { question: string; }; output?: { query: { sql: string; params: unknown[]; }; data: Record<string, unknown>[]; }; } | { name: "executePythonCode"; input: { code: string; }; output: { output: string; error: string; exitCode: number; success: boolean; }; };
type InconvoResponseWithTrace = { id: string; input: { message: string; context: Record<string, unknown>; }; trace: TraceStep[]; output: { text: string; type: "text" | "chart" | "table"; chart?: { type: "bar" | "line"; data: { labels: string[]; datasets: { name: string; values: number[]; }[]; }; title: string; xLabel: string; yLabel: string; }; table?: { head: string[]; body: string[][]; }; };}; Request
import Inconvo from "@inconvoai/node";
const inconvo = new Inconvo({ apiKey: process.env.INCONVO_API_KEY});
const response = await inconvo.conversations.response.retrieve("51524c88", { conversation_id: 'convo_3424s3'});
console.log(response);{ "id": "e45f7d78-36d5-4130-926a-78e334255609", "input": { "message": "Can you check if there is a correlation between the first character of the city name the total number of orders from that city?", "context": { "organisationId": 1 } }, "output": { "type": "table", "message": "I grouped your organisation's orders by the first character of the ordering user's city and checked how order volumes vary across initials. Since initials are categorical, a traditional correlation coefficient isn't appropriate; instead, I assessed variation across initials. There's clear variation: the number of orders per initial ranges from 4,946 to 20,266, with a median around 9,074. This indicates the first character of the city is associated with differing order volumes across initials.", "table": { "head": ["City initial", "Total orders"], "body": [ ["A", "10564"], ["B", "4946"], ["C", "10493"], ["D", "9074"], ["H", "4981"], ["L", "10385"], ["M", "5186"], ["N", "5120"], ["O", "5282"], ["P", "15535"], ["S", "20266"] ] } }, "trace": [ { "name": "getSchemasForTables", "input": { "tables": ["orders", "users", "organisations"] }, "output": "orders\n\tAccess: Selectable\n\tColumns:\n\t\t- created_at (DateTime) - Notes: This was the date that the order was created on.\n\t\t- reduction (number)\n\t\t- identifier (number)\n\t\t- product_identifier (number)\n\t\t- number_of_items (number)\n\t\t- subtotal (number)\n\t\t- taxation_fee (number)\n\t\t- user_identifier (number)\n\t\t- total (number [USD])\n\tRelations:\n\t\t- organisation (organisations)\n\t\t- product (products)\n\t\t- user (users)\n\n---\n\nusers\n\tAccess: Selectable\n\tColumns:\n\t\t- address (string)\n\t\t- birth_date (DateTime)\n\t\t- city (string)\n\t\t- created_at (DateTime)\n\t\t- email (string)\n\t\t- id (number)\n\t\t- last_order_at (DateTime)\n\t\t- latitude (number)\n\t\t- longitude (number)\n\t\t- name (string)\n\t\t- organisation_id (number)\n\t\t- password (string)\n\t\t- zip (string)\n\tRelations:\n\t\t- orders (orders[])\n\t\t- organisation (organisations)\n\t\t- reviews (reviews[])\n\t<usersTableContext>\nUsers are also referred to as accounts. \nA user is considered a customer if the last_order_at is not null.\nNew customers over a time period are those who have every order after the start of the time period.\n\t</usersTableContext>\n\n---\n\norganisations\n\tAccess: Selectable\n\tColumns:\n\t\t- created_at (DateTime)\n\t\t- id (number)\n\t\t- name (string)\n\tRelations:\n\t\t- orders (orders[])\n\t\t- products (products[])\n\t\t- reviews (reviews[])\n\t\t- users (users[])" }, { "name": "databaseRetriever", "input": { "question": "For organisationId = 1, return the total number of orders grouped by the first character of the users.city of the ordering user. Include the group label (first character) and the order count." }, "output": { "query": { "sql": "select \"users\".\"city\", json_build_object('users.city', count(\"users\".\"city\")) from \"orders\" inner join \"users\" on \"orders\".\"user_id\" = \"users\".\"id\" where \"orders\".\"organisation_id\" = $1 group by \"users\".\"city\" order by count(\"users\".\"city\") desc limit $2", "params": [1, 1000] }, "data": [ { "users.city": "Philadelphia", "_count": { "users.city": 5409 } }, { "users.city": "Austin", "_count": { "users.city": 5407 } }, { "users.city": "Las Vegas", "_count": { "users.city": 5405 } } ] } }, { "name": "executePythonCode", "input": { "code": "import json, pandas as pd\n# Load results\nfiles = ['retriever_result_1.json','retriever_result_2.json','retriever_result_3.json']\nframes = []\nfor fn in files:\n with open(fn,'r') as f:\n data = json.load(f)\n df = pd.json_normalize(data['data'])\n frames.append(df)\n# Prefer the one with explicit org id\ndf = frames[1]\n# Keep only organisation 1\ndf = df[df['organisations.id']==1]\n# Extract initial uppercase\ndf['initial'] = df['users.city'].str.strip().str[0].str.upper()\n# Sum counts by initial\ndf_counts = df.groupby('initial')['_count.orders.id'].sum().reset_index()\nsummary = {\n 'n_initials': int(df_counts.shape[0]),\n 'min_count': int(df_counts['_count.orders.id'].min()),\n 'max_count': int(df_counts['_count.orders.id'].max()),\n 'median_count': int(df_counts['_count.orders.id'].median()),\n 'mean_count': float(df_counts['_count.orders.id'].mean()),\n}\nprint(json.dumps({'summary': summary, 'by_initial': df_counts.sort_values('initial').to_dict(orient='list')}))" }, "output": { "output": "{\"summary\": {\"n_initials\": 11, \"min_count\": 4946, \"max_count\": 20266, \"median_count\": 9074, \"mean_count\": 9257.454545454546}, \"by_initial\": {\"initial\": [\"A\", \"B\", \"C\", \"D\", \"H\", \"L\", \"M\", \"N\", \"O\", \"P\", \"S\"], \"_count.orders.id\": [10564, 4946, 10493, 9074, 4981, 10385, 5186, 5120, 5282, 15535, 20266]}}", "error": "", "exitCode": 0, "success": true } } ]}