You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/docs/content/docs/en/blocks/human-in-the-loop.mdx
+80-11Lines changed: 80 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,7 +78,7 @@ Defines the fields approvers fill in when responding. This data becomes availabl
78
78
}
79
79
```
80
80
81
-
Access resume data in downstream blocks using `<blockId.resumeInput.fieldName>`.
81
+
Access resume data in downstream blocks using `<blockId.fieldName>`.
82
82
83
83
## Approval Methods
84
84
@@ -93,11 +93,12 @@ Access resume data in downstream blocks using `<blockId.resumeInput.fieldName>`.
93
93
<Tab>
94
94
### REST API
95
95
96
-
Programmatically resume workflows using the resume endpoint. The `contextId` is available from the block's `resumeEndpoint` output or from the paused execution detail.
96
+
Programmatically resume workflows using the resume endpoint. The `contextId` is available from the block's `resumeEndpoint` output or from the `_resume` object in the paused execution response.
97
97
98
98
```bash
99
99
POST /api/resume/{workflowId}/{executionId}/{contextId}
100
100
Content-Type: application/json
101
+
X-API-Key: your-api-key
101
102
102
103
{
103
104
"input": {
@@ -107,23 +108,44 @@ Access resume data in downstream blocks using `<blockId.resumeInput.fieldName>`.
107
108
}
108
109
```
109
110
110
-
The response includes a new `executionId` for the resumed execution:
111
+
The resume endpoint automatically respects the execution mode used in the original execute call:
112
+
113
+
- **Sync mode** (default) — The response waits for the remaining workflow to complete and returns the full result:
If the resumed workflow hits another HITL block, the response returns `"status": "paused"` with new `_resume` URLs in the output.
126
+
127
+
- **Stream mode** (`stream: true` on the original execute call) — The resume response streams SSE events with `selectedOutputs` chunks, just like the initial execution.
128
+
129
+
- **Async mode** (`X-Execution-Mode: async` on the original execute call) — The resume dispatches execution to a background worker and returns immediately with `202`:
111
130
112
131
```json
113
132
{
114
133
"status": "started",
115
134
"executionId": "<resumeExecutionId>",
116
-
"message": "Resume execution started."
135
+
"message": "Resume execution started asynchronously."
117
136
}
118
137
```
119
138
120
-
To poll execution progress after resuming, connect to the SSE stream:
139
+
#### Polling execution status
140
+
141
+
To check on a paused execution or poll for completion after an async resume:
121
142
122
143
```bash
123
-
GET /api/workflows/{workflowId}/executions/{resumeExecutionId}/stream
144
+
GET /api/resume/{workflowId}/{executionId}
145
+
X-API-Key: your-api-key
124
146
```
125
147
126
-
Build custom approval UIs or integrate with existing systems.
148
+
Returns the full paused execution detail with all pause points, their statuses, and resume links. Returns `404` when the execution has completed and is no longer paused.
127
149
</Tab>
128
150
<Tab>
129
151
### Webhook
@@ -132,6 +154,53 @@ Access resume data in downstream blocks using `<blockId.resumeInput.fieldName>`.
132
154
</Tab>
133
155
</Tabs>
134
156
157
+
## API Execute Behavior
158
+
159
+
When triggering a workflow via the execute API (`POST /api/workflows/{id}/execute`), HITL blocks cause the execution to pause and return the `_resume` data in the response:
Blocks before the HITL stream their `selectedOutputs` normally. When execution pauses, the final SSE event includes `status: "paused"` and the `_resume` data:
On resume, blocks after the HITL stream their `selectedOutputs` the same way.
194
+
195
+
<Callouttype="info">
196
+
HITL blocks are automatically excluded from the `selectedOutputs` dropdown since their data is always included in the pause response.
197
+
</Callout>
198
+
</Tab>
199
+
<Tab>
200
+
Returns `202` immediately. Use the polling endpoint to check when the execution pauses.
201
+
</Tab>
202
+
</Tabs>
203
+
135
204
## Common Use Cases
136
205
137
206
**Content Approval** - Review AI-generated content before publishing
@@ -161,9 +230,9 @@ Agent (Generate) → Human in the Loop (QA) → Gmail (Send)
161
230
**`response`** - Display data shown to the approver (json)
162
231
**`submission`** - Form submission data from the approver (json)
163
232
**`submittedAt`** - ISO timestamp when the workflow was resumed
164
-
**`resumeInput.*`** - All fields defined in Resume Form become available after the workflow resumes
233
+
**`<fieldName>`** - All fields defined in Resume Form become available at the top level after the workflow resumes
165
234
166
-
Access using `<blockId.resumeInput.fieldName>`.
235
+
Access using `<blockId.fieldName>`.
167
236
168
237
## Example
169
238
@@ -187,7 +256,7 @@ Access using `<blockId.resumeInput.fieldName>`.
187
256
**Downstream Usage:**
188
257
```javascript
189
258
// Condition block
190
-
<approval1.resumeInput.approved>===true
259
+
<approval1.approved>===true
191
260
```
192
261
The example below shows an approval portal as seen by an approver after the workflow is paused. Approvers can review the data and provide inputs as a part of the workflow resumption. The approval portal can be accessed directly via the unique URL, `<blockId.url>`.
193
262
@@ -204,7 +273,7 @@ The example below shows an approval portal as seen by an approver after the work
204
273
<FAQitems={[
205
274
{ question: "How long does the workflow stay paused?", answer: "The workflow pauses indefinitely until a human provides input through the approval portal, the REST API, or a webhook. There is no automatic timeout — it will wait until someone responds." },
206
275
{ question: "What notification channels can I use to alert approvers?", answer: "You can configure notifications through Slack, Gmail, Microsoft Teams, SMS (via Twilio), or custom webhooks. Include the approval URL in your notification message so approvers can access the portal directly." },
207
-
{ question: "How do I access the approver's input in downstream blocks?", answer: "Use the syntax <blockId.resumeInput.fieldName> to reference specific fields from the resume form. For example, if your block ID is 'approval1' and the form has an 'approved' field, use <approval1.resumeInput.approved>." },
276
+
{ question: "How do I access the approver's input in downstream blocks?", answer: "Use the syntax <blockId.fieldName> to reference specific fields from the resume form. For example, if your block name is 'approval1' and the form has an 'approved' field, use <approval1.approved>." },
208
277
{ question: "Can I chain multiple Human in the Loop blocks for multi-stage approvals?", answer: "Yes. You can place multiple Human in the Loop blocks in sequence to create multi-stage approval workflows. Each block pauses independently and can have its own notification configuration and resume form fields." },
209
278
{ question: "Can I resume the workflow programmatically without the portal?", answer: "Yes. Each block exposes a resume API endpoint that you can call with a POST request containing the form data as JSON. This lets you build custom approval UIs or integrate with existing systems like Jira or ServiceNow." },
210
279
{ question: "What outputs are available after the workflow resumes?", answer: "The block outputs include the approval portal URL, the resume API endpoint URL, the display data shown to the approver, the form submission data, the raw resume input, and an ISO timestamp of when the workflow was resumed." },
[AWS CloudWatch](https://aws.amazon.com/cloudwatch/) is a monitoring and observability service that provides data and actionable insights for AWS resources, applications, and services. CloudWatch collects monitoring and operational data in the form of logs, metrics, and events, giving you a unified view of your AWS environment.
15
+
16
+
With the CloudWatch integration, you can:
17
+
18
+
-**Query Logs (Insights)**: Run CloudWatch Log Insights queries against one or more log groups to analyze log data with a powerful query language
19
+
-**Describe Log Groups**: List available CloudWatch log groups in your account, optionally filtered by name prefix
20
+
-**Get Log Events**: Retrieve log events from a specific log stream within a log group
21
+
-**Describe Log Streams**: List log streams within a log group, ordered by last event time or filtered by name prefix
22
+
-**List Metrics**: Browse available CloudWatch metrics, optionally filtered by namespace, metric name, or recent activity
23
+
-**Get Metric Statistics**: Retrieve statistical data for a metric over a specified time range with configurable granularity
24
+
-**Publish Metric**: Publish custom metric data points to CloudWatch for your own application monitoring
25
+
-**Describe Alarms**: List and filter CloudWatch alarms by name prefix, state, or alarm type
26
+
27
+
In Sim, the CloudWatch integration enables your agents to monitor AWS infrastructure, analyze application logs, track custom metrics, and respond to alarm states as part of automated DevOps and SRE workflows. This is especially powerful when combined with other AWS integrations like CloudFormation and SNS for end-to-end infrastructure management.
28
+
{/* MANUAL-CONTENT-END */}
29
+
30
+
13
31
## Usage Instructions
14
32
15
33
Integrate AWS CloudWatch into workflows. Run Log Insights queries, list log groups, retrieve log events, list and get metrics, and monitor alarms. Requires AWS access key and secret access key.
@@ -155,6 +173,34 @@ Get statistics for a CloudWatch metric over a time range
155
173
|`label`| string | Metric label |
156
174
|`datapoints`| array | Datapoints with timestamp and statistics values |
157
175
176
+
### `cloudwatch_put_metric_data`
177
+
178
+
Publish a custom metric data point to CloudWatch
179
+
180
+
#### Input
181
+
182
+
| Parameter | Type | Required | Description |
183
+
| --------- | ---- | -------- | ----------- |
184
+
|`awsRegion`| string | Yes | AWS region \(e.g., us-east-1\)|
185
+
|`awsAccessKeyId`| string | Yes | AWS access key ID |
0 commit comments