Is the MS Teams bot framework / botkit able to disable typing indicator? - botframework

Is the MS Teams Bot Framework or botkit support a function to disable a typing indicator?
What I know that if want to start typing indicator then can use below format with value type is typing but how can I disabled the typing indicator once it start. Sometimes has case that typing indicator take long time to hide after bot response the answer.
var data = {
'type':'typing',
conversation:
{
id: <channel>
}
};

Hi Muhammad Aiman Azizan,
As of now we cannot disable the typing indicator but you can raise your idea/voice in the link below,
https://microsoftteams.uservoice.com/forums/555103-public/filters/new

Related

Switching manually between tabs in personal msteams application

I have two tabs in my personal msteams application and I would like to navigate between them dynamically. Is it possible? I've tried to use microsoftTeams.getTabInstances method from msteams SDK to get my tabs and after that navigate to the chosen tab by invoking microsoftTeams.navigateToTab but this approach doesn't work - I get null from microsoftTeams.getTabInstances. My user is logged in (I've read somewhere that user must be logged in).
I've not tried exactly this action, but I believe you should be able to do what you're trying using Deep Links. In particular, see the Deep linking from your tab where it talks about
This is useful if your tab needs to link to [...] another tab [...]
and the syntax is
microsoftTeams.executeDeepLink(/*deepLink*/);
Just a reminder that in deep link syntax, e.g. https://teams.microsoft.com/l/entity/<appId>/<entityId>, the appid is your Teams app id, and the "entityId" must match the "entityId" for your tab in your Teams manifest file.
You can deeplink to content in Teams from your tab. This is useful if your tab needs to link to other content in Teams such as to a channel, message, another tab or even to open a scheduling dialog. To trigger a deeplink from your tab you should call:
var encodedWebUrl = encodeURI('https://tasklist.example.com/123/456&label=Task 456');
var encodedContext = encodeURI('{"subEntityId": "task456"}');
var taskItemUrl = 'https://teams.microsoft.com/l/entity/fe4a8eba-2a31-4737-8e33-e5fae6fee194/tasklist123?webUrl=' + encodedWebUrl + '&context=' + encodedContext;
Please take a look Deep Link to your tab

Customizing Adaptive Card appearance using RenderedAdaptiveCards inside bot framework SDK

I am developing a Bot using Microsoft Bot Framework. I am using Adaptive Cards for displaying flights to users but they have a lot of limitations on their appearance. I am trying to render the adaptive card from one of the dialogs within my bot framework by creating a adaptive card renderer using my own hostconfig.json and then attaching the Html of my adaptive card back to the chat window. But its not working :(
public static Attachment CreateFlight(Flight flight)
{
var renderedAdaptiveCard = AdaptiveCardRenderer
.RenderCard(new AdaptiveCard
{
Body = new List<AdaptiveElement>
{
new AdaptiveContainer {Items = CreateFlightAdaptiveElements(flight)}
},
Actions = new List<AdaptiveAction>
{
new AdaptiveShowCardAction
{
Card = new AdaptiveCard
{
Body = new List<AdaptiveElement>
{
},
Actions = new List<AdaptiveAction>
{
new AdaptiveSubmitAction
{
Title = "Select",
Data = flight.Segments.Select(x => $"{x.Airline} {x.FlightNo}")
.Aggregate((i, j) => i + "/" + j),
}
},
BackgroundImage = new Uri($"{DomainUrl}/Images/ac_background.jpg")
},
Title = "Select"
},
},
BackgroundImage = new Uri($"{DomainUrl}/Images/ECEFF1.png")
});
var attachment = new Attachment
{
ContentType = "application/html",
Content = renderedAdaptiveCard.Html
};
return attachment;
}
Am I trying something that is impossible here ? How to change the default grey looks of my bot ? My primary channels would be Skype, Slack etc so I don't have plans to integrate this to a Web Chat. Kindly help me with this regard.
The idea behind Adaptive Cards is to allow each channel to render the cards in a way that's specific to that channel. A card "adapts" to any environment that might support it. While Adaptive Cards offer a lot of flexibility, the bot can only do so much because it's ultimately the channel that's in charge of rendering the card.
Card Authors describe their content as a simple JSON object. That
content can then be rendered natively inside a Host Application,
automatically adapting to the look and feel of the Host.
For example, Contoso Bot can author an Adaptive Card through the Bot
Framework, and when delivered to Skype, it will look and feel like a
Skype card. When that same payload is sent to Microsoft Teams, it will
look and feel like Microsoft Teams. As more host apps start to support
Adaptive Cards, that same payload will automatically light up inside
these applications, yet still feel entirely native to the app.
Users win because everything feels familiar. Host apps win because
they control the user experience. And Card Authors win because their
content gets broader reach without any additional work.
As you probably know, the RenderedAdaptiveCard type is meant to be used in client-side code. That means it can help you if you want to make your own channel for example, but it's not really meant to be used in a bot. Your code isn't working because there is no HTML attachment type and most channels don't support HTML at all. You can find more information in this question and this GitHub issue.
Hopefully you can achieve the appearance you're looking for using the tools available to you, such as images and links.

How to switch Dialogs in BotFramework SDK3 C#

I'm trying to add a timeout Dialog using proactiveMessages. If user doesn't reply to [A dialog], [timeout dialog] comes out. So I think timeout dialog should be the current dialog. But do I to close other dialog [A dialog]?
According this, it seems context.EndConversation was not working in MS Teams. Of course I have tried again. It is still not working.
I also tried the way below. But it seems not working either.
using (var scope = DialogModule.BeginLifetimeScope(Conversation.Container, context.Activity.AsMessageActivity()))
{
var botData = scope.Resolve<IBotData>();
await botData.LoadAsync(default(CancellationToken));
var stack = scope.Resolve<IDialogStack>();
stack.Reset();
await botData.FlushAsync(default(CancellationToken));
}
Any suggestions about changing the dialog?
There are two methods of redirecting dialog flow within a C# bot.
you can use context.Forward() to send a user to a new dialog starting with a message that you are currently processing:
await context.Forward(new NewOrderDialog(), this.ResumeAfterNewOrderDialog, message, CancellationToken.None);
or you can use context.call() to send a user to a new dialog and start from scratch there:
context.Call(new AgeDialog(this.name), this.AgeDialogResumeAfter);
The "ResumeAfter" functions can be defined anywhere (including a function within the new dialog itself) and setting these to where you would like to redirect the user after they have finished with your timeout dialog will allow you to determine the flow.

Using MS Teams as Channel: Authentification Dialog (GetTokenDialog class from Microsoft.Bot.Builder.Dialogs) doesn't popup

How can I use the new authentification feature in Bot Builder with MS Teams?
There seems to be an issue with Teams (see Login user with MS Teams bot or https://github.com/Microsoft/BotBuilder/issues/2104), seems if this is not considered in GetTokenDialog?
Is there any chance to get around this?
Just found the reason why it won't work with Teams. In method Microsoft.Bot.Connector.Activity.CreateOAuthReplyAsync(), Parameter asSignInCard has to be set to True for MSTeams, then, the line new CardAction() { Title = buttonLabel, Value = link, Type = ActionTypes.Signin } has to be changed to new CardAction() { Title = buttonLabel, Value = link, Type = ActionTypes.OpenUrl } because MS Teams can obviously not deal with Action type Signin. Hope, the MS developers will fix that method soon.
There are a few things you need to do to get this to work. First you need to create a manifest file for your bot in teams and whitelist token.botframework.com. That is the first problem.
From teams itself in AppStudio you create a Manifest. I had to play around with this a little bit. In AppDetails... Let it generate a new ID. Just hit the button. The URLs really don't matter much for testing. The package name just needs to be unique so something like com.ilonatag.teams.test
In the bots section you plug in your MS AppId and a bot name. This is a the real MSAPPID from your bots MicrosoftAppId" value=" from web.config in your code.
Ok now in "finish->valid domains" I added token.botframework.com and also the URL for my bot just in case. so something like franktest.azurewebsites.net
This part is done but you are not quite done... in your messages controller you need to add this since Teams sends a different verification than the other clients.
if (message.Type == ActivityTypes.Invoke)
{
// Send teams Invoke along to the Dialog stack
if (message.IsTeamsVerificationInvoke())
{
await Conversation.SendAsync(message, () => new Dialogs.RootDialog());
}
}
It took me a bunch of going back and forth with Microsoft to get this sorted out.
This is a known problem using OAuthCard in MS Teams. To solve it, you can change the Button ActionType from signIn to openUrl using this solution on github

How to get to the Messaging app to text someone?

I'm making an app and I want to be able to go from my app to the messaging app straight to the "Create new" page. Is there a way I can navigate to that page straight from my app?
As Andrew M mentioned, the SmsComposeTask is the correct control to use. Here is some sample code for you:
SmsComposeTask smsTask = new SmsComposeTask();
smsTask.To = "0123456789"; // the number you would like to send the sms to
smsTask.Body = "Some prefilled text..."; // if you would like to fill some text
smsTask.Show();
When Show() is called, the app will navigate to the Messaging application and display an SMS filled in with the defined parameters.
Simply use the above code in an event handler (i.e., the event for when a button is clicked), and the user will be navigated accordingly.
Use the SMSComposeTask:
http://www.nickharris.net/2010/09/how-to-sms-using-the-smscomposetask-for-windows-phone-7/

Resources