PHP Integration
Example POST /v1/score using Guzzle.
Prereqs
RI_API_KEY(string)BASE_URL(string), defaulthttps://www.relationalmanager.com/apicomposer require guzzlehttp/guzzle
<?php
require "vendor/autoload.php";
use GuzzleHttp\Client;
$baseUrl = getenv("BASE_URL") ?: "https://www.relationalmanager.com/api";
$apiKey = getenv("RI_API_KEY") ?: "";
$payload = [
"lenses" => [1, 4],
"persist" => false,
"message" => [
"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" => [
"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",
],
];
$client = new Client(["base_uri" => $baseUrl]);
$response = $client->post("/v1/score", [
"headers" => [
"Authorization" => "Bearer " . $apiKey,
"Content-Type" => "application/json",
],
"json" => $payload,
]);
echo $response->getStatusCode() . " " . $response->getHeaderLine("X-Request-Id") . PHP_EOL;
echo (string) $response->getBody() . PHP_EOL;
Lens Aggregates, Indicators and Traffic Lights
Lens results include weighted score, scoring_coverage, and traffic_light; questions include full question text 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.
$client->put("/v1/lenses/1/traffic-light-ranges", [
"headers" => ["Authorization" => "Bearer " . $apiKey],
"json" => ["traffic_light_ranges" => [
"red" => ["min" => -1.0, "max" => -0.2],
"yellow" => ["min" => -0.2, "max" => 0.4],
"green" => ["min" => 0.4, "max" => 1.0],
]],
]);
The update key requires org:write. Use scoring_status before interpreting a zero.