Here is the step-by-step academy guide designed to accompany this invoice automation video. It is structured to serve as an easy-to-follow lesson for your students.
Academy Lesson: AI Invoice Automation (Gmail to Salesforce)
Learn how to leverage Docrag AI and Noca Web to build an automated workflow that intercepts incoming emails, extracts invoice details and complex line-item tables via simple AI prompts, and automatically populates records in Salesforce.
Step 1: Set Up the Gmail Trigger
To begin our automation, we need to listen for incoming emails.
-
Create a new blank flow in the Noca canvas.
-
Add a Google Gmail trigger node as your starting point.
-
Set the trigger event to Email Received. This ensures the flow runs automatically every time a new message hits your inbox.
Step 2: Filter for Invoices Using a Condition Node
To prevent the flow from running on unrelated emails, add a filter to check the attachments.
-
Add a Condition node immediately following the Gmail trigger.
-
Open the Data Kit on the right and navigate to Google Gmail > App Fields > Message Attachments.
-
Set up the rule:
File Name➡️ Contains ➡️ type"invoice". -
The flow will now only proceed down the True path if an attached file matches this rule.
Step 3: Extract Invoice Header Data with Docrag AI
Next, we use plain language prompts to pull top-level metadata from the document.
-
Attach a Docrag AI node to the true path of your condition node.
-
Map the file content field to the Gmail attachment by selecting Google Gmail > App Fields > Message Attachments > File.
-
Add specific prompt-based questions for the fields you want to extract:
-
Extract the invoice date in YYYY-MM-DD format.
-
Extract the invoice currency code.
-
Extract the invoice grand total.
-
Extract the invoice number.
-
Extract the invoice notes (one line only).
-
Step 4: Extract Line-Item Tables
Invoices usually contain tables with shifting numbers of rows. We can extract these dynamically using a specialized table node.
-
Add an Extract Document Table node to your flow.
-
Map the
Filetarget back to your Google Gmail Attachment file. -
Define the exact columns you want the AI to pull from the invoice layout:
-
Item Name
-
Quantity
-
Unit Price
-
Line Total
-
Step 5: Create the Main Invoice Record in Salesforce
Now that the data is extracted, we need to push it into Salesforce.
-
Add a Salesforce Object Create node.
-
Select Invoice as the target object.
-
Manually map the Salesforce fields to the data extracted by your Docrag AI node (Date, Currency, Grand Total, Invoice Number, Notes).
Step 6: Create the Related Line Items
To finish the process, we map the structural table rows into separate line items and link them to our newly created parent invoice.
-
Add another Salesforce Object Create node right after the first one.
-
Select Invoice Line Item as the target object.
-
Map the fields (Item Name, Quantity, Unit Price) which Noca will auto-detect from your Extract Document Table node.
-
Manually map the missing
Line Totalfield from Rule 1 > Extract Document Table > Line Total. -
Crucial Step: To link these line items to the correct invoice, map the
Invoicelookup field in this node to the Record ID output of the previous Salesforce Invoice Create node.
Step 7: Go Live and Test
-
Click Go Live in the top right to deploy your automated process.
-
Send a test email to your connected Gmail account with an invoice PDF attached.
-
Navigate to the Logs tab in Noca and use the Debug viewer to watch the AI process the document, pull the tables, and generate the connected records in Salesforce in real time!