[DONE] About using entity fields

I asked GPT-3.5 from the Fibery interface :grinning:. He suggested this solution - insert Markdown markup:

{{#find “00cd1a20-e433-11ed-9262-53adc0ca5a59”}}
{{Product}}
{{/find}}

But an error occurs:
Test is failed. Failed to execute Action “Overwrite Test”: Identifier directly after number (87:24)

If you want to transfer data (incl rich text content) from an entity in db1 to one in db2, then there typically needs to be a connection between the dbs.
What is the meaning behind the transfer in your case?
Can you make the example concrete

I am setting up automation in database 2. The automation replaces one of the RichText fields with the result of the AI.
To do this, a prompt is made in the automation. Here I need to specify the content of the RichText field of one of the entities from database 1.
The whole process is shown in the images above

How are db1 and db2 related?

With relation ))). Many to Many

My task has already been described earlier here.

That’s what I really need. The need to mention entities is one solution that came to mind.

The idea is to add data from different databases to the AI prompt.

If the relation is many-to-many, how does an automation in db2, know which entity in db1 it should be extracting the rich text content from?

That’s also a question. Because need a relation «many to many».

But in fact the question is quite different. I wrote above.

«to add data from different databases to the AI prompt.»
Any solution can be a solution. If there is one, of course.

Well, the short answer is that AI can’t currently be used to populate from rich text fields.
But I had hoped by digging into the details we might be able to find a workaround, but that seems unlikely.

Filling RichText with AI is possible within a single database. To do this, just use «Automations» — «Button» — «Overwrite Field» — Prompt with [ai][/ai].
But… «to add data from different databases to the AI prompt» — I haven’t figured out a solution yet ))).

Thank you for taking the time to find a solution :wink:

There is an idea to take data from documents created in Space. But I haven’t found what the syntax of such a request should be in Markdown.

Sorry, I missed a word:
‘populate from rich text fields’

(I’ve update my reply above)

and actually, it is not related to AI - in general, automations can’t extract rich text from linked collections

1 Like

There seems to be a hint in this article.

https://the.fibery.io/search/kiiZP#User_Guide/Guide/Markdown-templates-53

But I’m not good at JavaScript.

So we’ll wait for Fibery updates. ))

Well, if you want to do it with scripting, it may be possible. For example, you could use a script to populate the rich text field in db2 with the contents of the rich text fields of the linked entities in db1, and then use AI to take this description and overwrite the description with the output.
But there’s not a no-code solution.

1 Like

Something like this might work:

Here’s the script (which you’ll need to modify according to your database and field names.

const fibery = context.getService('fibery');

for (const entity of args.currentEntities) {
   
    const entityPlus = await fibery.getEntityById(entity.type, entity.id, ['Description','Sources']);
    const sources = await fibery.getEntitiesByIds('Source', entityPlus['Sources'].map((s) => s.id), ['Description'])
    await fibery.setDocumentContent(entityPlus['Description']['Secret'], '')
    for (const source of sources) {
        const sourceDesc = await fibery.getDocumentContent(source['Description']['Secret']);
        await fibery.appendDocumentContent(entityPlus['Description']['Secret'],sourceDesc)
    }
}
1 Like

Thank you very much. I will definitely give it a try.

I found a solution to my problem. It was on the surface. No code :grinning: .
It’s probably obvious to experienced Fibery users. But no one suggested it. So I had to look it up. :sunglasses:

Here’s everything we need: 2 databases, some RichText fields, the right relations.

The conditions of the problem in the form of screenshots were indicated in my question.
Here’s the solution:

Relations determine which data will be used in the Prompt.
This solution allows us to pull data only from the entities we need. Not a complete list of all field values of all entities in the database.

While in the DB2 database, we select the entity where we want to generate a response from the AI. And it is generated based on the DB1 database data that is defined by relation.

I’m happy. :sweat_smile:

Glad to hear you solved it to your satisfaction, but I don’t quite understand this:

If Ad1 were to be related to Avatar 1 AND Avatar 2, what would happen in your automation?
It looks to me like the automation should only work if the relation between db2 and db1 is many-to-one