We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Invoice creation using document intelligence

VenkateshA42034
Tera Contributor

I need to create a new invoice record whenever an inbound email comes in with attachment and need to extract the values from the attachment using document intelligence and map the values to the invoice record.

Could any one help me on this?

2 REPLIES 2

HaimNizri
Tera Contributor

This is a pretty cool use case! I've implemented something similar for processing vendor invoices automatically.

You'll want to break this into a few pieces:

First, set up an inbound email action to trigger when emails come in with attachments. That part's straightforward - create the email processing rule and have it call a Script Include or Business Rule.

For the document intelligence piece, you'll need to use ServiceNow's Document Intelligence API. The key is getting your attachment content and sending it to the ML service:

```javascript
var docIntel = new DocumentIntelligence();
var result = docIntel.processDocument(attachmentSysId, 'invoice'); // or whatever model you're using
```

The tricky part is mapping the extracted data to your invoice fields. Document Intelligence returns a JSON structure with the extracted values, but you'll need to handle cases where the extraction isn't perfect. I usually build in some validation logic:

```javascript
if (result.invoice_number && result.invoice_number.confidence > 0.8) {
invoiceGR.number = result.invoice_number.value;
}
```

One heads up - make sure you have the right Document Intelligence models trained for your invoice formats. The out-of-box models are decent but you might need to train custom ones depending on your vendors.

Are you planning to auto-create the invoices or queue them for review? I've found it's usually better to create them in a "pending review" state first until you're confident in the extraction accuracy.

What's your current setup like - are these coming from specific vendors or a mixed bag?

Currently I have created a inbound email action to create an invoice and copy the attachments to invoice record.

Now I want to extract the values from attachment using flow desingner and update the invoice record.

I have a document intelligent use case which is trained with some invoices and stores the data in invoice staging table .

I need to call this doc intelligence use case in the flow desingner and update the invoice record.