Event streaming (SSE) and XML responses
Event streaming (SSE) and XML responses
Handle text/event-stream and XML payloads in HTTP Actions. Learn how streams terminate, aggregate data: chunks safely, and parse XML outputs.
Event streaming (SSE) and XML responses
Handle text/event-stream and XML payloads in HTTP Actions. Learn how streams terminate, aggregate data: chunks safely, and parse XML outputs.
HTTP Actions can call APIs that return either streaming Server‑Sent Events (SSE) or XML. This guide explains how SSE responses terminate and how the HTTP Action behaves, how to aggregate data: event chunks into a single output, common pitfalls, and simple approaches for XML parsing.
Moveworks converts all XML responses to JSON automatically at the HTTP action layer, so XML responses can be used easily in conversational processes and compound actions.
This also allows XML responses from on-prem systems (via the Moveworks Agent) to be used.
Accept: text/event-stream.output_key. Typical shape:output_key as result or data to prevent collisions. Use something like action_output.In a Compound Action, set the HTTP Action output_key to action_output, then map the aggregated text plus any metadata:
Notes:
\n\n).data: prefix on each frame before parsing JSON ($REPLACE("^data: ", "")).: keep-alive. Filter them out if present, e.g.:The following mapping aggregates SSE frames by converting the raw stream into a JSON array, then parsing once. This is useful when frames are well‑formed JSON objects and delimited by blank lines:
How it works:
data: prefix with a comma, then drops the leading comma via [1:].chunk fields from the rest.Accept: application/json and/or use a JSON variant of the endpoint.output_key (e.g., action_output).For basic cases you can extract values using $MATCH, $REPLACE, etc. Example (extract <status>):
Use a Python Script Action after the HTTP Action to convert XML to JSON‑like text you can parse back in the mapper.
HTTP Action: set output_key: action_output.
Script Action:
xml_body mapped from data.action_output.xml_parsed.output_key: Avoid result and data. Prefer action_output, xml_parsed, etc.