0
votes

I want to open a URL through "Action.OpenUrl" in an AdaptiveCard and addtionally provide an "OK" Status to the bot, so the waterfall dialog can continue as supposed.

Important to know is that I want to deploy the bot on azure for MS Teams. So my first try was to "Action.Submit" the "OK" To the bot and open the URL from code through the System.Diagnostics.Process.Start(url). But it doesn't work like that on Windows 10 anymore and throws a "Directory not found" exceptions. There are some solutions for that problem that I tried. for example this one "here! This worked for me on the local Emulator but when deployed in MS Teams it just didn't do anything at all. So now I'm back to thinking about a nested "Action.XXX" possibility in the AdaptiveCard JSON that allows me to open the URL via OpenUrl function and on the same time gives the bot a signal like Submit function does. Has anyone ever had such a problem?

"actions": [
    {
      "type": "Action.Submit",
      "title": "Alles OK",
      "data": {
        "msteams": {
          "type": "imBack",
          "value": "OK"
        }
      }
    },

That is the Action Button right now in the adaptive card for MS Teams It should trigger the "OK" Case in the c# Bot code seen below and simultaneously open the url which can be added to a "Action.OpenUrl" Button

if (stepContext.Result is string promptResult)
            {
                switch (promptResult)
                {
                    case "OK":
                        string url = CreateTicketResponses.CreateTicketLink(state.Summary, state.Description, state.Type);
                        System.Diagnostics.Process.Start(url);
                        //await stepContext.Context.SendActivityAsync(url);
                        state.Reset();
                        new DialogTurnResult(DialogTurnStatus.Complete);
                        return await stepContext.EndDialogAsync();

So as described above I want to get an adaptive card which opens the URL in a new browser tab (on any system that the user might have) and give the bot an indicator to End the dialog (EndDialogAsync()).

1
System.Diagnostics.Process.Start(url); - isn't this going to run on the server??stuartd
@derdax A button on an adaptive card can have only one action at a time. We cannot have a single button to perform "Action.Submit" and "Action.OpenURL" at once.Gousia Begum
So if the process runs on the server then it simply cannot "open the URL in a new browser tab (on any system that the user might have)"stuartd
I may be able to devise a workaround, but we need to know that you understand the problem with what you're trying to do. @stuartd told you that bot code will run on the server and your responses have not indicated that you understand the problem with this. The server is an entirely different machine from the machine your user is using. The user will be running a Teams client application on their own machine while the bot code is running on a server. If your bot runs a command that's meant to open a URL then it will try to open a URL on a computer that your user isn't using. Do you understand?Kyle Delaney

1 Answers

1
votes

I think you have two options here:

  1. You could gather data in the Adaptive Card and have the bot respond to the submit action by sending another card (not necessarily Adaptive) with a button that opens a URL that's populated with the data from the Adaptive Card.
  2. You could skip the Adaptive Card and just send a generic URL button card that links to Jira, and then the user could fill out the data on the Jira page instead of having already filled it out in an Adaptive Card.

In either case, the bot won't know that the user has opened the URL. The user will have to enter something into the chat window when they want to continue the conversation. If you really want the bot to know when the user clicks the button then you'll have to set up a special web app that sends an activity to the bot and then redirects to your Jira page, which would be difficult/complicated.