.NET SDK

dotnet add package Glytos

Targets net8.0 and netstandard2.0.

Setup

using Glytos;

using var glytos = new GlytosClient("gly_...");

To act in a specific environment, name it - dev, staging, prod, or an environment uuid. Without it, requests use the organization's default environment. A value that matches no environment falls back to the default rather than failing.

using var prod = new GlytosClient("gly_...", new GlytosClientOptions { Environment = "prod" });

Timeouts

The client uses HttpClient's own timeout, 100 seconds unless you change it. A text turn can take a while when the model writes a long reply, so set one that leaves room for it:

using var glytos = new GlytosClient("gly_...", new GlytosClientOptions
{
    Timeout = TimeSpan.FromMinutes(3),
});

Timeout is ignored when you supply your own HttpClient; set it on that client instead. A streamed turn is bounded only until the response starts; after that, stop it with the CancellationToken every method takes. A timeout surfaces as a TaskCanceledException, not a GlytosException.

Text conversations

A thread holds a conversation; a run is one turn on it. The reply is in the result - there is no run to poll. See Chat.

var thread = await glytos.Threads.CreateAsync(agentUuid);
var run = await glytos.Threads.Runs.CreateAsync(thread, "What are your opening hours?");

// Or stream it as it is written
await foreach (var e in glytos.Threads.Runs.StreamAsync(thread, "Summarise the policy"))
{
    if (e.Type == "token") Console.Write(e.Delta);
}

Agents is an alias of Workflows: the product calls them agents, the API path is /workflows. Either works.

Resources

await glytos.Workflows.ListAsync();
await glytos.Workflows.RetrieveAsync(workflowUuid);
await glytos.Workflows.CreateAsync("Receptionist", mode: "prompt");

await glytos.Calls.CreateAsync(new
{
    transport = "phone",
    workflow_uuid = workflowUuid,
    to_number = "+1...",
});
await glytos.Calls.ListAsync();
await glytos.Calls.SayAsync(callUuid, "One moment, please.");

await glytos.Workflows.SessionAsync(workflowUuid, sessionUuid);

ASP.NET Core

dotnet add package Glytos.Extensions.DependencyInjection
builder.Services.AddGlytos(builder.Configuration["Glytos:ApiKey"]!, options =>
{
    options.Environment = "prod";
});

app.MapGet("/agents", async (GlytosClient glytos) => await glytos.Workflows.ListAsync());

AddGlytos sends through an IHttpClientFactory client named "Glytos", so options.Timeout does not apply there. Configure the named client instead:

builder.Services.AddHttpClient("Glytos", client => client.Timeout = TimeSpan.FromMinutes(3));

The client covers Agents (alias Workflows), Threads, Folders, Imports, Chat, Calls, PhoneNumbers, SipTrunks, Campaigns, Dnc, Sessions, Webhooks, Tools, KnowledgeBase, VectorStores, Integrations, Automations, TestSuites, Analytics, Billing, Environments, Providers, ApiKeys and Organizations.

Anything not wrapped

await glytos.RequestAsync<JsonElement>("GET", "/audit");

Verifying webhooks

using Glytos;

// The raw body must be the untouched request body - parsing and re-serialising it
// changes the bytes and the signature will not match.
var ok = Webhook.Verify(rawBody, Request.Headers["X-Glytos-Signature"], secret);

See Webhooks.