public async Task MessageReceivedAsync(IDialogContext context, IAwaitable <Message> argument)
        {
            var message = await argument;
            await context.PostAsync("I am looking for an answer to: " + message.Text);

            var service      = new StackOverflowService();
            var searchResult = await service.ExecuteSearch(message.Text);

            if (searchResult.Items != null && searchResult.Items.Length > 0)
            {
                await context.PostAsync("I found " + searchResult.Items.Length + " answers. Here is the first: ");

                await context.PostAsync(searchResult.Items[0].title);

                await context.PostAsync("More info: " + searchResult.Items[0].link);
            }
            else
            {
                await context.PostAsync("Sorry, but I could not find an answer. Can you ask in a different way?");
            }

            context.Wait(MessageReceivedAsync);
        }
Example #2
0
 public StackOverflowController(StackOverflowService stackService)
 {
     this.stackService = stackService;
 }