private async Task imageReceived(IDialogContext context, Message message) { await context.PostAsync("**Yay!** You've sent me something special! (gift)"); var imageResult = await ImageAnalyzer.DescribeImage(message.Attachments[0].ContentUrl); var color = imageResult.Color.AccentColor; await context.PostAsync($@"I see {imageResult.Description.Captions[0].Text}."); await Task.Run(() => { var colorValueFrmHex = ColorTranslator.FromHtml("#" + color); AzureIoTHub.SendMessageAsync($"{(int)colorValueFrmHex.R},{(int)colorValueFrmHex.G},{(int)colorValueFrmHex.B}"); }); await context.PostAsync($@"Now look how I work my IoT magic using the accent color of this image... (holidayspirit)"); }
private async Task stopEmotionalAnalysis(IDialogContext context, Message message) { if (message.Text == "stop") { isRunning = false; await Task.Run(() => { AzureIoTHub.SendMessageAsync($"stop-track"); }); await context.PostAsync("I've stopped the emotion analysis process."); } else { await context.PostAsync($"I'm busy doing emotion analysis. (movie) Tell me when to **stop**."); context.Wait(messageReceived); } }
private async Task startEmotionalAnalysis(IDialogContext context, IAwaitable <bool> argument) { var confirm = await argument; if (confirm) { isRunning = true; await Task.Run(() => { AzureIoTHub.SendMessageAsync($"start-track"); }); await context.PostAsync("I've initiated the emotion analysis on the device and will send you the results in the form of emoji's soon. (brb)"); } else { await context.PostAsync("Okay, you're the boss! (y)"); } context.Wait(messageReceived); }