Connect an application to Buffaly
An external application's server can call the existing Buffaly host API to read an authorized session and submit work. Keep the installation credential on that server, bind it to the intended workspace, and check admission separately from task completion.
Choose the correct direction
- Application → Buffaly: this guide covers an authenticated server-to-server client of
BuffalyAgentService. - Buffaly → application: expose the application's existing business API through a supported typed adapter; follow Attach JSON web services or MCP services.
- Website chat: use the dedicated website-chat application guide and its server-owned site configuration. Never place an installation API key in an anonymous widget.
- Code already inside Buffaly: use
BuffalyAgentServiceand existing typed worker/session services directly, not HTTP back into the same host. The platform's own cross-process transport is not a pattern for hand-built loopback calls in a skill.
Configure an authorized server client
- Use an existing installed Buffaly web host with its agent service and generated JsonWs contracts. No new controller or integration-server package is needed for these methods. Verify the installed version's descriptor/signatures before coding against it.
- Have the operator supply the reachable HTTPS host URL and an existing authorized installation API credential through the application's server-side secret store. Use
Authorization: Bearer <installation-token>; do not expose it in client JavaScript, URLs or logs. - Configure the credential's workspace on the Buffaly server through
Authentication:ApiWorkspace. Its only members areModeandUserKey. Root usesMode=Rootwith an emptyUserKey; User usesMode=Userand an existing canonical user key. Do not omit them and rely on a browser selection cookie or a caller-supplied user identity. - Create or select the target session through the authorized owning workflow, for example the Buffaly UI in that workspace. Keep the exact session key in the application's server-side configuration and confirm the credential can access it.
- Use the existing generated JsonWs client/contracts where applicable. External non-.NET clients may send the JSON requests below with exact parameter names; these examples are source-checked request shapes, not live-tested credentials or a new SDK.
Installation credentials are for trusted automation, not end-user authorization. Your application still authenticates its own user and restricts which session and operations that user may request. Do not accept arbitrary session keys, source-agent identity or prompt context from an untrusted browser.
Verify one bounded session read
Start with the existing message-history method. Replace the host and session with operator-provided values, and send the bearer header from your server:
POST https://buffaly.example/api/buffaly.agent.host/buffaly-agent-service/get-agent-messages-since
Content-Type: application/json
Authorization: Bearer <installation-token>
{
"sessionKey": "Integration test",
"sinceMessageKey": "",
"maxCount": 10,
"includeSessionStats": false,
"includeStatusMeta": false
}
Confirm the authorized session's messages and expected result contract. A login HTML page, access denial or service error is not a successful API read even if your HTTP client followed a redirect. Record message keys for subsequent bounded history requests instead of repeatedly downloading the whole timeline.
Send a message to the existing session
The current SteerActiveInput(sessionKey, input) contract admits an immediate message into a running turn or starts an existing idle session. It does not create deferred queue work. Despite its historical name, it is not limited to an already-running turn in this version.
POST https://buffaly.example/api/buffaly.agent.host/buffaly-agent-service/steer-active-input
Content-Type: application/json
Authorization: Bearer <installation-token>
{
"sessionKey": "Integration test",
"input": {
"Instruction": "Report the session name. Do not call external services or change files.",
"MessageKey": "application-test-0001",
"IsExternalInput": true
}
}
Use one stable, unique MessageKey for the logical message and preserve it while reconciling an uncertain receipt. The input contract is EvaluateInputContract; it also supports Images, Files and server-controlled context/state. Do not copy recovery, worker-recycle or prepared-input fields into ordinary client requests.
Set IsExternalInput for untrusted external content and preserve the restricted-input handling. The application must still enforce authorization and limit supplied content. Source-session/agent fields are provenance, not credentials or permission to impersonate another session.
If the installed version exposes only active-only steering, follow that version's contract; do not claim it can start idle sessions. For deliberately deferred work, use QueueInput and inspect its queue receipt. Do not change an immediate rejected send into a queued send automatically.
Separate admission from the task result
SteerInputResultContract includes Accepted, SessionKey, MessageKey, Mode, Status, IsRunning, Message, Error and, when available, TurnKey. Inspect these fields under the installed JsonWs response contract. An HTTP success or Accepted=true means neither that the agent read the message yet nor that it completed the requested task.
- Check the session/message identity and explicit admission result before reporting delivery to the user.
- Use bounded message-history reads and the returned message/turn identities to retrieve the corresponding outcome. Do not display an older final message as this request's answer.
- On rejection, preserve the request and report the reason. On timeout/unknown receipt, inspect the session and message identity before any retry. Never evade backpressure with a new key or another route.
EvaluateWithInput(SessionKey, Input)is the direct evaluation method for integrations that need that flow. Its response isEvaluateResponse, not the steering receipt. Use its generated contract rather than interpreting every endpoint as the same response shape.
Tool approval and user-input requests remain part of the session workflow. Do not automatically approve tools or claim completion while the session is waiting for a required decision.
Acceptance checks before application use
- The application server authenticates to the intended Buffaly host and reads only its configured workspace/session.
- A permitted test message has an admitted receipt and a matching visible result; sending the same logical message is not duplicated during receipt reconciliation.
- An unauthorized session is denied in a controlled test environment; missing authentication does not become an HTML-login “success.”
- The application preserves rejected/uncertain delivery, approval waits and external-input restrictions.
- No installation credential, raw token or unrelated session data reaches the public browser.
These checks require an authorized integration environment. The request examples document current source contracts; they do not establish that a particular customer host is configured or reachable.