1

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()).

derdax
  • 11
  • 2
  • 1
    `System.Diagnostics.Process.Start(url);` - isn't this going to run on the server?? – stuartd Aug 22 '19 at 10:40
  • It is, but i'm getting the following error `The system cannot find the file specified` – derdax Aug 22 '19 at 10:48
  • 1
    @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 Aug 22 '19 at 10:50
  • 1
    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 Aug 22 '19 at 10:51
  • @stuartd yes, that's right. So I can't open the URL via the card button (because I need the confirmation for the bot from the submit action) and I can't open it from c# code because the options I tried don't work in MS Teams... – derdax Aug 22 '19 at 11:04
  • @Gousia-MSFT Okay, is there a way to solve my problem without performing both actions? – derdax Aug 22 '19 at 11:47
  • 1
    Possible duplicate of [How to message back in an OpenUrl Card Action?](https://stackoverflow.com/questions/57455089/how-to-message-back-in-an-openurl-card-action) – tdurnford Aug 22 '19 at 15:45
  • 1
    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 Aug 22 '19 at 18:09
  • 1
    Please refer to the documentation to gain a better understanding of how bots work: https://learn.microsoft.com/en-us/azure/bot-service/bot-service-overview-introduction – Kyle Delaney Aug 22 '19 at 18:14
  • @KyleDelaney Okay, I do understand now what he meant. What workaround do you have in mind? – derdax Aug 23 '19 at 07:19
  • Before getting into that, I want to make sure I understand what you're trying to do. It looks like the URL you're opening is meant to create a sort of support ticket or something. But the only thing the bot is doing when the URL opens is resetting the state and ending the dialog, i.e. it isn't sending anything to the user that continues the conversation. If that's the case, why not just end the dialog before opening the URL? I presume you're using a waterfall, so the Adaptive Card could be sent in the last step of the waterfall. The user could click the button and type a message to continue. – Kyle Delaney Aug 23 '19 at 18:13
  • Are you still working on this? – Kyle Delaney Aug 26 '19 at 21:33
  • Yes I am, and I tried the workaround that you suggested (ending the dialog and sending the card afterwards. this isnt ideal but works. Can you still describe the solution you had in mind? – derdax Aug 28 '19 at 08:34
  • What you want to do is combine `submit` with `openUrl` in a single button. Your idea was to use `submit` and then have the bot open the URL in response to the activity. That's impossible, so my idea is to use `openUrl` and have the URL send a message to the bot. This would be very complicated, so I still think you're better off just letting the user continue the conversation manually after opening the URL. – Kyle Delaney Aug 29 '19 at 22:31
  • Just to clear up some possible confusion... this URL that you're opening, is the user meant to interact with it? Are they meant to fill out a form to create the ticket and then close the page? Or is the user not supposed to see the URL because it handles the ticket creation automatically? You need to be very explicit about what you're trying to do here. – Kyle Delaney Aug 29 '19 at 22:33
  • Yes, that's right. And the URL is the JIRA Create Page which is pre-filled with the data the bot collected from the user. So the user has to sign in (if he isnt already) and create the ticket in the mask. So I don't think the url can send something back. But I get the idea and I'll have to make a "sign-in" dialog which will need to have something like that (open URL and send back a token to the bot) : ) Thank you for your help, sometimes it's just good to get a second thought and an alternative thinking of something :) – derdax Aug 30 '19 at 06:50
  • You said "Yes, that's right" but I asked multiple questions. It's an either/or. – Kyle Delaney Sep 04 '19 at 16:07
  • Is my answer acceptable? – Kyle Delaney Sep 09 '19 at 23:40

1 Answers1

1

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.

Kyle Delaney
  • 11,616
  • 6
  • 39
  • 66