Skip to main content

REFERENCE

SDK Demos

How to use @asgard-js/core and @asgard-js/react, with demos you can try on the page.

cwd:// Download Actions

When an ATTACHMENT's defaultAction / downloadAction uses a cwd://<relative-path> URI, the SDK intercepts cwd:// and fetches <botProviderEndpoint>/cwd/download to retrieve the file and trigger a browser download, instead of window.open (which cannot open cwd://).

This is common with sandbox / code-server style bots: the agent produces a file in its working directory and offers a cwd:// link for the user to download.

  1. Highlights​

    • A cwd:// downloadAction (type: "uri") is enough to show the download icon — an EMIT download_file is no longer required.
    • Clicking the card or the download icon fires GET <base>/cwd/download?custom_channel_id=...&relative_path=....
  2. Code Example (attachment template)​

    template: {
    type: MessageTemplateType.ATTACHMENT,
    attachments: [
    {
    title: "sales-ranking.json",
    defaultAction: { type: "uri", uri: "cwd://sales-ranking.json" },
    downloadAction: { type: "uri", uri: "cwd://sales-ranking.json" },
    },
    ],
    quickReplies: [],
    }

    The example above runs in preview mode (botProviderEndpoint: "skip") to show the attachment download UI; an actual download requires a Bot Provider that returns cwd:// actions and serves /cwd/download.

Ready to get started?

Want to see how Asgard fits your team? Talk to us.

Contact us