cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Regular Visitor

OCR_MailAttachment_AI_Builder

Hi Powerusers

 

I hope that you can help me finish my Flow as I have been working on it for some time now.

Be aware I am absolute no JSON expert and coding in general. I know I need to do some more reading in this area.

 

What I want to achieve

- An Email arrives with an attachment (PDF) to specific mailbox

- Use AI Builder to scan and Pick a specific value (Part Number) from a PDF-attachment (Pick List)

- Send an email to a specific mailbox where:

            -Subject = Part Number from Pick List

            -Attachment = Original Attachment

 

AI Builder

To begin with, I have trained AI_Builder using the Microsoft examples, just to get started. The Value (InvoiceNumber) in this case

has been marked as the area/value I want to use using the Training of these documents. InvoiceNumber will be Part Number in my real scenario. See the Screenshot below from Power Automate - AI Builder - Models. It has been saved as "SFK_Test_Simple_AI".

 
 

2020-01-29 10_52_45-Manage your models _ Power Automate.png

 

My Current Flow

I found out that to use AI Builder Trained Models, then I needed to create a flow under a Solution.

Therefore I created a solution and started my flow.

 

In the screenshots demonstrated below I will start by showing you a full overview of the Flow and afterwards expanding and going into details of the Actions and the individual flows.

 

Flow Full Overview

2020-01-29 11_02_11-Edit your flow _ Power Automate.png2020-01-29 11_02_35-Edit your flow _ Power Automate.png

 

Detailed Overview

 

When a new email arrives (V3) 2

What I did:

- Set to to the mailbox, who will be receiving the PDF Pick Lists

- Set "Include Attachments" to YES

2020-01-29 11_04_02-Edit your flow _ Power Automate.png

 

Apply to Each + Get Attachment (V2)

What I did:

- Apply to Each: Set "Select an output from previous steps" = Attachments

- Get Attachment (V2): Set Message Id to "Message Id" and Set "Attachment Id to = Attachments Attachment Id

2020-01-29 11_08_45-Edit your flow _ Power Automate.png

 

Predict 2

What I did:

- Set "Model" to the Trained AI_Builder Model

- Set "Request Payload" to:

{
"base64Encoded": "@{string(outputs('Get_Attachment_(V2)')?['body/contentBytes'])}",
"mimeType": "application/pdf"
}

2020-01-29 11_11_56-Edit your flow _ Power Automate.png

 

Parse JSON 2

What I did:

- Set "Content" to Response Payload

- Set "Schema" to:

2020-01-29 11_14_30-_new 4 - Notepad++.png

 

2020-01-29 11_15_23-Edit your flow _ Power Automate.png

Filter array

This is also where I am stuck. I now the Filter Array takes info from the JSON. I am just stuck and cant figure out how it is doing it and how to handle it. Therefore I know the below is wrong. I am hoping you PowerUsers can help me to get this right.

- Set "From" to predictionOutput

- Set "Value" to predictionOutput -> Contains -> 089936 (This is the Invoice Number of the Attachment I am testing with)

2020-01-29 11_20_20-Edit your flow _ Power Automate.png

 

Send an email (V2)

What I did:

- Set "To" to my own mail address for testing

- I want subject to be InvoiceNumber (Part Number in Real Life)

- I want the original Attachment to be included in the mail.

2020-01-29 11_21_36-Edit your flow _ Power Automate.png

 

 

ANY help is appreciated. I know that from the JSON and down it looks kinda crappy, so please bare with me.

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Power Apps
Power Apps

Hi @farfan,

 

Thanks for your question.

 

Since yesterday, the experience to use you AI Builder models in Power Automate is now much simpler. 🙂 Here's the updated documentation that explains how to do it: https://docs.microsoft.com/en-us/ai-builder/form-processing-model-in-flow

 

For your use case, here is how you can build your flow: 

 

1. Start with the Outlook trigger, making sure Has Attachment and Include Attachment are set to Yes

 

2. Add the predict action, select your model and add:

  • Document type: Attachments Content-Type
  • Document: Attachments Content

3. Add a condition to check if the invoice id matches the one you are interested in. 

 

4. In the Send email action

  • Select the Invoice Id attribute coming out from the predict action 
  • Set as Attachments Name: Attachments Name  
  • Set as Attachments Contents: Attachment Content

 

Let us know if this helps! 

 

2020-01-30_11-04-56.png

View solution in original post

3 REPLIES 3
Highlighted
Community Support
Community Support

Hi @farfan ,

 

What is your problem to achieve your requirement?

 

Best regards,

Alice       

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Highlighted
Power Apps
Power Apps

Hi @farfan,

 

Thanks for your question.

 

Since yesterday, the experience to use you AI Builder models in Power Automate is now much simpler. 🙂 Here's the updated documentation that explains how to do it: https://docs.microsoft.com/en-us/ai-builder/form-processing-model-in-flow

 

For your use case, here is how you can build your flow: 

 

1. Start with the Outlook trigger, making sure Has Attachment and Include Attachment are set to Yes

 

2. Add the predict action, select your model and add:

  • Document type: Attachments Content-Type
  • Document: Attachments Content

3. Add a condition to check if the invoice id matches the one you are interested in. 

 

4. In the Send email action

  • Select the Invoice Id attribute coming out from the predict action 
  • Set as Attachments Name: Attachments Name  
  • Set as Attachments Contents: Attachment Content

 

Let us know if this helps! 

 

2020-01-30_11-04-56.png

View solution in original post

Highlighted

Works perfectly.

 

Thank you ALOT @JoeF-MSFT ur a lifesaver!

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Top Solution Authors
Top Kudoed Authors
Users online (11,822)