Create connections and label space
Prerequisites
1) Create connections (positive & negative)
import "dotenv/config";
import GospaceAI from "@gospace-ai/api";
async function main() {
const gospace = new GospaceAI(process.env.GOSPACE_API_KEY!);
const res = await gospace.connections.createConnections({
connections: [
// Positive: person prefers to sit near a team
{
strength: 75,
connection_from_entity: {
connection_entity_id: "person_123",
connection_entity_type: "PERSON",
connection_entity_data: {
first_name: "Alice",
last_name: "Smith",
email: "[email protected]",
person_id: "person_123",
external_id: "ext-alice",
},
},
connection_to_entity: {
connection_entity_id: "team_456",
connection_entity_type: "TEAM",
connection_entity_data: {
team_name: "Engineering",
team_id: "team_456",
external_id: "ext-team-eng",
},
},
},
// Negative: team should avoid a particular room
{
strength: -50,
connection_from_entity: {
connection_entity_id: "team_456",
connection_entity_type: "TEAM",
connection_entity_data: {
team_name: "Engineering",
team_id: "team_456",
},
},
connection_to_entity: {
connection_entity_id: "room_789",
connection_entity_type: "ROOM",
connection_entity_data: {
room_name: "Conference Room A",
room_id: "room_789",
},
},
},
],
});
console.log(JSON.stringify(res.data.connections, null, 2));
}
main().catch((err) => {
console.error("Create connections failed:", err);
process.exit(1);
});2) Query connections (by entity, type, or external_id)
3) Update connection strength / endpoints
4) Delete connections
5) Create labels (for tagging entities)
6) Label space (map a label to SPACE/ROOM/ZONE/TEAM/PERSON)
7) Query & manage label mappings
Tips & patterns
Last updated
Was this helpful?