Autolink GitHub PRs

I have the GitHub integration set up, and it pulls in the PRs which is great, but people need to manually link PRs to entities in Fibery if they want to have it all linked up. This is a bit tedious, especially given the sync only runs once per hour.

It’d be really nice to be able to auto-link GitHub PRs to Entities in Fibery, based on a prefix in the PR name. E.g. “Task/1234: ”

Things like JIRA have specific integrations with GitHub/GitLab for this sort of thing, but I figured I’d try to get it to work in Fibery without one. :muscle:

“Automatically link X to Y” relations require an exact match not a prefix/regex. I’m unwilling to name GitHub PRs with just the Fibery entity number and requiring people to do an exact copy/paste of the entity name feels clunky. It also takes over the relationship management entirely, which precludes manually linking more PRs into a single entity.

Next attempt is going to be an automation involving GraphQL I think.
Does anyone have any example code here I can use as a leg-up, where they link entities to each other using a pattern match or startsWith or similar?

What information in a Fibery entity allows a user to see that it should be linked to a specific PR?

It sounds like you should add a formula field in Fibery that extracts/forms the PR name (using regex perhaps) and then use an auto relation to link on this field…

It sounds like you should add a formula field in Fibery that extracts/forms the PR name (using regex perhaps) and then use an auto relation to link on this field…

Good thinking. That would work, but wouldn’t let people manually link their PRs up too, unless I add a separate field for that.

What information in a Fibery entity allows a user to see that it should be linked to a specific PR?

I basically want an automation that adds an Entity link between A and B if B.Name contains A.EntityType + "/" + A.PublicId, but also allows manual linking too.

If you need to link automatically, but also allow manual changes, then you should not use auto-linking relations (they are basically read-only).
You need a (standard) relation, and you then need to write an automation to make the connection.
Without knowing the exact details, I’m not sure what the trigger(s) should be. Probably when an entity in Fibery is created.
The action will be to link the items based on an ‘entity query’:
https://the.fibery.io/@public/User_Guide/Guide/Using-First()-in-Automations---Entity-query-finder-for-a-dynamic-set-for-relations-fields-118

Yes. I’ve struggled a bit with getting hold of public IDs from the normal API (it that even possible?), hence planning to use the GraphQL API to achieve this. Thanks.

In an automation script:

const fibery = context.getService('fibery');
for (const entity of args.currentEntities) {
    console.log(entity['Public Id']);
}