다음을 통해 공유


Integrate Bot App with Cognitive Services LUIS, RESTful Services and Web APIs

 

This post walks through the steps you take to integrate Cognitive Services – LUIS and RESTful services and web service APIs. The idea is to use LUIS to get the intent from user activity, and then call a RESTful service or web service API (e.g. Yahoo Finance API or OpenWeatherMap API) to get data for the user. You can find the source code at GitHub.

Step 1 – Create a Cognitive Service API Account

Go to https://portal.azure.com, and follow the steps at “Create a Cognitive Services APIs account in the Azure Portal”. Make a copy of Key 1 under Resource Management. You will need the key when you publish your LUIS app at next step.

Step 2 – Create your LUIS app and Publish it

Go to https://www.luis.ai/applications to create a Cognitive Service LUIS app. Add intents, entities, train and test the app, and publish the app. Use the key you obtained at Step 1 when publishing the app. You can find more detail here.

image

Step 3 – Create a Bot App using Visual Studio

Follow the steps here.

Before Publishing your Bot Application to Microsoft Azure, test the app in the local bot framework emulator, which I discussed in a previous post.

Modify your Visual Studio project to integrate LUIS, and web service APIs.

a) Update values in the web.config file

b) Add model.cs, stockprice.cs and weatherservice.cs files

c) Update MessageController.cs file by adding three methods – GetIntentFromLUIS, GetStock and GetWeather and modifying the Post method as follows.

image

Test the app in the local bot framework emulator again. Fix any error. You should be able to test it with “show me msft stock” and “show me weather in Seattle”.

image

You can now publish the app to Azure. See more detail at the section, “Publishing your Bot Application to Microsoft Azure”.

Also, you can finish the remaining steps.

  • Testing the connection to your bot
  • Registering your Bot with the Microsoft Bot Framework
  • Configuring Channels

image