Botbuilder-samples: How to Make API Calls from Bot Framework

Created on 16 Sep 2019  路  3Comments  路  Source: microsoft/BotBuilder-Samples

@v-kydela @mdrichardson
Hi,

I'm looking for an example to build BOT for Customer Support scenarios where the BOT asks questions and responds calling API, as the user inputs.

For Example,
Customer : I need Order details
Bot: Can I have Order #
Customer : 1232134
BOT : calls api internaly and show information.
Customer: I need performance of the order
BOT: shares the link to view the performance.

Let me know if you have other suggestions for the given scenario.

Thanks
Arun

Bot Services customer-replied-to customer-reported question

Most helpful comment

Hi @arunprasathv! The bot framework team prefers that "how-to" questions are asked on Stack Overflow, tagged with the botframework tag

That being said, there should be no reason you cannot make a standard API call, as illustrated by @Edwardenis. I would recommend making sure you're making the methods asynchronous, so you aren't blocked by slower-than-expected responses.

All 3 comments

If you are using C# on the step that received the order # you should have something like:

c# var orderNum = "the order #"; using (var client = new HttpClient()) { var response = await client.GetAsync($"Your API Endpoint?orderNum={orderNum}"); if (response.IsSuccessStatusCode) { var json = await response.Content.ReadAsStringAsync(); //Geneate the message you want to display to the users using this json } else { //Do something in case the resource is not found or another error occurred } }

Hi @arunprasathv! The bot framework team prefers that "how-to" questions are asked on Stack Overflow, tagged with the botframework tag

That being said, there should be no reason you cannot make a standard API call, as illustrated by @Edwardenis. I would recommend making sure you're making the methods asynchronous, so you aren't blocked by slower-than-expected responses.

I did post in Stackoverflow but no response, then I decided to post it here. Any sample from github that matches my ask would be great. I started looking into bot framework examples. Thanks.

Was this page helpful?
0 / 5 - 0 ratings