Dear devonthinkers,
I want to set up a smart rule that, on import, uses an AI model to extract data from a file’s content and update custom metadata with that data if it is extracted. Whilst chat can add tags, it cannot modify custom metadata. Is it possible to do this via a smart rule that can update metadata? If possible, how can I pass the output of the AI chat action in the smart rule to the update metadata action?
As a use case, I would like to implement something similar to the Devonthink community AppleScript for extracting receipt data and placing it in a custom metadata field, which can then be used to create an “Expense Report”.
Regards, Alex
Welcome @asobolev
See the Automation > AI Assisted Automation section of the built-in Help and manual for more information on the smart actions and scripting used with external AI.
There are also AI-controlled placeholders discussed in the Appendix > Placeholders that can be used in some instances.
And the choices you make depend on the tasks you need to perform. Changing one custom attribute should be fairly trivial. Changing multiple attribute without reprocessing the same document multiple times requires some scripting and forethought.
Here is an example…
… via…
Note the Suggested placeholders are from Chat Suggestions. These use the default Chat model you have chosen. They do their best to parse things but the results depend on the AI model’s capabilities. This was done with Claude 4.5 Sonnet. Haiku struggled to determine the location.
And the prompt to get the payment method since there isn’t a built-in Chat suggestion…
Examine the receipt or invoice and only return the simple method of payment, e.g., MasterCard, VISA, cash, etc. Return N/A if one is not found. No chatter.
1 Like
See also this default smart rule:
Thank you, Jim and Cristian,
Very informative. I understand that I need to make a separate call to the model for each metadata field change, which would multiply the cost of model usage. It would be expensive if I had a rich schema of custom metadata, given that the free or local models don’t do a good job for such tasks at present. Is there a way, say, to use AppleScript to handle multiple metadata fields in a single query? If so, are there examples of such scripts that could get me started?
Kind regards,
Alex
You’re welcome.
I understand that I need to make a separate call to the model for each metadata field change, which would multiply the cost of model usage
Not quite. As I noted, it depends on what you’re doing and my example showed how you can send a specific query via the smart action.
Yes, there is scripting support as I noted in my previous reply…
See the Automation > AI Assisted Automation section of the built-in Help and manual for more information on the smart actions and scripting used with external AI.
However, you have to construct the query to return results that can be parsed and used in different ways, e.g., updating multiple custom attributes.