How to create a comment in a thread view with Step 1 Linked entity

I have an automation log where we track the external automations that should have created/changed entities in Fibery.

When certain conditions are met, we want to create a comment in a thread view with the linked automation log.

  • So that we inform the user of a failed automation (thread view will show ‘new message’)
  • But without cluttering their notifications/inbox since we’ve build an auto retry solution so that 95% will be fixed automatically.

I have an Automation log database and an entity Automation erros where I want to create the comment in so that it shows as Thread view.

image

My idea was to link the automation log to the entity automation errors (= thread view entity)

And then via that entity create a comment.

But how can I link the Step 1 linked Automation log in the comment?

So that it shows like this
image

Thanks for the help!

I’m not sure it is possible, I’m afraid to say. Although [Step 1 linked Automation log] is available in automation formulas, I don’t know of any way to extract it using markdown, sorry.

Bummer! Would it be possible via script? Or is Step 1 Linked Entity also not available there?

I don’t think so.
As far as I know, there is no way in a script to determine which item in a collection was the most recently linked.

One workaround would be a create a new to-one relation field to save the “Most recently linked Automation Log”, and create a Rule that triggers whenever an Automation Log is linked, and saves the newly linked Automation Log entity to this “Most recently linked Automation Log” field.

1 Like

Indeed, this is workable, but I believe that there is a non-zero possibility that you could ‘lose’ events if they happened in quick succession, e.g.
two items are linked, and by the time the automation checks the to-one relation, the first value has been overwritten by the second linked item, causing the first link event to be lost

2 Likes

So really, all automation activity that should happen in response to a “new entity linked” should be specified in the same Rule.

But IIUC, there is no guarantee that such an “Entity linked” Rule will get triggered for every linked entity? If so, that seems wrong…

1 Like

There will be an automation triggered for every linked entity, and if this automation’s action is to update a to-one relation with the linked item, any secondary automation which is triggered by this to-one relation being updated will also be triggered twice.
But any secondary automations will sit in the queue waiting to execute, and by the time they run, the update value of the to-one field may not be what you expect.

As an example, imagine this sequence:

To many To one
empty empty

User links two things

To many To one
ThingA, ThingB empty

Automation 1 (that triggers on linked item) is triggered twice.
First execution takes place - it updates the to-one field

To many To one
ThingA, ThingB ThingA

Automation 2 (which triggers on the to-one field being updated) is triggered, but will only execute when the queue of automations is empty

Second execution of automation 1 takes place.

To many To one
ThingA, ThingB ThingB

Automation 2 (which triggers on the to-one field being updated) is triggered again, since the value of the to-one field has changed.

The first execution of automation 2 takes place, and sees that the to-one field contains the value ‘ThingB’.
The second execution of automation 2 takes place, and sees that the to-one field contains the value ‘ThingB’.

Ideally, yes, but as @YvetteLans has discovered, markdown does not support referencing [Step 1 linked item] unlike formulas, so I can’t think of a way of making a comment that references the linked item all within a single automation rule.

2 Likes

I made a feature request for this - Automations: Support entity references like "[Step 1 linked item]" in markdown-template Actions

2 Likes

Sort by Rank ?

I don’t think so. I mean, if I drag and drop an item into a column on board view (where the columns are entities in another DB) and then I drag and drop another item into the same column, their relative rank depends on whether the second drop is above or below the first, not a function of the order in which I dropped them.

@YvetteLans Can you move this Rule to the Automation Error DB, and trigger on entity creation there?

I can do that, but I don’t think I will then be able to create a comment in the ‘automation error log’ entity/thread view :thinking: That’s the ultimate goal and I can’t create a comment in another entity as far as I know…

It’s not a real must have → we also have a view with all automation logs. But it’s not very user friendly. Since the user then needs to check that view once in a while to find out if something went wrong.

The thread view is an awesome way to inform a user without a complete inbox overwhelm.

We have a lot of integrations and some of our bigger clients have 1000+ automations actions per week.

If a third party server is down, they will get an error notification of each and every automation that fails if I use the normal notify automation in Fibery.

That’s not helpful. There will be an auto retry every hour for those failed automations. I only want to auto inform them in the meantime about the problems without overloading their inbox.

Thanks, awesome! I have more use cases for this; will put them in the feature request :slight_smile:

My approach to centralized error tracking has been to create a special “Error” DB.

When an error is detected anywhere in a Workspace script, it is reported by creating a new Error entity with all the details.

The drawback to this approach is that javascript is needed if the Error DB is not linked to the subject DB. But it is fairly easy a script. The script can also assign the new Error entity to appropriate user(s).

2 Likes

Thanks! Your solution sounds awesome!

However, the errors that we log are not caused by scripts within the workspace, but in automations outside the workspace.

The external integrations run via Node-RED (Google Calendar, Calendly, ActiveCampaign, Order automations, etc.)

When the automation start, we create an entity in the automation log database and include the payload. If the automation run without errors, we update the entity status to finished. When an error occurs, Fibery will trigger the external automation again (and includes the original payload).

As a Fibery partner, we handle the errors so no need to assign a user. Our clients can see the status of external automations in a view. And we would like to inform them about the errors so that they don’t have to open the view for that.

If I want to use the thread view for that, I only have 1 entity plus comments.

image

Let’s assume I also create a special DB for errors only. Would it then be possible to create the comment in the automation error channel via script you think?

If so, I don’t fully understand why it is possible via the error DB and not possible via the current log database :sweat_smile:

Thanks for your time and help!

I have not used comments in my Error-entities, so I have not solved that part of the problem :thinking:

But I have created comments via script in other places:

await fibery.addComment(type, Id, comment, userId, format)

Thanks! My script skills sucks but I think the challenge is that I want the URL of the error (either in a separate error database or the current automation log database) and put that entity in the comment of another entity (the channel entity where the thread view is based on).

So it’s won’t work if a script simply just add the comment; that will create a comment in the origine database instead of the channel entity I think?

A script can add a comment to any entity (assuming comments are enabled on that DB).

A script can also get an entity’s URL via utils.getEntityUrl(type, publicId).

Ah, I think this is caused by miscommunication then!

I thought that script was not possible but my question is confusing.

If I run the script in the origin database I can use the args.currentEntities and don’t need to link the entity to the channel.

Will try a few things, thanks again for all the help :smile:

1 Like