Alter utterance data before or during prediction

Important

LUIS will be retired on October 1st 2025 and starting April 1st 2023 you will not be able to create new LUIS resources. We recommend migrating your LUIS applications to conversational language understanding to benefit from continued product support and multilingual capabilities.

LUIS provides ways to manipulate the utterance before or during the prediction. These include fixing timezone issues for prebuilt datetimeV2.

Change time zone of prebuilt datetimeV2 entity

When a LUIS app uses the prebuilt datetimeV2 entity, a datetime value can be returned in the prediction response. The timezone of the request is used to determine the correct datetime to return. If the request is coming from a bot or another centralized application before getting to LUIS, correct the timezone LUIS uses.

V3 prediction API to alter timezone

In V3, the datetimeReference determines the timezone offset.

V2 prediction API to alter timezone

The timezone is corrected by adding the user's timezone to the endpoint using the timezoneOffset parameter based on the API version. The value of the parameter should be the positive or negative number, in minutes, to alter the time.

V2 prediction daylight savings example

If you need the returned prebuilt datetimeV2 to adjust for daylight savings time, you should use the querystring parameter with a +/- value in minutes for the endpoint query.

Add 60 minutes:

https://{region}.api.cognitive.azure.cn/luis/v2.0/apps/{appId}?q=Turn the lights on?timezoneOffset=60&verbose={boolean}&spellCheck={boolean}&staging={boolean}&bing-spell-check-subscription-key={string}&log={boolean}

Remove 60 minutes:

https://{region}.api.cognitive.azure.cn/luis/v2.0/apps/{appId}?q=Turn the lights on?timezoneOffset=-60&verbose={boolean}&spellCheck={boolean}&staging={boolean}&bing-spell-check-subscription-key={string}&log={boolean}

V2 prediction C# code determines correct value of parameter

The following C# code uses the TimeZoneInfo class's FindSystemTimeZoneById method to determine the correct offset value based on system time:

// Get CST zone id
TimeZoneInfo targetZone = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time");

// Get local machine's value of Now
DateTime utcDatetime = DateTime.UtcNow;

// Get Central Standard Time value of Now
DateTime cstDatetime = TimeZoneInfo.ConvertTimeFromUtc(utcDatetime, targetZone);

// Find timezoneOffset/datetimeReference
int offset = (int)((cstDatetime - utcDatetime).TotalMinutes);