Quick overview
This workflow triggers on a Gmail message from a specific sender, extracts bill of lading data from an email attachment using Google Gemini, validates the extracted values with Python, posts the structured JSON to a webhook URL, and replies to the sender with an HTML acceptance email.
How it works
- Triggers when a new Gmail email arrives from the configured sender and downloads the attached document.
- Uses Google Gemini to analyze the attachment and rewrite the bill of lading content into a structured Markdown format.
- Uses a second Google Gemini agent with a structured output schema to convert the Markdown into validated JSON fields for shipper, consignee, shipment details, and line items.
- Runs a Python validation that compares customer order package/weight values against the carrier line items and appends a validation result to the JSON.
- Sends the resulting JSON payload to an external HTTP webhook endpoint.
- Uses Google Gemini to draft an HTML acceptance reply email based on the validated data and sends it back to the original sender via Gmail.
Setup
- Connect your Gmail OAuth2 credentials and set the sender filter (and any other Gmail Trigger options) to match the emails you want to process.
- Add Google Gemini (PaLM) API credentials and confirm the selected Gemini models are available in your account.
- Ensure the incoming emails include a compatible bill of lading attachment and update the binary attachment property name if it differs from
attachment_0.
- Replace the HTTP Request URL with your own endpoint that should receive the structured JSON payload.
- Review the structured JSON schema and the Python validation logic to match your required fields and matching rules before enabling the workflow.
Customization
- Any LLM provider can do the task, change Gemini with any AI you can use
Additional info
This is an example of prompt chaining. It is an AI agent workflow that shows the benefit of chaining several LLMs together.