Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      The Ultimate Guide to Node.js Development Pricing for Enterprises

      July 29, 2025

      Stack Overflow: Developers’ trust in AI outputs is worsening year over year

      July 29, 2025

      Web Components: Working With Shadow DOM

      July 28, 2025

      Google’s new Opal tool allows users to create mini AI apps with no coding required

      July 28, 2025

      5 preinstalled apps you should delete from your Samsung phone immediately

      July 30, 2025

      Ubuntu Linux lagging? Try my 10 go-to tricks to speed it up

      July 30, 2025

      How I survived a week with this $130 smartwatch instead of my Garmin and Galaxy Ultra

      July 30, 2025

      YouTube is using AI to verify your age now – and if it’s wrong, that’s on you to fix

      July 30, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      Time-Controlled Data Processing with Laravel LazyCollection Methods

      July 30, 2025
      Recent

      Time-Controlled Data Processing with Laravel LazyCollection Methods

      July 30, 2025

      Create Apple Wallet Passes in Laravel

      July 30, 2025

      The Laravel Idea Plugin is Now FREE for PhpStorm Users

      July 30, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      New data shows Xbox is utterly dominating PlayStation’s storefront — accounting for 60% of the Q2 top 10 game sales spots

      July 30, 2025
      Recent

      New data shows Xbox is utterly dominating PlayStation’s storefront — accounting for 60% of the Q2 top 10 game sales spots

      July 30, 2025

      Opera throws Microsoft to Brazil’s watchdogs for promoting Edge as your default browser — “Microsoft thwarts‬‭ browser‬‭ competition‬‭‬‭ at‬‭ every‬‭ turn”

      July 30, 2025

      Activision once again draws the ire of players for new Diablo Immortal marketing that appears to have been made with generative AI

      July 30, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»Natural Language Q&A in Optimizely CMS Using Azure OpenAI and AI Search

    Natural Language Q&A in Optimizely CMS Using Azure OpenAI and AI Search

    April 25, 2025

    In Part 2, we integrated Azure AI Search with Azure Personalizer to build a smarter, user-focused experience in Optimizely CMS. We used ServiceAPI to send CMS content to Azure AI Search. In Part 3, we’ll take things a step further: enabling users to ask natural language questions and get AI-powered answers. But here’s the twist: instead of using ServiceAPI, this time we’ll explore how to query indexed content directly using Azure AI Search’s REST API.

    Why Natural Language Q&A?

    Sometimes users don’t know the exact keywords. They ask things like:

    “How do I return a product?” “Can I book a demo?”

    With OpenAI on Azure and the semantic capabilities of Azure AI Search, your website can now understand those queries and provide helpful, contextual responses.

    Architecture Overview

    1. CMS content is indexed by Azure AI Search (via ServiceAPI or crawler).
    2. The search index is enriched with semantic settings.
    3. A user types a natural language query.
    4. Your backend uses Azure Search’s Semantic Search + Azure OpenAI (chat/completion API) to return a contextual answer.

    Using Azure Search API to Extract Content

    You can directly access indexed content using the Azure Search REST API. Here’s an example of how to fetch top 5 results:

    public async Task<List<string>> SearchAzureContentAsync(string query)
    {
        var searchServiceName = "<your-search-service-name>";
        var indexName = "<your-index-name>";
        var apiKey = "<your-api-key>";
    
        using var client = new HttpClient();
        client.DefaultRequestHeaders.Add("api-key", apiKey);
    
        var url = $"https://{searchServiceName}.search.windows.net/indexes/{indexName}/docs?api-version=2021-04-30-Preview&search={query}&$top=5";
        var result = await client.GetStringAsync(url);
        
        var json = JsonDocument.Parse(result);
        var docs = new List<string>();
    
        foreach (var item in json.RootElement.GetProperty("value").EnumerateArray())
        {
            docs.Add(item.GetProperty("content").GetString());
        }
    
        return docs;
    }

    Generate Answer Using Azure OpenAI

    Once we retrieve relevant documents, we’ll pass them into Azure OpenAI to generate a contextual answer:

    public async Task<string> AskOpenAiAsync(string question, List<string> context)
    {
        var prompt = $"""
    You are a helpful assistant. Based on the following content, answer the question:
    
    {string.Join("nn", context)}
    
    Question: {question}
    Answer:
    """;
    
        var openAiKey = "<your-openai-key>";
        var endpoint = "https://<your-openai-endpoint>.openai.azure.com/openai/deployments/<deployment-name>/completions?api-version=2022-12-01";
    
        var payload = new
        {
            prompt = prompt,
            temperature = 0.7,
            max_tokens = 200
        };
    
        using var client = new HttpClient();
        client.DefaultRequestHeaders.Add("api-key", openAiKey);
        var response = await client.PostAsync(endpoint, new StringContent(JsonSerializer.Serialize(payload), Encoding.UTF8, "application/json"));
    
        var result = JsonDocument.Parse(await response.Content.ReadAsStringAsync());
        return result.RootElement.GetProperty("choices")[0].GetProperty("text").GetString();
    }

    Integrate with Optimizely CMS

    You can create a controller like this:

    public class QnAController : Controller
    {
        [HttpPost]
        public async Task<ActionResult> Ask(string question)
        {
            var docs = await SearchAzureContentAsync(question);
            var answer = await AskOpenAiAsync(question, docs);
            return Json(new { answer });
        }
    }

    And on your view:

    <form method="post" id="qnaForm">
      <input type="text" name="question" placeholder="Ask a question..." />
      <button type="submit">Ask</button>
    </form>
    <div id="answer"></div>
    
    <script>
      $('#qnaForm').submit(function(e) {
        e.preventDefault();
        const question = $('input[name=question]').val();
        fetch('/QnA/Ask', {
          method: 'POST',
          headers: {'Content-Type': 'application/json'},
          body: JSON.stringify({ question })
        })
        .then(r => r.json())
        .then(data => $('#answer').text(data.answer));
      });
    </script>

    Summary

    This wraps up the final puzzle piece: letting users speak freely with your Optimizely site, while AI interprets and responds in real-time. From content indexing to re-ranking to full-on Q&A, your CMS is now intelligent, conversational, and user-first. Want to see this in action? Stay tuned for the sample repo and video walkthrough!

    The blog is also published here Natural Language Q&A in Optimizely CMS Using Azure OpenAI and AI Search

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleHow to use chatgpt4o to redesign your website
    Next Article Perficient Included in IDC Market Glance: Healthcare Provider Operational IT Solutions, 1Q25

    Related Posts

    Development

    Time-Controlled Data Processing with Laravel LazyCollection Methods

    July 30, 2025
    Development

    Create Apple Wallet Passes in Laravel

    July 30, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    CVE-2022-50224 – “KVM: AMD SVM NX Bit Validation Vulnerability”

    Common Vulnerabilities and Exposures (CVEs)

    12 Must-Know Cost Factors When Hiring Node.js Developers for Your Enterprise

    Tech & Work

    AI overviews and an AI chatbot are coming to YouTube. Here’s what they look like

    News & Updates

    Microsoft announces new Surface Pro and Surface Laptop with smaller screens, lower starting prices, and surprising design changes

    News & Updates

    Highlights

    CVE-2025-7207 – mruby Heap-Based Buffer Overflow Vulnerability

    July 9, 2025

    CVE ID : CVE-2025-7207

    Published : July 9, 2025, 1:15 a.m. | 5 hours, 22 minutes ago

    Description : A vulnerability, which was classified as problematic, was found in mruby up to 3.4.0-rc2. Affected is the function scope_new of the file mrbgems/mruby-compiler/core/codegen.c of the component nregs Handler. The manipulation leads to heap-based buffer overflow. An attack has to be approached locally. The exploit has been disclosed to the public and may be used. The name of the patch is 1fdd96104180cc0fb5d3cb086b05ab6458911bb9. It is recommended to apply a patch to fix this issue.

    Severity: 3.3 | LOW

    Visit the link for more details, such as CVSS details, affected products, timeline, and more…

    I’ve tested dozens of work laptops – but I’d take this Lenovo to the office everyday

    May 30, 2025

    U.S. Seizes $7.74M in Crypto Tied to North Korea’s Global Fake IT Worker Network

    June 17, 2025

    OpenAI Releases a Technical Playbook for Enterprise AI Integration

    April 19, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.