Introduction
In my previous article "Creating a Simple Bot Application using Microsoft Bot Framework", I explained how can we create a very simple Bot application using Microsoft Bot Framework.
In this article I will create a very simple real time Bot Application using Microsoft Bot Framework, that is Stock Bot. In this application I will use Yahoo's Finance API. I will pass a stock symbol as a message and I will get the current stock value of that particular company symbol.
In my previous article "Creating a Simple Bot Application using Microsoft Bot Framework", I explained how can we create a very simple Bot application using Microsoft Bot Framework.
In this article I will create a very simple real time Bot Application using Microsoft Bot Framework, that is Stock Bot. In this application I will use Yahoo's Finance API. I will pass a stock symbol as a message and I will get the current stock value of that particular company symbol.
Step 2: Create a class in your project with any name. I am giving Name as Yahoo Bot Application and writing the following code inside it.
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Threading.Tasks;
- using System.Web;
- namespace StockBot2
- {
- public class YahooBot
- {
- public static async Task<double?> GetStockRateAsync(string StockSymbol)
- {
- try
- {
- string ServiceURL = $"http://finance.yahoo.com/d/quotes.csv?s={StockSymbol}&f=sl1d1nd";
- string ResultInCSV;
- using (WebClient client = new WebClient())
- {
- ResultInCSV = await client.DownloadStringTaskAsync(ServiceURL).ConfigureAwait(false);
- }
- var FirstLine = ResultInCSV.Split('\n')[0];
- var Price = FirstLine.Split(',')[1];
- if (Price != null && Price.Length >= 0)
- {
- double result;
- if (double.TryParse(Price, out result))
- {
- return result;
- }
- }
- return null;
- }
- catch (WebException ex)
- {
- //handle your exception here
- throw ex;
- }
- }
- }
- }



Chirag MadhaniPosted Oct 25, 2017, 1:14 AM
I cann't find namespace "using Microsoft.Bot.Connector.Utilities;" and also, when i am trying to call webservice it is giving error of "webexception 403 forbidden" .
Vipin MauryaPosted Aug 17, 2017, 8:51 AM
I am new to bots. This application is not working for me. Can you help me
Prudhveer KankarPosted Jul 3, 2017, 5:06 AM
I tried to connect the same bot to the emulator,but it was not connecting, [14:15:34] -> POST getaddrinfo ENOTFOUND http http:443 It was showing this error in Log,what do i do now
vishal vermaPosted May 31, 2017, 1:30 AM
Nice one.It si really nice article.keep it up
Youssra BenchekrounPosted May 24, 2017, 11:13 AM
Thank you for your article. On my messageController , i have a problem with Message (it's not known )
Rijo PRPosted Aug 30, 2016, 12:57 AM
Is it possible to get the reply from this bot as voice commands rather than text reply?
Rijo PRPosted Aug 30, 2016, 12:56 AM
Nice one.
Radhakrishnan IyerPosted Aug 8, 2016, 3:35 AM
Great Article. Can you give a few pointers on how the summarize bot under the bot directory works?
Prasanna MuraliPosted Jun 24, 2016, 1:13 AM
Nice one...
Bhuvanesh MohankumarPosted May 3, 2016, 12:46 PM
Good one..
Debasis SahaPosted Apr 15, 2016, 12:31 AM
Nice article..
Bhavik PatelPosted Apr 14, 2016, 9:30 PM
good article.
Gowtham RajamanickamPosted Apr 14, 2016, 9:31 AM
nice sharing..
Kuppurasu NagarajPosted Apr 14, 2016, 9:16 AM
Nice Sharing..
Vignesh ManiPosted Apr 14, 2016, 8:08 AM
Nice
Rahul Kumar SaxenaPosted Apr 14, 2016, 6:21 AM
Good Show
Gowtham RajamanickamPosted Apr 14, 2016, 6:05 AM
nice article..
Nitesh KejriwalPosted Apr 14, 2016, 4:04 AM
Its outstanding Sourabh!
Shakti Singh DulawatPosted Apr 14, 2016, 3:10 AM
Read first time about it and impress with the work and explain