The Unified Question Handler is an Obsidian plugin that simplifies the process of gathering user input in your scripts and templates. It provides a unified interface for asking various types of questions and handling user responses.
- Single modal interface for multiple questions
- Support for various question types: input, checkbox, fuzzy search, multi-select, and more
- Integration with index files for dynamic options
- Easy to integrate with existing scripts
- Download the latest release from the GitHub repository.
- Extract the zip file in your Obsidian vault's
.obsidian/plugins/directory. - Enable the plugin in Obsidian's Community Plugins settings.
The Unified Question Handler exposes an API through Obsidian's plugin registry. Here's how to access and use it:
// Get the API from the plugin registry
const api = app.plugins.plugins['unified-question-handler'].api;
// Example usage
const questions = [
{
type: "inputPrompt",
prompt: "What's your name?",
answerId: "name"
},
{
type: "checkbox",
prompt: "Are you a student?",
answerId: "isStudent"
}
];
const answers = await api.askQuestions(questions);
if (answers) {
console.log(`Name: ${answers.name}`);
console.log(`Is student: ${answers.isStudent ? 'Yes' : 'No'}`);
}For better type safety and version checking, you can use the provided utility function:
const { getUnifiedQuestionHandlerAPI } = require('unified-question-handler/utils');
try {
const api = getUnifiedQuestionHandlerAPI(app);
// Use the API as shown above
} catch (error) {
console.error('Failed to access Unified Question Handler:', error);
}The plugin supports various question types:
inputPrompt: Simple text inputcheckbox: Yes/no questionsfuzzySuggester: Selection with fuzzy searchmultiSelect: Multiple option selectionindexedManual: Selection from an index file with manual entry option
Index files allow you to maintain lists of options for your questions:
const questions = [
{
type: "fuzzySuggester",
prompt: "Select your favorite color:",
answerId: "favoriteColor",
indexPath: "Meta/Indices/Colors.md",
allowNewEntry: true
}
];The index file (Colors.md) should contain a list of options:
Red
Blue
Green
Yellow
Purple
The plugin includes version information to ensure compatibility:
const api = getUnifiedQuestionHandlerAPI(app);
console.log(`API Version: ${api.getAPIVersion()}`);Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.