static async Task MainAsync() { var key = ConfigurationManager.AppSettings["BotKey"]; NotificationSender notificationSender = new NotificationSender(key); IList <Party> partiesToNotify = new List <Party>(); var party = PartyManager.GetParties()[0]; partiesToNotify.Add(party); Console.WriteLine("Write Notification. Your Message, High|Normal|Low"); Console.Write("> "); var messageLine = Console.ReadLine(); var message = messageLine.Split(','); while (message[0].ToLower() != "stop") { Log($"Sending notification {message[0]}"); Microsoft.Bot.Connector.DirectLine.ResourceResponse resourceResponse = await notificationSender.NotifyAsync(partiesToNotify, $"{message[0]}", message[1].ToLower().Trim()); Log($"{((resourceResponse == null) ? "Received no response" : $"Received resource response with ID {resourceResponse.Id}")}"); Console.Write("> "); messageLine = Console.ReadLine(); message = messageLine.Split(','); #if DEBUG // The following will dump the activity info into Output (console) Microsoft.Bot.Connector.DirectLine.Activity activity = await notificationSender.GetLatestReplyAsync(); #endif }
static async Task MainAsync() { NotificationSender notificationSender = new NotificationSender("INSERT YOUR DIRECT LINE SECRET HERE"); IList <Party> partiesToNotify = new List <Party>(); /* * You can set the parties to notify here. In order to do that you need to access the * database of users collected by the bot somehow. You could also send a backchannel * message to the bot asking for suitable parties. However, that is not the point of * this sample so I will leave the implementation to you. */ for (int i = 0; i < NumberOfNotificationsToSend; ++i) { Log($"Sending notification {(i + 1)}/{NumberOfNotificationsToSend}..."); Microsoft.Bot.Connector.DirectLine.ResourceResponse resourceResponse = await notificationSender.NotifyAsync(partiesToNotify, $"Notification test {(i + 1)}"); Log($"{((resourceResponse == null) ? "Received no response" : $"Received resource response with ID {resourceResponse.Id}")}"); #if DEBUG // The following will dump the activity info into Output (console) Microsoft.Bot.Connector.DirectLine.Activity activity = await notificationSender.GetLatestReplyAsync(); #endif Thread.Sleep(3000); }