Introduction
LUIS.AI will help build the Language Understanding (LU) Model as per your requirements. For example, if a user asks a question or conveys the conversation with a Bot or IoT device, the questions will be treated as an input. For LUIS.AI will be treated as Utterances (User Inputs). The LUIS.AI Model takes questions or input text and provides Intents, extracts the text from Input, generates Entities and produces the JSON data.
Key Points
- 1000 Endpoint Hits only with a free subscription.
- LUIS bot isn't working because when you use all 1000 free endpoint queries or exceed your pricing tier's monthly transactions quota, you receive an HTTP 403 error status code.
- LUIS bot isn't working or you get 403 and 429 error status codes when you exceed the transactions per second or transactions per month for your pricing tier.
- The update command is only to rename the application name and description of the LUIS application.
- App ID is mandatory to save in log information(table row).
- After the creation of an application, we need to make the endpoint public (This option will be available in Application Information).
- We can't see endpoint hits in the app's Dashboard(LUIS.AI portal) If you want to check endpoint hits we need to migrate with azure services.
- Only 500 applications per Azure authoring resource will be supported.
- We can give collaborators access to our teammates by using Azure Active Directory or Role-based access control(RBAC).
Go
here and click on Sign-In.
Now give your Microsoft ID to log in.
Once you’re successfully logged in to your LUIS.AI, it will provide a note to migrate (link-up) the LUIS.AI cognitive services to your Azure resources. If you have your Azure subscription to link-up, you may proceed to click on the migrate button, or else you can click on the migrate later button.
Now the LUIS.AI home page will look like what is shown in the below figure.
Go to the bottom right, you’ll see Profile details, Go to Settings
In this section, you’ll get information about the region, Primary key, Endpoint Url, Pricing Details and Linked Azure Resources Information.
Our project flow is shown in the below screenshot:
Now it’s time to create a new project for LUIS.AI cognitive service's API.
Select ASP.Net Web Application using .Net Framework and click on the Next button.
Give a Valid Project Name and Location Path to save source files and Click on Create button.
Select MVC and click on the Create button.
The default MVC template will be created as shown in the below figure:
Here, I’m adding a local SQL database for maintaining all log information about the created LUIS.AI applications. The complete script will be available in the project file or GIT resource.
Go to the below link to learn more about cognitive services from
Microsoft.
LUIS Programmatic API’s 2.0
https://westus.dev.cognitive.microsoft.com/docs/services/5890b47c39e2bb17b84a55ff/operations/5890b47c39e2bb052c5b9c2f
Add one model for LUIS Endpoint location as shown in the below figure.
Global_Records class created log information for each and every transaction done by the user.
DBHelper.cs file created for database operations and code shown in the below figure.
EndPointLocationsController created endpoint log information without using luis.ai API and maintaining it in our database.
LUISAppMaster.cs class created to maintain the LUIS application entities model. To access this file, download the solution file and go-to models.
LUISAppMasterController.cs controller created for CRUD action methods for LUIS Applications.
Our design should be shown in the below figure:
For the above design, we require information about prebuilt LUIS.AI cultures, Token Version, Usage Scenario, Domain Name, EndPoint ID
Based on the selected cultures, a tokenizer version number will be generated (In our developer language cascading dropdown list with selected culture).
Database Script
- CREATE TABLE [dbo].[LuisEndPointLocations] (
- [LID] INT IDENTITY (1, 1) NOT NULL,
- [LEndPoint] NVARCHAR (MAX) NULL,
- [LEndPointUrl] NVARCHAR (MAX) NULL,
- [LEndPointCode] NVARCHAR (MAX) NULL,
- [Record_Type] CHAR (1) NULL,
- [InsertedDate] DATETIME NULL,
- [DeletedDate] DATETIME NULL,
- [UpdatedDate] DATETIME NULL,
- [IPAddress] NVARCHAR (MAX) NULL,
- PRIMARY KEY CLUSTERED ([LID] ASC)
- );
- Go
- CREATE TABLE [dbo].[LUISAppMaster] (
- [AID] INT IDENTITY (1, 1) NOT NULL,
- [AName] NVARCHAR (MAX) NULL,
- [ADescription] NVARCHAR (MAX) NULL,
- [ACulture] NVARCHAR (MAX) NULL,
- [AtokenizerVersion] NVARCHAR (MAX) NULL,
- [AUsageScenario] NVARCHAR (MAX) NULL,
- [Adomain] NVARCHAR (MAX) NULL,
- [AinitialVersionId] NVARCHAR (MAX) NULL,
- [AppID] NVARCHAR (MAX) NULL,
- [EndPointID] INT NULL,
- [Record_Type] NVARCHAR (MAX) NULL,
- [InsertedDate] DATETIME NULL,
- [DeletedDate] DATETIME NULL,
- [UpdatedDate] DATETIME NULL,
- [IPAddress] NVARCHAR (MAX) NULL,
- PRIMARY KEY CLUSTERED ([AID] ASC),
- FOREIGN KEY ([EndPointID]) REFERENCES [dbo].[LuisEndPointLocations] ([LID])
- );
- Go
- /*
- Exec LocationEndpoint_CRUD '{
- "LID": 1,
- "Flag": "R",
- "Record_Type": "N",
- "InsertedDate": "12/2/2019 1:19:29 AM"
- }'
- Exec LocationEndpoint_CRUD '{ "Flag": "R", "LEndPoint": "ManiTeja", "LEndPointUrl": "Maniteja Vegi", "LEndPointCode": "VMT", "LID":"2"}'
- */
- CREATE Proc LocationEndpoint_CRUD
- (
- @json nvarchar(max)
- )
- as
- BEgin
- Declare @Flag char(1);
- Declare @LID int;
- Set @Flag = JSON_VALUE(@json,'$.Flag') ;
- Set @LID = JSON_VALUE(@json,'$.LID') ;
-
-
- IF @Flag = 'I'
- BEGIN
- BEGIN TRY
- BEGIN TRANSACTION
- INSERT INTO LuisEndPointLocations Select * from OPENJSON(@json) with (
- LEndPoint nvarchar(max)
- ,LEndPointUrl nvarchar(max)
- ,LEndPointCode nvarchar(max)
- ,Record_Type char(1)
- ,InsertedDate datetime
- ,DeletedDate datetime
- ,UpdatedDate datetime
- ,IPAddress nvarchar(max)
- );
- COMMIT TRANSACTION
- Select '0' as ErrorCode,'Data Saved Successfully' as ErrorMessage FOR JSON PATH
- END TRY
- BEGIN CATCH
- ROLLBACK TRANSACTION
- SELECT
- ERROR_NUMBER() AS ErrorNumber
- ,ERROR_SEVERITY() AS ErrorSeverity
- ,ERROR_STATE() AS ErrorState
- ,ERROR_PROCEDURE() AS ErrorProcedure
- ,ERROR_LINE() AS ErrorLine
- ,ERROR_MESSAGE() AS ErrorMessage FOR JSON PATH;
- END CATCH
-
- END
- IF @Flag = 'U'
- BEGIN
- BEGIN TRY
- BEGIN TRANSACTION
- update LuisEndPointLocations
- Set
- LEndPoint = JSON_VALUE(@json,'$.LEndPoint')
- ,LEndPointUrl = JSON_VALUE(@json,'$.LEndPointUrl')
- ,LEndPointCode = JSON_VALUE(@json,'$.LEndPointCode')
- ,Record_Type = JSON_VALUE(@json,'$.Record_Type')
- ,UpdatedDate = JSON_VALUE(@json,'$.UpdatedDate')
- ,IPAddress = JSON_VALUE(@json,'$.IPAddress')
- where LID = JSON_VALUE(@json,'$.LID') ;
- COMMIT TRANSACTION
- Select '0' as ErrorNumber,'Data Updated Successfully' as ErrorMessage FOR JSON PATH
- END TRY
- BEGIN CATCH
- ROLLBACK TRANSACTION
- SELECT
- ERROR_NUMBER() AS ErrorNumber
- ,ERROR_SEVERITY() AS ErrorSeverity
- ,ERROR_STATE() AS ErrorState
- ,ERROR_PROCEDURE() AS ErrorProcedure
- ,ERROR_LINE() AS ErrorLine
- ,ERROR_MESSAGE() AS ErrorMessage FOR JSON PATH;
-
- END CATCH
- END
- IF @Flag = 'D'
- BEGIN
- BEGIN TRY
- BEGIN TRANSACTION
- Update LuisEndPointLocations
- set Record_Type = JSON_VALUE(@json,'$.Record_Type') ,
- DeletedDate = JSON_VALUE(@json,'$.DeletedDate')
- where LID = JSON_VALUE(@json,'$.LID') ;
- COMMIT TRANSACTION
- Select '0' as ErrorNumber,'Data Deleted Successfully' as ErrorMessage FOR JSON PATH
- END TRY
- BEGIN CATCH
- ROLLBACK TRANSACTION
- END CATCH
- END
- IF @Flag = 'R'
- BEGIN
- IF @LID = 0
- BEGIN
- Select * from LuisEndPointLocations where Record_Type = 'L' for JSON PATH
- END
- ELSE
- BEGIN
- Select * from LuisEndPointLocations where LID = JSON_VALUE(@json,'$.LID') for JSON PATH
- END
- END
- end
-
- Go
- /*
- Exec LUISAppMaster_CRUD '{
- "AName": "Test",
- "ADescription": "test",
- "ACulture": "en-us",
- "AtokenizerVersion": "1.0.0",
- "AUsageScenario": "IoT",
- "Adomain": "Booking & Reference",
- "AinitialVersionId": "1",
- "EndPointID": 1,
- "AppID": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
- "Flag": "I",
- "Record_Type": "L",
- "InsertedDate": "12/1/2019 5:35:20 PM"
- }'
- */
- CREATE Proc LUISAppMaster_CRUD
- (
- @json nvarchar(max)
- )
- as
- BEgin
- Declare @Flag char(1);
- Declare @AID int;
- Set @Flag = JSON_VALUE(@json,'$.Flag') ;
- Set @AID = JSON_VALUE(@json,'$.AID') ;
-
-
- IF @Flag = 'I'
- BEGIN
- BEGIN TRY
- BEGIN TRANSACTION
- INSERT INTO LUISAppMaster Select * from OPENJSON(@json) with (
- AName nvarchar(max)
- ,ADescription nvarchar(max)
- ,ACulture nvarchar(max)
- ,AtokenizerVersion nvarchar(max)
- ,AUsageScenario nvarchar(max)
- ,Adomain nvarchar(max)
- ,AinitialVersionId nvarchar(max)
- ,AppID nvarchar(max)
- ,EndPointID int
- ,Record_Type nvarchar(max)
- ,InsertedDate datetime
- ,DeletedDate datetime
- ,UpdatedDate datetime
- ,IPAddress nvarchar(max)
- );
- Select '0' as ErrorNumber,'Data Saved Successfully' as ErrorMessage FOR JSON PATH
- COMMIT TRANSACTION
- END TRY
- BEGIN CATCH
- ROLLBACK TRANSACTION
- SELECT
- ERROR_NUMBER() AS ErrorNumber
- ,ERROR_SEVERITY() AS ErrorSeverity
- ,ERROR_STATE() AS ErrorState
- ,ERROR_PROCEDURE() AS ErrorProcedure
- ,ERROR_LINE() AS ErrorLine
- ,ERROR_MESSAGE() AS ErrorMessage FOR JSON PATH;
- END CATCH
- END
- IF @Flag = 'U'
- BEGIN
- BEGIN TRY
- BEGIN TRANSACTION
- update LUISAppMaster
- Set
- AName = JSON_VALUE(@json,'$.AName')
- ,ADescription = JSON_VALUE(@json,'$.ADescription')
- ,Record_Type = JSON_VALUE(@json,'$.Record_Type')
- ,UpdatedDate = JSON_VALUE(@json,'$.UpdatedDate')
- ,IPAddress = JSON_VALUE(@json,'$.IPAddress')
- where AID = JSON_VALUE(@json,'$.AID') ;
- Select '0' as ErrorNumber,'Data Updated Successfully' as ErrorMessage FOR JSON PATH
- COMMIT TRANSACTION
- END TRY
- BEGIN CATCH
- ROLLBACK TRANSACTION
- SELECT
- ERROR_NUMBER() AS ErrorNumber
- ,ERROR_SEVERITY() AS ErrorSeverity
- ,ERROR_STATE() AS ErrorState
- ,ERROR_PROCEDURE() AS ErrorProcedure
- ,ERROR_LINE() AS ErrorLine
- ,ERROR_MESSAGE() AS ErrorMessage FOR JSON PATH;
- END CATCH
- END
- IF @Flag = 'D'
- BEGIN
- BEGIN TRY
- BEGIN TRANSACTION
- Update LUISAppMaster
- set Record_Type = JSON_VALUE(@json,'$.Record_Type') ,
- DeletedDate = JSON_VALUE(@json,'$.DeletedDate')
- where AID = JSON_VALUE(@json,'$.AID') ;
- Select '0' as ErrorNumber,'Data Deleted Successfully' as ErrorMessage FOR JSON PATH
- COMMIT TRANSACTION
- END TRY
- BEGIN CATCH
- ROLLBACK TRANSACTION
- SELECT
- ERROR_NUMBER() AS ErrorNumber
- ,ERROR_SEVERITY() AS ErrorSeverity
- ,ERROR_STATE() AS ErrorState
- ,ERROR_PROCEDURE() AS ErrorProcedure
- ,ERROR_LINE() AS ErrorLine
- ,ERROR_MESSAGE() AS ErrorMessage FOR JSON PATH;
- END CATCH
- END
- IF @Flag = 'R'
- BEGIN
- IF @AID != 0
- BEGIN
- Select * from LUISAppMaster where AID = JSON_VALUE(@json,'$.AID') for JSON PATH
- END
- ELSE
- BEGIN
- Select * from LUISAppMaster where AID = 'L' for JSON PATH
- END
- END
- end
Our LUIS.AI project is done. If you want to check the output, you need to download the source code and replace the Primary key (Authoring Key) from th LUIS.AI portal, run DB Script into your database, and run the application.
Happy Coding...
![]()