1

I am looking to open a task module (Pop up - iframe with audio/video) in my bot that is connected to Teams channel. I am having issues following the sample code provided on the GitHub page.

I have tried to follow the sample and incorporate to my code by did not succeed.

In my bot.cs file I am creating card action of invoke type:

card.Buttons.Add(new CardAction("invoke", TaskModuleUIConstants.YouTube.ButtonTitle, null,null,null,
                new Teams.Samples.TaskModule.Web.Models.BotFrameworkCardValue<string>()
                {
                    Data = TaskModuleUIConstants.YouTube.Id
                }));

In my BotController.cs that inherits from Controller

   [HttpPost]
        public async Task PostAsync()
        {
            // Delegate the processing of the HTTP POST to the adapter.
            // The adapter will invoke the bot.
           await _adapter.ProcessAsync(Request, Response, _bot);        

        }

        public async Task<HttpResponseMessage> Post([FromBody] Activity activity)
        {
           if (activity.Type == ActivityTypes.Invoke)
            {
                return HandleInvokeMessages(activity);
            }

            return new HttpResponseMessage(HttpStatusCode.Accepted);
        }

        private  HttpResponseMessage HandleInvokeMessages (Activity activity)
        {

            var activityValue = activity.Value.ToString();
            if (activity.Name == "task/fetch")
            {
                var action = Newtonsoft.Json.JsonConvert.DeserializeObject<Teams.Samples.TaskModule.Web.Models.BotFrameworkCardValue<string>>(activityValue);

                Teams.Samples.TaskModule.Web.Models.TaskInfo taskInfo = GetTaskInfo(action.Data);
                Teams.Samples.TaskModule.Web.Models.TaskEnvelope taskEnvelope = new Teams.Samples.TaskModule.Web.Models.TaskEnvelope
                {
                    Task = new Teams.Samples.TaskModule.Web.Models.Task()
                    {
                        Type = Teams.Samples.TaskModule.Web.Models.TaskType.Continue,
                        TaskInfo = taskInfo
                    }
                };
                return msg;
            }

            return new HttpResponseMessage(HttpStatusCode.Accepted);
        }

There is more code as per the GitHub sample but I won't paste it here. Can someone point me into the correct direction ?

I have got to the stage that it is displaying a pop up window but the content and title comes from manifest file instead of creating actual iframe also no video is rendering. My goal is to render video within my teams using iframe container. enter image description here

Rikardo
  • 79
  • 1
  • 10
  • Could you please confirm if you have added [this line](https://github.com/OfficeDev/microsoft-teams-sample-task-module-csharp/blob/master/Microsoft.Teams.Samples.TaskModule.Web/App_Start/WebApiConfig.cs#L38) from the sample code? – Gousia Begum Jul 26 '19 at 11:45
  • @Gousia-MSFT I don't have this file in. Should I just create it and add at the top level of the project ? – Rikardo Jul 29 '19 at 08:12
  • Yes please try adding it and let me know if that resolves your issue. – Gousia Begum Jul 29 '19 at 08:51
  • Were you able to solve this? – Gousia Begum Aug 07 '19 at 12:27
  • Hi, I have added the mentioned code but no luck. I am getting number of errors: `The name 'Scripts' does not exist in the current context` `The name 'Styles' does not exist in the current context ` – Rikardo Aug 07 '19 at 14:43
  • I am also getting error on the HandleInvokeMessages method in the BotController.Cs class `'HttpRequest' does not contain a definition for 'CreateResponse' and the best extension method overload 'HttpRequestMessageExtensions.CreateResponse(HttpRequestMessage, HttpStatusCode, TaskEnvelope)' requires a receiver of type 'HttpRequestMessage'` – Rikardo Aug 07 '19 at 14:51

1 Answers1

0

The important part from the sample:

This sample is deployed on Microsoft Azure and you can try it yourself by uploading Task Module CSharp.zip to one of your teams and/or as a personal app. (Sideloading must be enabled for your tenant; see step 6 here.) The app is running on the free Azure tier, so it may take a while to load if you haven't used it recently and it goes back to sleep quickly if it's not being used, but once it's loaded it's pretty snappy.

So,

  1. Your Teams Admin MUST enable sideloading
  2. Your bot MUST be sideloaded into Teams

The easiest way to do this would be download the sample manifest, open it in App Studio, then edit your bot information in. You then need to make sure Domains and permissions > Valid Domains are set for your bot. Also ensure you change the Tabs URLs to your own.

You also need to make sure that in your Tasks, the URLs they call ALL use https and not http. If anywhere in the chain is using http (like if you're using ngrok and http://localhost), it won't work.

mdrichardson
  • 7,141
  • 1
  • 7
  • 21
  • Teams sideloading is enabled. Manifest file is corrected along with Valid Domains added. All use Https. Is there no easier way of displaying just a single pop up with iframe object after button click ? Thank you – Rikardo Jul 29 '19 at 08:14
  • @Rikardo Are you able to share your full code? That might make it easier to troubleshoot. And I'm afraid this is the only way to pop up an iframe that I know of. The alternative would be to open a link in the browser. – mdrichardson Jul 29 '19 at 15:01
  • I can't share the full code. I have seen that your example uses ASP.NET httpResponseMessage that returns taskEnvelope. It seems like my code never reaches this method as my bot is running on the .Net Core 2.1. Anyway I can replicate to my `PostAsync` method? – Rikardo Aug 09 '19 at 05:21
  • 1
    @Rikardo I'm afraid I'm not well-versed enough in C# or that sample to provide a good answer. I'd suggest [opening an issue in that repo](https://github.com/OfficeDev/microsoft-teams-sample-task-module-csharp/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc) – mdrichardson Aug 09 '19 at 15:30