Getting Started with ASP.NET MVC AI AssistView control
21 Jul 20266 minutes to read
This section briefly explains how to include the ASP.NET MVC AI AssistView control in your ASP.NET MVC application using Visual Studio.
Prerequisites
.NET and Visual Studio compatibility
| .NET Version | Visual Studio Version |
|---|---|
| .NET Framework 4.6.2 | Visual Studio 2015 Update 3 or later |
Browser support
| Browser | Versions |
|---|---|
| Google Chrome, including Android & iOS | Latest Version |
| Mozilla Firefox | Latest Version |
| Microsoft Edge | Latest Version |
| Apple Safari, including iOS | Latest Version |
| Opera | Latest Version |
| Microsoft Internet Explorer | 11 |
Create an ASP.NET MVC Web App with HTML Helper
Create an ASP.NET MVC Web App using Visual Studio via Microsoft Templates or the Syncfusion® ASP.NET MVC Extension. For detailed instructions, refer to the ASP.NET MVC Getting Started documentation.
Install the required ASP.NET MVC package
To add ASP.NET MVC AI AssistView control in the app, open the NuGet package manager in Visual Studio (Tools → NuGet Package Manager → Manage NuGet Packages for Solution), search for and install the Syncfusion.AspNetMvc.InteractiveChat package. All Syncfusion ASP.NET MVC packages are available in nuget.org. See the NuGet packages topic for details.
Alternatively, you can install the same package using the Package Manager Console with the following command.
Install-Package Syncfusion.AspNetMvc.InteractiveChat -Version 34.1.29Add the Namespace
After the package is installed, open the ~/Views/Web.config file and import the Syncfusion.EJ2 namespace.
<namespaces>
<add namespace="Syncfusion.EJ2" />
</namespaces>Add stylesheet and script resources
The theme stylesheet and script are referenced from the CDN. Include the stylesheet and script references inside the <head> of the ~/Views/Shared/_Layout.cshtml.
<head>
...
<!-- ASP.NET MVC controls styles -->
<link rel="stylesheet" href="https://cdn.syncfusion.com/ej2/34.1.29/fluent2.css" />
<!-- ASP.NET MVC controls scripts -->
<script src="https://cdn.syncfusion.com/ej2/34.1.29/dist/ej2.min.js"></script>
</head>Register the script manager
Open the ~/Views/Shared/_Layout.cshtml file and register the script manager EJS().ScriptManager() at the end of the <body> element as follows.
<body>
...
<!-- ASP.NET MVC Script Manager -->
@Html.EJS().ScriptManager()
</body>Add ASP.NET MVC AI AssistView control
Add the ASP.NET MVC AI AssistView control in the ~/Views/Home/Index.cshtml file.
@using Syncfusion.EJ2.InteractiveChat
<div class="aiassist-container" style="height: 350px; width: 650px;">
@Html.EJS().AIAssistView("aiAssistView").Render()
</div>public ActionResult Default()
{
return View();
}Run the application
Press Ctrl+F5 (Windows) or ⌘+F5 (macOS) to launch the application. The ASP.NET MVC AI AssistView control will render in your default web browser.

Note: Starting from version 33.1x, when a user submits a prompt to the AI AssistView, the component automatically scrolls and focuses on the latest prompt and response. This behavior eliminates the need for users to manually scroll down to see the new response, ensuring they always view the most recent AI response without interruption. Prior to version 33.1x, the previous responses remained visible when new responses were added.
Configure suggestions and responses
You can use the PromptSuggestions property to add prompt suggestions and the PromptRequest event to add responses when the prompt matches the specified prompts data otherwise, the default response will be displayed.
@using Syncfusion.EJ2.InteractiveChat
@using Newtonsoft.Json
@{
var suggestions = new string[] { "How do I prioritize my tasks?", "How can I improve my time management skills?" };
var prompts = new[]
{
new { prompt = "How do I prioritize my tasks?", response = "Prioritize tasks by urgency and impact: tackle high-impact tasks first, delegate when possible, and break large tasks into smaller steps. For more assistance, feel free to ask—I’m here to help!", suggestionData = new List<string> { } },
new { prompt = "How can I improve my time management skills?", response = "To improve time management skills, try setting clear goals, using a planner or digital tools, prioritizing tasks, breaking tasks into smaller steps, and minimizing distractions. Regularly review and adjust your approach for better efficiency.", suggestionData = new List<string> { } }
};
var promptsJson = @Html.Raw(JsonConvert.SerializeObject(prompts));
}
<div class="aiassist-container" style="height: 350px; width: 650px;">
@Html.EJS().AIAssistView("aiAssistView").PromptSuggestions(suggestions).PromptRequest("onPromptRequest").Created("onCreated").Render()
</div>
<script>
var assistObj;
var prompts = @Html.Raw(promptsJson);
function onCreated() {
assistObj = this;
}
function onPromptRequest(args) {
setTimeout(function () {
var foundPrompt = prompts.find(prompt => prompt.prompt == args.prompt);
var defaultResponse = 'For real-time prompt processing, connect the AI AssistView control to your preferred AI service, such as OpenAI or Azure Cognitive Services. Ensure you obtain the necessary API credentials to authenticate and enable seamless integration.';
assistObj.addPromptResponse(foundPrompt ? foundPrompt.response : defaultResponse);
}, 2000);
}
</script>public ActionResult Default()
{
return View();
}