Quick Overview
This sub-workflow receives an email item with binary attachments, uses an OpenAI-compatible chat completions endpoint to detect and extract invoice fields from PDF/XML/JSON files, and then creates an incoming invoice in work4all with the relevant original attachments.
How it works
- Receives an item from a parent workflow via Execute Workflow Trigger containing the email metadata and binary attachments.
- Checks whether any attachments exist and skips processing if none are provided.
- Builds a chat-completions request that includes a strict JSON extraction prompt plus any readable PDF/XML/JSON attachment content.
- Sends the request to an OpenAI-compatible HTTP endpoint and parses the returned JSON to determine whether an invoice is present.
- If an invoice is found, filters to the relevant attachments, normalizes fields (forces EUR and converts dates), and adds entry/receipt dates from the email receivedDateTime.
- Creates the incoming invoice in work4all and returns the created invoice data and any errors along with the original message ID.
- If no invoice is found (or no readable attachments exist), returns a minimal “success” result with the original message ID to the caller.
Setup
- Add a work4all OAuth2 credential and ensure the verified work4all community node is installed.
- Add an OpenAI-compatible API credential and set the chat-completions URL (and required headers) in the HTTP Request step.
- Update the model name in the “Build LLM messages” code to one that supports file/PDF input for your chosen provider.
- Ensure the parent workflow passes a single email item with binary attachment properties plus id and receivedDateTime fields when calling this sub-workflow.