Microsoft Bot Framework Proactive Dialog No Facebook Notification - c#

I have used the Microsoft Bot Framework Proactive Message samples which are great but I have one issue.
In the simple message example (https://github.com/Microsoft/BotBuilder-Samples/tree/master/CSharp/core-proactiveMessages/simpleSendMessage) the messages send but in Facebook Messenger I don't get a notification on my phone. However, adding in this simple bit of code fixes that perfectly:
message.ChannelData = JObject.FromObject(new { notification_type = "REGULAR" });
I'm now using the Start New Dialog example (https://github.com/Microsoft/BotBuilder-Samples/tree/master/CSharp/core-proactiveMessages/startNewDialog) and want to do the same thing but the dialog messages do not cause a notification. I've tried setting the notification_type in as above in various places in my code but nothing seems to work.
Any help / pointers would be greatly appreciated.
Thanks
Stu

I've found the notifications work just fine without any code changes to the Start New Dialog example sample since making my Messenger Bot Public. I don't understand why some notifications work / don't work when the bot is not public.

Related

Bot can handle request from Skype desktop app, but not from Skype store app

I have written a small chat bot using the MS bot framework. I added the Skype and Web channels, and host the bot on Azure with the smallest pay-as-you-go plan. The bot itself is working nicely, both through the web chat and in Skype conversations, both directly (1on1 chat) as well as in groups, when I'm using the Skype desktop app.
Unfortunately, when using the Skype app installed from the Microsoft store, nothing works anymore... Sending a message to the bot (in direct chats and groups) always produces HTTP 500 responses from my bot. Digging into it a bit releaved a simple NullReferenceException being thrown, apparently in the very first line in my dialog handler (see below): The call stack pointed at this line, but the error happened later, see below:
namespace MyBot.Dialogs {
[Serializable]
public class RootDialog: IDialog<IMessageActivity> {
public Task StartAsync(IDialogContext context) {
context.Wait(MessageReceivedAsync);
return Task.CompletedTask;
}
private async Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> result) {
// call stack pointed to next line
Activity activity = await result as Activity;
//... some unproblematic stuff
string username = activity.From.Name;
// the next line was the actual problem:
if(username.Contains(" "))
//...
}
}
}
This part of the code, as well as the full MessagesController are taken without changed from the bot framework examples, and as mentioned before, the bot is working fine from web chat and the "regular" Skype desktop app. Even in a group chat with some users on the desktop app and some on the store app, the users with the desktop app can interact with the bot as expected, while the store app users only trigger errors.
The obvious questions here are of course: how (and why) do the two Skype apps differ from a bot perspective, and how can I handle this?
Edit: As it turns out, the Skype desktop app sets the activity.From.Name property to the user's name, while the Skype store app does not. The mean part is, the channelid's for both are the same ("skype", obviously).
Thanks to the comment of #EricDahlvang, I noticed that the error was not the line mentioned above at first, despite the call stack specifically giving this line number. The error happened later, when I tried to work with "activity.From.Name". As it turns out, the regular Skype sets this property to match the users display name, while the Skype store app does not, and returns null.

Connecting a MS bot framework user to someone on Skype

I've made a chat bot using Microsoft Bot Framework which answers a user's questions. When the bot is unable to answer the user's questions, I want to be able to redirect the user question to a customer rep on Skype.
The person on Skype will see the messages posted by the user, and his answers will be sent to the user.
I need some advice on how to achieve this connection (from user<->chatbot<->SkypecustomerRep)
Edit:
I'm toying with the idea of using the commands in http://docs.botframework.com/connector/new-conversations/#navtitle
I figured when the LuisIntent would turn out to be None, I'd message a skype id with:
var connector = new ConnectorClient();
var message = new Message
{
From = new ChannelAccount(channelId: ""),
To = new ChannelAccount() {ChannelId = "Skype", Address = "xyz#abc.com"},
Text = result.Query,
Language = "en"
};
where the email is the Skype id. I'm not able to figure out what should be in the From field (what's the channelId, Address of my bot)
EDIT:
I'm able to pass one message to Skype now, but when the Skype user replies, I observe that the reply is not immediately presented to the bot framework user. In other words, when the user types something into the chat window, he gets a response from the bot (as expected) and the skype user's delayed message.
If you want the customer support representative to have sufficient context (i.e. see more than just the most recent text posted by the user) you are going to need to build your own customer support interface to both record conversations as well as highlight those that need attention from a human. Usually folks do this building their own client with DirectLine or connecting up their existing customer support client (also with DirectLine). The bot then directly passes the support reps replies back to the end users.
Some additional detail can be seen in this previous answer.

Windows 10 Feedback Task for my App

Similar to this question which invokes the Windows 10 store to allow a user to write a review or rate an app, I'd also like to be able to invoke the Windows 10 Feedback app and allow users to provide feedback there.
I cannot seem to find much information on:
How this works in general. Can any old app use this service? (I
notice it just kind of shows whatever apps I have running)
How to invoke the Windows Feedback app with my package id
In short - not that I can see.
Other apps are invoked via protocol activation. I haven't seen this documented for the feedback app though so I have to err on the side of 'we haven't made this available yet' (I'm still checking though)
Here's an overall guide to the process http://blog.jerrynixon.com/2012/10/walkthrough-using-windows-8-custom.html?m=1
When I look in the registry under HKEY_CLASSES_ROOT\Extensions\ContractId\Windows.Protocol I see (shortened a tad)
[HKEY_CLASSES_ROOT\Extensions\ContractId\Windows.Protocol\PackageId\Microsoft.WindowsFeedback...\ActivatableClassId\App.AppX7eaybq6p4x7d4jgd6w6jk7r5dg6yhmbf.mca\CustomProperties]
"Name"="windows-feedback"
So - give that a try via launching windows-feedback
If I do Windows Key-R (run): windows-feedback://
it works fine so this should work:
var uri = new Uri(#"windows-feedback://");
var success = await Windows.System.Launcher.LaunchUriAsync(uri);
if (success)
{
// URI launched
}
else
{
// URI launch failed
}
Update
I've done some searching and it seems the magic parameter there is
windows-feedback:?contextid=522
That launches the NFL feedback for example. This is a predetermined number - I'm not sure how one gets on this list though.

Hiding the Toast Notification when a push notification is received

I am using Windows azure push notifications. Every time a new notification is received a Toast is displayed with the information received, is there anyway I can disable this feature programmatically? The reason I want this is because I am trying to develop a FPS game and I am using the Push notifications to update locations, for obvious reasons I don't want the data received to get displayed.
You can hide the toast notification by setting the expiration time of the ToastNotification to DateTime.Now, that way it would expire as soon as it is displayed. You can do that by using the PushNotificationReceivedEventArgs args that is passed.
args.ToastNotification.ExpirationTime = DateTime.Now;
A better solution as provided by Gaurav is to use
args.Cancel=true;
What you could do is consume the PushNotificationReceived event and then handle it there. I did the same for one sample chat application I built. Look for the code for app.xaml.cs in my blog post here: http://gauravmantri.com/2012/08/30/how-i-built-an-awesome-chat-application-for-windows-8-with-windows-azure-mobile-service/.

Jabber-net integration

I'd like to ask your help regarding having a Google Talk Bot that will communicate with my code on my server.
I have downloaded Jabber-Net from code.google.com, but the examples there are not enough... I am new to these technologies, and have no clue about:
How will client arrive to my server? where should I change [if any] DNS to my server?
Which server side library should I use?
From the examples I understood that I need to have a Desktop-app running in the background constantly, which doesn't make sense to me.
Does anyone has an example of some better references to understand this better?
[Sorry for my ignorance...]
I'm not sure if I understand what you ask correctly. If you're asking how to connect to chosen server, console sample shows how to do it simply, you basically fill out JID class.
Sample from Jabber-Net
JabberClient jc = new JabberClient();
JID j = new JID(jid);
jc.User = j.User;
jc.Server = j.Server;
jc.NetworkHost = networkHost;
jc.Port = port;
jc.Resource = "Jabber.Net Console Client";
jc.Password = pass;
jc.AutoStartTLS = TLS;
jc.AutoPresence = initialPresence;
If you want to create your own server, there's a library (also running under .NET) called agsxmpp, it allows to create both, server and client, it's open source on MIT/GPL license afair. I don't know if jabber-net enables this feature. On the other hand, there are plenty of free jabber-server if you don't want to just use one of "public" ones, so it may be worth to consider just using something that is ready to be launched.
There's a console sample in the project, you don't need desktop-app (if this is what you were asking?), so you can write service, console app or anything else.
Here's a recent post that shows an example of replying to incoming messages on Gtalk using .NET

Categories

Resources