Channel adapters#
Channel integrations authenticate external events, resolve an owned Agent and environment through a source binding, and submit input to a Session. They share the same validation and Codex or Pi Durable runtime as API-created Sessions. The bound Agent and environment define the execution capabilities.
Deployed Sessions use the configured model credentials and can incur model usage.
The adapters intentionally separate:
- the source identity authenticated by the inbound request;
- the destination identity selected for a terminal response; and
- the credential identity used for repository access or outbound provider APIs.
A delivery route is an opaque local name or provider channel ID. It is never a webhook URL, token, owner ID, or Secrets Manager ARN supplied by an untrusted user.
Use terraform -chdir=infra output -json webhook_urls to obtain enabled endpoints. The paths are
POST /webhooks/github, /webhooks/gitlab, /webhooks/teams, and /webhooks/slack; a route exists
when enabled by its *_webhook_enabled input. If that input is unset, enablement is inferred from
the ingress secret ARN; an enabled route requires that ARN. The API hostname changes per stack,
so do not copy a URL from another environment.
Secret formats#
Secrets Manager values may be raw strings or the following JSON shapes:
| Setting | Accepted JSON keys |
|---|---|
| GitHub webhook secret | secret, webhook_secret |
| GitHub clone/comment token | token, access_token (password is also accepted by clone only) |
| GitLab signing/legacy token | signing_token, token, secret, webhook_secret |
| GitLab clone/note token | token, access_token (password is also accepted by clone only) |
| Teams outgoing-webhook HMAC secret | secret, hmac_secret |
| Teams Workflow URL | url, webhook_url |
| Teams threaded-reply gateway URL | url, webhook_url |
| Slack signing secret | secret, signing_secret |
| Slack bot token | token, bot_token |
Keep ingress, clone, and outbound API credentials in different secrets. The module exposes separate clone and notification ARNs so the worker never receives a provider-write credential. Pin IAM policies to exact secret ARNs.
GitHub#
Current behavior#
The GitHub Lambda validates X-Hub-Signature-256 over the exact raw request body using HMAC-SHA256
before parsing JSON. X-GitHub-Delivery is the provider event identity and idempotency source.
Accepted events are:
| GitHub event | Accepted actions | Result destination |
|---|---|---|
pull_request |
opened, reopened, synchronize, ready_for_review |
PR issue comment |
issue_comment |
created, only when the issue is a PR; admission follows the binding's event policy |
PR issue comment |
Other validly signed events return 202 with {"accepted":false,"ignored":true}. The review
request checks out the head SHA read-only and fetches the base ref for diff context. Comment requests
on an unsubscribed thread are case-insensitively gated by github_comment_trigger (injected as
GITHUB_COMMENT_TRIGGER; @rat-things by default). This is a cost
and noise filter, not authorization: anyone allowed to comment can include the trigger. Every PR
comment also requires its author in the binding's eventPolicy.actors.allow, even on a subscribed
thread. Without that allowlist, review events still work but comments do not start or steer work.
Retain installation, repository, rate, and budget controls.
An empty trigger never counts as an explicit mention. Provider result replies include the
hidden rat-things:result marker, and ingress ignores marked replies and comments
whose GitHub user type is Bot. These controls prevent the runtime's ordinary result replies from
starting another run even when generated text repeats the trigger. They do not authorize human
authors; keep repository, actor, budget, and rate policy separate. Bot-authored pull requests,
including Dependabot, Renovate and Actions requests, remain eligible for lifecycle-triggered
reviews. If an actor allowlist is configured, include the bot actors whose reviews you want.
Configure GitHub#
Configure the signed webhook and its owned Agent/environment binding as described in Connect a GitHub webhook.
- Create a high-entropy webhook secret, a clone-only credential, and a separate comment-only
credential in Secrets Manager.
The current implementation consumes a static token;
installationIdis retained as source metadata but the runtime does not yet mint short-lived GitHub App installation tokens. - Set
github_webhook_secret_arn,github_clone_token_secret_arn, andgithub_notify_token_secret_arn. Limit each token independently to the intended repositories and its one operation. - In the GitHub App or repository webhook, set the payload URL to the stack's GitHub webhook output,
content type to
application/json, and secret to the same ingress secret value. - Set a distinct command-like
github_comment_trigger, and subscribe only to pull-request and issue-comment events. Use a separate App/webhook per environment so delivery IDs, permissions, URLs, and secrets do not cross dev/prod boundaries. - Create an owner-authenticated source binding for the repository, selecting an Agent and
environment. A signed event without a matching binding returns
source_not_bound. Each accepted pull request subscribes to a Session; saved terminal root Turns drive comment delivery. Follow-up comments continue that Session. A synchronized head change starts a new review Session and transfers the subscription.
When an issue_comment starts a new Session, the adapter checks out refs/pull/<number>/head.
Comments admitted to an existing Session retain its checkout. The synthetic ref is mutable; a future
adapter should resolve it to a commit SHA at authenticated ingress when exact replay reproducibility is
required.
GitHub signs webhook deliveries as documented in Validating webhook deliveries. Use a GitHub App with short-lived installation tokens as the production credential design; the static token adapter is an explicit maturity gap.
For GitHub Enterprise Server, add its clone hostname to allowed_repository_hosts and set the
validated github_api_base_url input to that installation's REST /api/v3 endpoint. The public
default is https://api.github.com. Keep both values environment-specific and integration-test clone
and source delivery together.
GitLab#
Current behavior#
For GitLab 19 Standard Webhooks, the Lambda requires webhook-id, a webhook-timestamp within five
minutes, and at least one matching v1,<base64> entry in webhook-signature. It strips the whsec_
prefix from the configured signing token, strictly decodes its 32-byte key, and verifies HMAC-SHA256
over webhook-id.webhook-timestamp.raw-body with a timing-safe comparison before parsing JSON. A
present but invalid Standard signature is rejected; it never downgrades to legacy auth.
When no webhook-signature header is present, the handler retains X-Gitlab-Token timing-safe
comparison for older GitLab installations. This legacy token authenticates a shared value but does
not sign the body or provide timestamp replay protection; do not choose it for a new GitLab 19+
webhook.
Idempotency prefers webhook-id, then Idempotency-Key, X-Gitlab-Webhook-UUID, X-Request-ID, and
finally a SHA-256 hash of the raw body.
Accepted payloads are:
| GitLab object kind | Accepted actions | Result destination |
|---|---|---|
merge_request |
open, reopen, update, approved (or omitted action) |
Merge-request note |
note |
Note attached to a merge request; admission follows the binding's event policy | Merge-request note |
Other authenticated payloads return an accepted/ignored response. GitLab note requests on an unsubscribed thread are
case-insensitively gated by gitlab_comment_trigger (injected as GITLAB_COMMENT_TRIGGER;
@rat-things by default). The trigger controls
noise/cost but is not proof that the author is authorized for a particular repository or destination.
Every MR note also requires its author in eventPolicy.actors.allow, including notes on subscribed
threads. Use gitlab:<user-id> identifiers. Bot-authored merge requests remain eligible for review
events; bot notes remain ignored. A configured actor allowlist also restricts review events.
An empty trigger never counts as an explicit mention. Provider result notes include the
hidden rat-things:result marker, and ingress ignores marked replies and payload users
whose GitLab bot field is true. These controls prevent ordinary self-trigger loops even when
generated text repeats the trigger. They do not authorize human authors; keep project, actor, budget,
and rate policy separate.
Configure GitLab#
- On GitLab 19+, generate a signing token (
whsec_...) for the webhook and store it separately from a least-privileged project/group access token in Secrets Manager. Use a legacy secret token only for an older installation that cannot emit Standard Webhooks headers. - Set
gitlab_webhook_secret_arn,gitlab_clone_token_secret_arn, andgitlab_notify_token_secret_arn. - Set a distinct command-like
gitlab_comment_trigger. Add a project or group webhook using the Terraform-reported GitLab webhook URL and the matching secret token. Enable merge-request events and comments/notes only. - Restrict the API credential to read repository and create merge-request notes for the intended projects. Do not embed it in the clone URL.
- Create an owner-authenticated source binding with
sourceKind: "gitlab", aprojectIdselector containing the provider project ID as a string, and the selected Agent and managed environment. See provider bindings. A signed event without a matching binding returnssource_not_bound. Comments on the same merge request continue its active Session; a changed head starts a new review Session and transfers the subscription.
GitLab documents the signing-token format, Standard Webhooks headers, multi-signature verification, timestamp, idempotency header, and legacy-token warning under Webhook configuration.
For GitLab Self-Managed, add its clone hostname to allowed_repository_hosts and set the validated
gitlab_api_base_url input to that installation's REST /api/v4 endpoint. The public default is
https://gitlab.com/api/v4. Keep both values environment-specific and integration-test clone and
source delivery together.
Microsoft Teams: outgoing webhook and delivery bridge#
Teams ingress uses an outgoing webhook. Delayed results use a Workflow or a separately deployed threaded-reply gateway. For setup and secret formats, see Connect Rat Things to Microsoft Teams.
Teams @mention
-> Teams outgoing webhook (HMAC)
-> API Gateway + webhook Lambda
-> durable Session input, then acknowledgement (five-second provider deadline)
saved terminal root Turn
-> independent provider delivery
-> Teams Workflow incoming URL
-> Adaptive Card in the Workflow's configured destination
Current outgoing-webhook ingress#
Create an outgoing webhook for the target team, store the base64 HMAC secret Teams returns in
Secrets Manager, and configure its callback URL from the Terraform output. The handler validates the
Authorization: HMAC ... signature, removes the bot mention/HTML, durably records the input in S3/DynamoDB,
and then returns Rat Things request received. I'll reply when session <id> completes a turn. in the original
reply chain. Completion is asynchronous through the configured Workflow or threaded gateway. The
normalizer requires both the provider tenant ID and sender ID; a signed activity
missing either identity is rejected. The owned source binding determines Session
ownership; tenant, sender and thread determine provider continuity. The
handler is configured with a five-second timeout, so the synchronous persistence path does not
guarantee an acknowledgement under cold-start or AWS-service latency; this is another reason to
replace the bridge with a production gateway/ingest design.
This adapter inherits the documented Teams outgoing-webhook constraints:
- it is team-scoped and works only in public channels;
- it is reactive to an
@mention, not a general bot conversation; - it must return synchronously within five seconds;
- it cannot access Teams APIs such as the roster or channel list; and
- card actions are limited.
See Microsoft's Create an outgoing webhook.
Current Workflow egress#
Create a Teams Workflow using an incoming-webhook trigger, grant it only the intended channel, and
store its default URL through teams_workflow_url_secret_arn. For named destinations, map opaque
route names to Workflow URL secret ARNs with teams_route_secret_arns; Terraform injects the map as
TEAMS_ROUTES_JSON. Callers receive route names, never URLs or ARNs. An unknown named route is
rejected rather than falling back to the default.
The notifier sends an Adaptive Card containing the terminal Turn status, a truncated body, and Turn ID.
It does not use the inbound conversationId to post a proactive reply. Consequently, a source
destination means “the configured Teams Workflow destination,” which may not be the exact originating
thread.
Workflows are owned by specific users and can become orphaned without co-owners. Their channel support and webhook/card features differ from a full bot. Review Create incoming webhooks with Workflows and the Teams connector reference.
Treat the Workflow URL as a bearer credential. Rotate it on exposure, assign co-owners, monitor flow failures/throttling, and keep dev/prod flows separate.
Threaded reply gateway contract#
Set teams_delivery_mode = "threaded-gateway" and configure
teams_reply_gateway_url_secret_arn to route source replies through a trusted gateway instead of a
Workflow. The notifier posts a versioned envelope containing the original conversationId, the
inbound activity ID as replyToActivityId, a Bot Activity-shaped message with replyToId, and the
Turn ID as an idempotency key. Named Workflow routes are rejected in this mode.
The original conversation/activity reference is retained through Session ingress and terminal Turn delivery. The URL is still a credential and must point only at infrastructure controlled by the deployment. This repository does not yet implement the gateway's Microsoft Entra token exchange, Bot Connector authentication, or live tenant installation.
Recommended production Teams gateway#
An AWS-hosted Teams app/bot gateway can replace the bridge while retaining the Session contract:
- Register a Microsoft Entra/Bot identity and Teams app. Point its HTTPS messaging endpoint at an API Gateway/Lambda adapter in this repository.
- Validate Bot Framework service JWTs (issuer, audience, lifetime, signing keys) and enforce tenant allowlists before creating a trusted Teams source. Do not treat activity JSON fields as proof of identity.
- Use the Teams SDK for the Teams-facing gateway and check its current language support before choosing an implementation.
- Store an authorized conversation reference when the app is installed or messaged. Map it to a server-side destination ID; never accept a raw callback URL or arbitrary conversation ID as a public run destination.
- Submit through a privileged internal adapter that preserves the authenticated Teams source. The
general control API deliberately overwrites
sourceand is not a substitute for this trust boundary. - On terminal events, obtain an app/service token and send a proactive message to the stored conversation. The app must already be installed in the destination. Follow Microsoft's proactive messaging rules and Bot Connector authentication.
This keeps AWS as the compute/data plane while using the Microsoft identity and messaging plane that Teams requires. It enables tenant policy, installation lifecycle, exact conversation references, proactive completion, and future ordinary-input/cancel actions without coupling runs to a Power Automate owner. It must not add a mid-Turn authority-widening path.
Slack: self-hosted channel adapter#
Slack is an opt-in provider channel in each self-hosted deployment. The ingress validates Slack v0
signatures and rejects timestamps with more than five minutes of skew. It
answers URL-verification challenges and accepts app_mention events by default. Events carrying
bot_id, bot_profile, or the bot_message subtype are ignored so the adapter does not consume its
own bot output. Results use chat.postMessage, preserving the source thread when one exists.
For the user-facing workflows this enables—workspace research, durable follow-ups, controlled
posting/reactions, scheduled briefings, and broader MicroVM work launched from a mention—start with
Use Rat Things from Slack.
Like the Teams bridge, Slack currently performs secret resolution plus durable S3/DynamoDB input persistence before acknowledging the event, inside a five-second Lambda timeout. Slack requires an HTTP 2xx within three seconds and recommends acknowledging before processing; this synchronous path can therefore time out at Slack and cause provider retries even when AWS later accepted the input. Idempotency limits duplicate inputs, but not latency or retry noise. Treat an acknowledge-first durable ingress queue/worker split as a production requirement and validate cold starts against Slack's Events API response contract.
To enable it:
- Create a Slack app, register Terraform's
oauth_callback_url, set the Slack event request URL to thewebhook_urls.slackoutput, and subscribe toapp_mention. - Request bot scopes
app_mentions:read,chat:write, andreactions:write, plus user scopesearch:read. Reinstall the app after changing scopes. - Put the OAuth application's
client_id/client_secretand the separate Slack signing secret in Secrets Manager. Configure their ARNs and enable the Slack webhook route; do not store an issued bot or user token in Terraform. - Run
rat-things connect slack --oauth --wait --access read-write --alias slack-work. - Run
rat-things slack-events slack-work --agent-id agent_example --json. It derives the team selector from the verified Connection, creates one owner Connection Set/binding, and rejects a competing Connection for the same workspace. The service Connection remains write-capable for trusted threaded delivery. The Agent supplies its declared tools; this command does not select a capability profile. Add--environment-template envtpl_examplefor managed execution; without it, the binding usesenvironment: {"type":"none"}.
Slack's channel and message timestamp identify one occurrence within a binding. When Slack sends
both app_mention and message for the same message, they share one receipt and cannot create two
Turns. An explicit mention takes precedence over its candidate event. Accepted mentions require
both team_id and the event's
user ID; missing identity is ignored. slack:<team>:<user> identifies the actor. The authenticated
operator who created the matching source binding owns the Session. Channel/thread metadata and the
bot token do not establish that ownership. Delegated search visibility is exactly the installing
Slack user's visibility; it is not bot-wide or workspace-administrator search authority.
For supported behavior and current limitations, see Status and roadmap.
Event policies and quiet responses#
Each source binding can set eventPolicy. The default mode, explicit, accepts mentions,
configured repository comment triggers, and review events. A subscribed thread also accepts
follow-ups without a trigger when the provider delivers that event type. Slack ordinary messages
require the separate opt-in described below; Teams outgoing webhooks still require a mention.
ignore drops events. Bot-comment, bot-chat and result-marker filters always apply,
followed by actor and channel restrictions, before any subscription or mention can admit an event.
Trigger text filters noise; it does not authorize the author.
actors.allow and actors.deny contain exact actor IDs; deny takes precedence. IDs are
github:<login>, gitlab:<user-id>, slack:<team-id>:<user-id>, or
teams:<tenant-id>:<sender-id>. channels limits chat channel or conversation IDs. An empty
allowlist admits nobody. GitHub PR comments and GitLab MR notes require a matching allowlist entry;
omitting actors.allow disables comment admission. A trigger, subscription or semantic decision
cannot bypass that requirement. Automatic review events do not require an allowlist, but a
configured list restricts their actors too, including bots. Selectors still determine the source
binding and owner.
Candidate mode sends untriggered GitHub PR comments, GitLab MR notes, and enabled Slack ordinary messages to an asynchronous filter when they have no active thread subscription. Repository review events, triggered comments, Slack mentions and Teams outgoing-webhook messages are explicit input and bypass that model filter. Restrictions still apply to all inputs.
Set the policy when creating the source binding, or replace its event policy later. For example, a Slack binding request can include this field:
{
"eventPolicy": {
"mode": "candidate",
"actors": { "deny": ["slack:T123:U456"] },
"channels": ["C123"],
"semantic": {
"policies": ["Act on unanswered deployment questions that this team owns."],
"maxCandidatesPerHour": 30
}
}
}
Ingress persists a candidate receipt and acknowledges without invoking a model. A background
worker processes the receipt later. A tool-less Bedrock Converse request receives the
saved policies, bounded event text and recent thread text, and must return only act and reason.
Configure event_filter_model_id and exact event_filter_inference_resource_arns for a model
supporting JSON-schema output. With no configured model, or on model errors or invalid output,
the candidate is discarded. The model cannot select an Agent, destination or tool.
The cap applies per binding in fixed UTC clock hours. Decisions retain the model, policy digest, reason and boolean result for seven days; candidates older than an hour are discarded. Policy is saved with each candidate, so later policy changes cannot alter that decision. Subsequent explicit input, including a mention, triggered comment or review event, supersedes pending candidates on its thread. Provider retries retain the original receipt and decision.
Actor and channel lists accept at most 256 nonempty IDs each, with up to 512 characters per ID.
Candidate mode requires semantic: one to sixteen policies of at most 2,000 characters each,
and an integer maxCandidatesPerHour from 1 to 1,000.
A Turn containing only candidate-admitted input can complete with no text and post nothing. Explicit requests retain the normal completion reply. Candidate mode should use an Agent with mostly read-only tools: event text can manipulate the filter, and admitted events run inside the same fixed capability envelope as mentions.
For Slack, ordinary message intake additionally requires slack_candidate_events_enabled = true.
Use a separate opt-in Slack app installation, subscribe it to message.channels and
message.groups, and grant channels:history and groups:history alongside the existing scopes.
The integration's OAuth request includes those scopes only when the deployment flag is enabled.
Reading channel messages changes privacy expectations; restrict the binding's channels and use
private channels for shared-thread steering. Edited and deleted messages are ignored. Signature
verification and durable persistence still happen before acknowledgement, so the Slack latency
constraint above remains.
Create a Slack candidate binding#
Configure the deployment flag, model and exact inference resource ARNs before installing the
separate Slack app. Complete steps 1–4 of Slack setup,
including the message subscriptions and history scopes above. Use the following binding flow
instead of rat-things slack-events, which creates a default explicit binding.
Save a connection set as slack-set.json, using the alias of your verified Slack connection:
{
"version": "1",
"name": "slack-candidates",
"connections": ["slack-work"],
"defaults": { "slack": "slack-work" }
}
rat-things connection-set --file slack-set.json
Copy the returned connectionSetId into slack-binding.json. Replace the team, channel and
Agent IDs with your own. The example shares a private channel thread across participants;
omit threadScope to keep a separate Session for each sender.
{
"version": "1",
"sourceKind": "slack",
"selector": { "teamId": "T123", "channelId": "C123" },
"threadScope": "thread",
"agentId": "agent_example",
"environment": { "type": "none" },
"connectionSetId": "connection_set_from_previous_command",
"eventPolicy": {
"mode": "candidate",
"channels": ["C123"],
"semantic": {
"policies": ["Act on unanswered deployment questions that this team owns."],
"maxCandidatesPerHour": 30
}
}
}
rat-things bind-source --file slack-binding.json
rat-things source-bindings
Use an Agent with mostly read-only declared tools. The connection set enables result delivery;
it does not grant those tools. Replace environment with a managed environment when the work
needs a workspace.
Source bindings support creation, listing and event-policy replacement. Other binding fields and deletion are not editable through the control API. A second binding with the same provider and exact selector is rejected. Inspect existing bindings before creating one. A channel selector is more specific than a team-only binding and takes precedence for that channel; equally specific overlapping matches are rejected.
Change an event policy#
List bindings with rat-things source-bindings and copy the binding's bindingId. Save the complete
replacement event policy as event-policy.json. This GitHub example permits one person's comments
and review events triggered by that person or Dependabot. Bot comments remain ignored:
{
"version": "1",
"eventPolicy": {
"mode": "explicit",
"actors": { "allow": ["github:YOUR_LOGIN", "github:dependabot[bot]"] }
}
}
rat-things set-source-event-policy BINDING_ID --file event-policy.json
The equivalent authenticated request is PUT /v1/integrations/source-bindings/{bindingId}/event-policy
with that JSON body. The response contains the updated binding. Replacement preserves its ID,
selector, Agent, environment, credentials and thread subscriptions. Include every actor, channel
and semantic setting you want to retain; omitted event-policy settings are removed. A concurrent
update returns 409; reread the binding before retrying.
Existing repository bindings without an actor allowlist continue automatic reviews but ignore
comments until configured. Choose the humans and bots allowed to submit work explicitly. GitHub
uses the login from the signed event; GitLab uses the numeric user ID. Changes govern new events.
Already accepted input and candidates retain their admission policy, and running Session authority
does not change. Use mode: "ignore" to stop new intake; cancel active work separately if needed.