AI-Powered Survey Design Chat
AI assistants can simplify tasks like content creation, coding, and data generation. In surveys, they help authors configure questionnaires faster by turning plain text prompts into ready-to-use survey definitions. In this demo, Survey Creator integrates an AI assistant instead of the standard Property Grid. The assistant generates survey JSON schemas based on your input. Enter a description of your survey, click Send, and within seconds the schema will appear in the Survey Creator's JSON Editor tab.
Implementation
This Survey Creator configuration consists of four main parts:
Language Model
Integration begins with deploying a language model and exposing an API for interaction. Refer to the documentation of the chosen model for setup instructions. This example uses the GPT-3.5 Turbo model deployed on the SurveyJS website.Chat Manager
A static class that provides an API for sending prompts and parsing responses. Before the user can send a prompt, the chat manager sends system messages to establish context. Each user prompt is accompanied by the current JSON schema and instructions for the required response format. See thechat_manager.jsfile for details.Survey Creator Manager
A static class that provides an API for retrieving, validating, and assigning survey JSON schemas from and to Survey Creator. See thecreator_manager.jsfile for details.Custom AI Survey Chat Component
A custom component that renders a chat interface in the sidebar. It is activated by the AI Chat toolbar item and displays the conversation history, an input field, and a Send button. The component integrates with the chat manager and Survey Creator manager APIs to process prompts and manage JSON schemas. To use this component, register it under thesvc-ai-chatname with the appropriate factory:ReactElementFactory(React and vanilla JavaScript),AngularComponentFactory(Angular), orComponentFactory(Vue 3). See theAISurveyChatcomponent in the source code for implementation details.