private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result) { var activity = await result as Activity; var document = new SentimentDocument() { Id = "23", Text = activity.Text, Language = "en" }; var request = new SentimentRequest(); request.Documents.Add(document); var response = await _cognitiveClient.GetSentimentAsync(request); var retrivedDocument = response.Documents.FirstOrDefault(); var sentimentScore = retrivedDocument.Score; // calculate something for us to return int length = (activity.Text ?? string.Empty).Length; // return our reply to the user await context.PostAsync($"You sent {activity.Text} which was {length} characters"); context.Wait(MessageReceivedAsync); }
public async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> argument) { var message = await argument; var document = new SentimentDocument() { Id = "123", Text = message.Text, Language = "en" }; var request = new SentimentRequest(); request.Documents.Add(document); var response = await _cognitiveClient.GetSentimentAsync(request); var retrievedDocument = response.Documents.FirstOrDefault(); var sentimentScore = retrievedDocument.Score; await context.PostAsync(message.From.Name + " sentiment for your sentence is: " + sentimentScore + "%"); context.Wait(MessageReceivedAsync); }