botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

[Question] How to open file using Actions.OpenUrl?

Open meganlcooper opened this issue 9 years ago • 10 comments

I want to open a file from a button on a hero card. Why does using file:///...file or network location... not seem to work? Here is my code:

var helpHeroCard = new HeroCard {
      Title = "Build Location",
      Buttons = new List<CardAction> {
            new CardAction(ActionTypes.OpenUrl , "\\\\DUMMY_SERVER\\" , value: "file:\\\\DUMMY_SERVER\\")
      }
};
helpMsg.Attachments.Add(helpHeroCard.ToAttachment());
await context.PostAsync(helpMsg);

Thanks!

meganlcooper avatar Jun 09 '17 19:06 meganlcooper

can you please share the code in order to repro?

msmohan avatar Jun 09 '17 20:06 msmohan

Sorry I'm new to this. Do you mean upload my code to github? I just wanted to know if there's a way to open a file or network connection from a HeroCard button. When I hover over it in visual studio I can CTRL+ to get to the server so I know the link is formatted right. I can't share any of my code for privacy reasons.

meganlcooper avatar Jun 09 '17 20:06 meganlcooper

you can choose to upload it to GitHub or you could upload it to onedrive and share the link.

msmohan avatar Jun 09 '17 20:06 msmohan

Its what's mentioned in the orig post:

[LuisIntent("Help")]
public async Task showBotInformation(IDialogContext context, LuisResult result)
{
    var helpMsg = context.MakeMessage();
    var helpHeroCard = new HeroCard {
    Title = "Build Location",
        Buttons = new List<CardAction> {
            new CardAction(ActionTypes.OpenUrl , "\\\\DUMMY_SERVER\\" , value: "file:\\\\DUMMY_SERVER\\")
        }
    };
    helpMsg.Attachments.Add(helpHeroCard.ToAttachment());
    await context.PostAsync(helpMsg);
}

meganlcooper avatar Jun 09 '17 21:06 meganlcooper

@msmohan Any idea how I can accomplish this? Thanks for the help.

meganlcooper avatar Jun 12 '17 16:06 meganlcooper

@meganlcooper can you share your code in GitHub or Onedrive?

msmohan avatar Jun 12 '17 16:06 msmohan

@meganlcooper can you please explain on "DUMMY_SERVER" ? is it your local pc? or network share?

msmohan avatar Jun 12 '17 16:06 msmohan

@msmohan Sorry, it is network share. Also I added context for the var helpMsg. An example of the format for the server link would be file:\//mynetwork-example/

meganlcooper avatar Jun 12 '17 16:06 meganlcooper

@meganlcooper

You can host the file in local webserver instead. Using ActionTypes.OpenUrl or DownloadFile, update your code as shown below

Buttons = new List { new CardAction(ActionTypes.DownloadFile, "Help File", value: "http://localhost/HelpFile.txt") }

Network share is not supported in this context.

msmohan avatar Jun 12 '17 16:06 msmohan

Do the ActionTypes.OpenUrl or DownloadFile support Data URL protocol? i.e. data:

ghost avatar Mar 14 '19 03:03 ghost