Before
A user would need to download the DOCX file, open it in a compatible document application, locate the required section, and copy the relevant text manually. Each request would repeat the same document-handling and range-selection steps.
How it works
- Receive the DOCX URL and the requested text range.
- Download the document, extract its paragraph text, and select the specified portion.
- Return the extracted text and range details when processing succeeds, or route the request to the failure path when an error occurs.
Workflow details
- Trigger: The workflow starts when it receives a DOCX document URL together with the starting and ending positions for the text to return.
- Document retrieval: It downloads the document from the supplied URL and opens it for processing.
- Text extraction: The workflow reads the document's paragraphs and combines them into text, preserving paragraph breaks between the extracted sections.
- Range selection: It selects only the requested portion of the resulting text based on the supplied start and end positions.
- Completion handling: When processing completes without an error, the selected text and the requested range values are returned; if the function fails, the workflow follows a failure path with a retry-oriented error message.
What changed
The document is fetched and converted into paragraph text automatically for each request, with the requested range selected before the result is returned. The workflow also checks whether the processing function reported an error and routes unsuccessful executions to a defined failure path.
Work removed
Downloading the DOCX file, opening it, reading its paragraphs, locating the requested range, copying the selected text, and returning the extracted content manually.
Expected outcome
Each request can replace one manual document download, review, and copy sequence with an automated text extraction result.
