Forge app interacting with long running external process?

I have an API service that coordinates long running jobs, from a few minutes to potentially hours. I’m building a Forge app that uses a provider to talk with my API. I’m not using Custom UI currently and would prefer to avoid it if possible.

My developer and I cannot seem to figure out how to accomplish a long polling type of operation in a Forge UI. Specifically, we want users to be able to kick off a job from an issue in Jira and then be notified in some way when the job has completed. I know we could notify by email, but we’re hoping for a better user experience than that. Ideally we’d like to be able to update the Forge UI app when the status of the job changes from the API.

We’ve seen the posts about using websockets and looked into web triggers but haven’t found anything that seems to accomplish this seemingly simple use case.

We’re not building on the new runtime because we need external providers which are not supported yet apparently.

Are we missing something?

2 Likes

Welcome to the Atlassian developer community @jason2,

My colleague @dmorrow wrote a blog about Forge communicating with AIs. At the heart of it though, the problem is “long polling”. Check the last section of this post:

Does it answer your question?

1 Like

Thanks. That definitely seems to be the closest to what we’re looking to do that we’ve found. We’ll dig in and report back shortly.

1 Like

Hello @ibuchanan and @dmorrow .

Thank you for the reference. It’s very helpful in directing our thinking, but I note that the long polling does not seem to actually be implemented in the sample code. It would be a great follow-up to publish code that actually did implement the long polling.

I had the following questions:

  1. Can an async event listener, using the consumer module, update a UI Kit 2 component in a loaded browser page in real-time, or will the user need to refresh the page to see the update? How does the event-listener tell the UI kit component to refresh?

  2. In the “Alternate approach” described in the picture at the bottom, can the polling be done by a UI Kit 2 component or only by a Custom component? If by a UI Kit 2 component, would it not be subject to the 25 second limit?

So I guess the heart of my question is whether we must switch to Custom UI to make this work at all?

And, if so, are there good guidelines for how to make applications that mix UI Kit and Custom UI or should I just move everything to Custom UI?

1 Like

Hi @paulprescod and @jason2 ,

After creating The basics of creating a Forge AI app and the accompanying Forge AI basics app, I created another app, Forge AI sprint builder to demonstrate the use of Forge’s async events and polling from the front end. Functions invoked by Forge async events have a 55 second timeout instead of the standard 25 seconds which can be useful for AI requests that take longer.

Can an async event listener, using the consumer module, update a UI Kit 2 component in a loaded browser page in real-time

No it can’t which is why you have to poll from the UI unfortunately.

Can the polling be done by a UI Kit 2 component or only by a Custom component?

You’d only be able to implement polling from a Custom UI.

So I guess the heart of my question is whether we must switch to Custom UI to make this work at all?

Yes, I think you’ll have to migrate to Custom UI.

Are there good guidelines for how to make applications that mix UI Kit and Custom UI or should I just move everything to Custom UI?

I don’t know of any good official guidelines, but there is no problem if you choose to employ any combinations of UI kit, UI kit 2 and Custom UI in a single app.

With that said, I’ve used the approach of the same static front end for multiple UIs as is the case here in the Forge AI basics app:

const renderedUI =
    moduleKey === 'content-summariser' ? <PageSummariserView /> :
    moduleKey === 'themed-space-index' ? <ThemedSpaceIndexView /> : null;

With this approach, it makes it simpler to share front end code.

Regards,
Dugald

Thank you Dugald!

My question about mixing custom and UI Kit was more along the lines of:

Can I build a UI Kit 2 app and have a single DIV be rendered as Custom UI?

Or have a single panel that has some parts rendered with UI Kit 2 and some rendered with Custom UI (or an Iframe).

1 Like

Hi @paulprescod ,

Thanks for clarifying. Neither UI Kit nor UI Kit 2 provides access to the underlying DOM so you can’t embed Custom UI. The other way around (UI Kit or UI Kit 2 within Custom UI) also won’t work due to server side rendering in UI Kit and UI Kit 2.

Regards,
Dugald