C# (.NET) Integration
Example POST /v1/score using HttpClient.
Prereqs
RI_API_KEY(string)BASE_URL(string), defaulthttps://www.relationalmanager.com/api
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
var baseUrl = Environment.GetEnvironmentVariable("BASE_URL") ?? "https://www.relationalmanager.com/api";
var apiKey = Environment.GetEnvironmentVariable("RI_API_KEY") ?? "";
var payload = new
{
lenses = new[] { 1, 4 },
persist = false,
message = new
{
message_id = "m2",
conversation_id = "c1",
text = "I'm not sure this will work.",
channel_type = "chat",
channel_id = "support",
sender_id = "u2",
sender_type = "user",
lang = "en",
timestamp = "1716561012"
},
previous_message = new
{
message_id = "m1",
conversation_id = "c1",
text = "We can try a few options.",
channel_type = "chat",
channel_id = "support",
sender_id = "u1",
sender_type = "agent",
lang = "en",
timestamp = "1716560950"
}
};
var json = JsonSerializer.Serialize(payload);
using var client = new HttpClient();
using var request = new HttpRequestMessage(HttpMethod.Post, $"{baseUrl}/v1/score");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", apiKey);
request.Content = new StringContent(json, Encoding.UTF8, "application/json");
using var response = await client.SendAsync(request);
var responseBody = await response.Content.ReadAsStringAsync();
var requestId = response.Headers.Contains("X-Request-Id")
? string.Join(",", response.Headers.GetValues("X-Request-Id"))
: "";
Console.WriteLine($"{(int)response.StatusCode} {requestId}");
Console.WriteLine(responseBody);
}
}
Lens Aggregates, Indicators and Traffic Lights
Deserialize score, scoring_coverage, and traffic_light from each lens. Questions include question and scoring_status.
Use each question's indicator_name, score, scoring_status, and traffic_light for UI dials. The signal uses the parent lens ranges, while internal metric details remain private.
The lens prescriptions array contains prioritized guidance for yellow/red signals and is empty for green.
var rangesJson = JsonSerializer.Serialize(new {
traffic_light_ranges = new {
red = new { min = -1.0, max = -0.2 },
yellow = new { min = -0.2, max = 0.4 },
green = new { min = 0.4, max = 1.0 }
}
});
var ranges = new StringContent(rangesJson, Encoding.UTF8, "application/json");
await client.PutAsync($"{baseUrl}/v1/lenses/1/traffic-light-ranges", ranges);
The update key requires org:write; unscored questions retain a legacy numeric zero.