Quick overview
This workflow receives shipment requests via webhook, pulls carrier rate data from Google Sheets, uses OpenAI GPT-4o to generate a ranked HTML freight quote, converts it to a PDF with PDFShift, and emails the PDF to the customer via Gmail, with Slack alerts on workflow errors.
How it works
- Receives a POST webhook request containing shipment details like origin, destination, weight, mode, and customer contact information.
- Reads rate information in parallel from three carrier tabs in a Google Sheets spreadsheet (BlueDart, DTDC, and Delhivery).
- Combines the carrier results and calculates per-carrier total cost based on the shipment weight.
- Sends the shipment and carrier data to OpenAI GPT-4o to generate a complete HTML quote page with a ranked comparison table.
- Converts the generated HTML into an A4 PDF file using the PDFShift API.
- Emails the PDF quote to the customer using Gmail with a prefilled subject and message.
- If the workflow fails, posts an error alert message to a Slack channel.
Setup
- Configure the webhook path in n8n and copy the production webhook URL into the system that submits shipment requests.
- Add Google Sheets OAuth2 credentials and ensure the referenced spreadsheet and carrier sheet tabs (BlueDart_Rates, DTDC_Rates, Delhivery_Rates) exist and include the expected columns (for example, Rate_Per_Kg and Transit_Days).
- Add an OpenAI API credential for the GPT-4o step and confirm the prompt/model settings generate HTML in the expected format.
- Add your PDFShift API key by replacing the X-API-Key header value in the PDFShift request (and switch off sandbox mode if you want live PDFs).
- Add Gmail OAuth2 credentials and verify the sender mailbox and attachment settings for the outbound quote email.
- (Optional) Add Slack OAuth2 credentials and set the target channel for error notifications.