graph:smartLink in Confluence apps

Hi,

We have a Forge app and would like to use graph:smartLink as defined there: https://developer.atlassian.com/platform/forge/manifest-reference/modules/teamwork-graph-smart-link/

  • When I paste the URL in Confluence, it doesn’t transform into a smart link.
  • Even if I click “Display as card”, it doesn’t call our function (no visible invocation in the Forge Tunnel),
  • In “Manage apps” → the app → “Connections” → Teamwork Graphs connectors, it doesn’t display the app.

It’s as-if the manifest is not properly recorded. Can anyone tell what I am missing?

  • I’m sure I’ve executed “forge deploy” then “forge tunnel” before each experiment,
  • I’m sure other Forge functions are executed, since, when we export in PDF, we see our adfExporter invocation (“invocation: 36f0ffd7e42faf5bf07f9b02e95cca40 index.exportDefinitionMacro”),
  • No message in the https://developer.atlassian.com/console, and no warning either in forge deploy which returns ✔ Deployed,
  • Do we need to list the domain name example-hello-world.com in some kind of approved networking list, remotes, permission declaration, elsewhere in the manifest than the graph:smartLink?
  • Do we need to declare the function as async?

For reference, here’s our manifest.yml:

modules:
  graph:smartLink:
    - key: sl-test-example-hello-world
      icon: https://static.example-hello-world.com/favicon.ico
      name: sl-test
      function: getEntityByUrl
      domains:
        - example-hello-world.com
        - www.example-hello-world.com
      subdomains: true
      patterns:
        - https:\/\/example-hello-world.com\/123456
        - https:\/\/([\w\.-]+\.)?example-hello-world\.com\/([0-9a-zA-Z]{4,128})(?:\/.*)?$
  function:
    - key: getEntityByUrl
      handler: index.myForgeFunction

Then in src/index.ts:

export { myForgeFunction } from "./backend/functions/myForgeFunction";

Then in src/backend/functions/myForgeFunction.ts:

export const myForgeFunction = (payload: SmartLinkPayload): SmartLinkRendering => {
    console.error("Displaying a smart link2");
    console.error(JSON.stringify(payload));
    return {
        entities: [
            {
                identifier: {
                    url: "https://example-hello-world.com/123456",
                    ... the rest is like the example
                    https://developer.atlassian.com/platform/forge/build-a-smart-link-app/

Thank you!

Hi @aragot ,

I’ve just copy pasted your code and installed it into my site. It worked perfectly in that on paste of the link “https://example-hello-world.com/123456” (your first pattern) it triggered the correct function and printed the console.error messages.

Is it possible to provide me with the full myForgeFunction logic to test it end to end?

When you tunnel, do you see the error messages printed when you paste a link?

And then finally is the first pattern intentionally hardcoded to a specific url ending in 123456, or should it also have the regex pattern as in the second example? I’m assuming this was done for testing.

Note that the browser can cache the same URL outcome for up to 5min. If you are making a lot of changes in the response message, try using a different URL each time to ensure you are not getting back the old result.