OpenAI feature including Azure OpenAI integration, Orchard Harvest 2025 survey - This week in Orchard (17/01/2025)
This time, you can see a fascinating demo of the OpenAI feature, including Azure OpenAI integration! But first, let's check out our other topics, like removing ReCaptchaMode and DetectionThreshold, introducing the new ReCaptcha shape, and exposing properties of ITrackingConsentFeature and cookie policy in Liquid! Oh, and did we mention that we have just created a survey for Orchard Harvest 2025?
Orchard Core updates
Remove ReCaptchaMode and DetectionThreshold, and introduce the new ReCaptcha shape
In Orchard Core 2.x, the ReCaptcha module supports two modes: AlwaysShow and PreventRobots. To simplify the module, and enhance integration, the PreventRobots mode and its related components will be removed in Orchard Core 3. Going forward, only the AlwaysShow mode will be supported.
As part of this update, the following components will be deprecated and removed:
- IDetectRobots
- IPAddressRobotDetector
- ReCaptchaMode
Furthermore, the ReCaptchaService class will be sealed to prevent inheritance. The following methods will also be removed:
- MaybeThisIsARobot
- IsThisARobot
- ThisIsAHuman
The FormReCaptcha view is available to inject a ReCaptcha challenge from any display driver. This view will be removed in Orchard Core 3. A new ReCaptcha shape will be introduced, enabling you to render the ReCaptcha challenge using a customizable shape. The recommended approach in Orchard Core 3 will be to return this shape directly, as shown below:
return Dynamic("ReCaptcha", (m) =>
{
m.language = CultureInfo.CurrentUICulture.Name;
}).Location("Content:after");
Instead of the following approach:
return View("FormReCaptcha", model).Location("Content:after");
If you still need to render ReCaptcha using the deprecated FormReCaptcha, you can manually add the FormReCaptcha.cshtml view to your project. Here's the code for this:
<div class="mb-3">
<captcha mode="AlwaysShow" language="@Orchard.CultureName()" />
</div>
This change is designed to simplify your integration process and make managing ReCaptcha usage in your project easier. Here is the code for how you can display the ReCaptcha shape if the service is configured.
By using Liquid:
{% shape "ReCaptcha", language: "en-US" %}
By using Razor:
<shape type="ReCaptcha" language="en-US" />
To try this out quicky, you have to enable the ReCaptcha feature under Configuration -> Features. Afterward, you must configure the service under Security -> Settings -> reCAPTCHA. Here, you need to provide your Google's reCaptcha Site Key and Secret Key. You can get these at https://developers.google.com/recaptcha/.
We created a custom content type called Liquid Page. This content type has a Liquid Part attached where we can use the Liquid format. Now, the only thing left is to create a new Liquid Page to display the ReCaptcha shape using the Liquid code mentioned above.
Expose properties of ITrackingConsentFeature and cookie policy in Liquid
When building cookie-consent functionality with Liquid, it's helpful to expose the functionality or at least some of the properties of the ITrackingConsentFeature. E.g., CanTrack, IsConsentNeeded, and the consent cookie name and value would allow the building of a JS consent dialog.
The new TrackingConsent object represents the tracking consent feature of the current request. The following properties are available on this object:
- CanTrack: Indicates if tracking is allowed.
- HasConsent: Indicates if the user has given consent for tracking.
- IsConsentNeeded: Indicates if consent is needed for tracking.
- CookieName: The name of the consent cookie.
- CookieValue: The value of the consent cookie.
Let's see an example of how to use the TrackingConsent object in a Liquid template. Here, we will use our Liquid Page that we have created before:
Demos
OpenAI feature including Azure OpenAI integration
In this demo, we will check out a new module created by Mike Alhayek, which is an implementation of OpenAI. It contains a lot of features, so let's check out some of these! The OpenAI Chat feature is an implementation of ChatGPT. It provides you with a way to have profiles and be able to define your chat instances. Let's enable that first and see what this one does. This provides a UI for OpenAI Deployments and a UI for OpenAI Chat Profiles. This feature alone is not really good enough; you have to enable the Azure OpenAI feature, which utilizes the Azure OpenAI Services as a source for the OpenAI implementations. After, you can add an OpenAI Chat Profile under OpenAI -> Profiles, where you can select Azure OpenAI from the available sources.
A profile lets you define what you want this chat instance to do. There are a lot of settings, as you can see. Let's say we will create an instance we can chat with, like chatgpt.com or anything like that. Here, we create a Standard chat using the Chat profile type.
If you click Save, you can select the Standard chat option under OpenAI and type whatever you want, like What is OpenAI? or When was it founded? This is public knowledge at this point; if you put something like What is the weather like in Las Vegas?, you will get a generic response.
There are functions in OpenAI that allow the OpenAI module to call your code, and then you will be able to call a third-party service, like an API, and get real-time weather information, for example. Here you can read more about OpenAI Chat Functions, how to add them, and what interface you need to implement.
We already have an implementation of Search AI, and now there is a way to integrate OpenAI with ChatAI. To demo it, we created some sample content types that contain some lines from the Orchard Core documentation to have documents on our site. The next step is to create an Azure AI Search Index, which indexes the custom Documentation Page content type.
And by doing that, now we have data in our Search AI index. Now we can chat against our data by enabling the Azure OpenAI with Azure AI Search feature, which is an AI-powered chat using Azure OpenAI models with data from Azure AI Search. Now, we can add a new OpenAI Chat Profile and use Azure OpenAI with Azure AI Search as the profile source. It's quite the same as the Azure OpenAI profile source. The main difference is that you can select the Azure AI search index as the data source. Now you can ask something that is inside the index, like What communication methods does Orchard Core support?, and you will get an answer. So, the idea here is that you can create a chat using the data coming from your content items.
And we are just scratching the surface of this topic! If you want to know more, don't forget to check out this recording on YouTube!
News from the community
Orchard Harvest 2025 survey
After last year, the Orchard Harvest Conference will be held again in 2025. Last year, it was held in Las Vegas, and we had a really great time there. We would like to try to organize it again in Europe this year. But first, we would like to assess the potential interest and what would be needed. You can fill in the questionnaire here, which should take about 5 minutes. Please share your thoughts with us in the survey. We are curious about who we will meet in 2025! :)
Orchard Dojo Newsletter
Lombiq's Orchard Dojo Newsletter has 463 subscribers! We have started this newsletter to inform the community around Orchard of the latest news about the platform. By subscribing to this newsletter, you will get an e-mail whenever a new post is published to Orchard Dojo, including This week in Orchard of course.
Do you know of other Orchard enthusiasts who would like to read our weekly articles? Tell them to subscribe here!