A microservice for handling static and dynamic HTML forms in the automation workflow system. This service manages form rendering, submission, and session updates for both inline (static) and popup (dynamic) form types.
The Automation Form Service provides a centralized way to:
- Serve HTML forms for user input
- Handle form submissions
- Update session data with form responses
- Support both static (inline) and dynamic (popup) form rendering modes
- Features
- Form Types
- Installation
- Configuration
- Usage in Flow Configuration
- API Endpoints
- Form Development
- Session Management
- Static Forms: Rendered inline within the frontend application
- Dynamic Forms: Opened in a new window/tab with automatic polling for submission status
- Session Integration: Automatically updates session data with form submissions
- Multi-Domain Support: Supports multiple domains (FIS12, FIS13, TRV14, etc.)
- EJS Templating: Uses EJS for dynamic form rendering with injected submission URLs
Static forms are rendered directly inline within the frontend application. They are suitable for:
- Simple data collection forms
- Forms that should be part of the main flow UI
- Forms that don't require a separate window
Characteristics:
- Rendered immediately in the frontend
- No popup window required
- Form submission happens within the same page context
- Flow continues automatically after submission
Dynamic forms open in a new window/tab and are suitable for:
- Complex multi-step forms
- Forms requiring user attention in a separate window
- Forms that may take time to complete
- Forms that need to be tracked via polling
Characteristics:
- Opens in a new browser window/tab
- Frontend polls for submission status
- Shows success page after submission
- Auto-closes after successful submission
- Flow continues automatically once submission is detected
# Install dependencies
npm install
# Build the project
npm run build
# Run in development mode
npm run dev
# Run in production mode
npm startPORT=3001 # Server port (default: 3001)
BASE_URL=http://localhost:3001 # Base URL for form serviceForms are configured in src/config/index.yaml. Each form must be registered with the following structure:
domains:
- name: 'FIS12' # Domain identifier
version: '2.0.2' # Domain version
forms:
- name: "form_name" # Display name
url: "form_url" # URL identifier (used in flow config)
path: "FIS12/form-path" # Path to form.html file
type: "static" # "static" or "dynamic"
sessionUpdateFunction: "update-session.ts"
successRedirect: "https://example.com/success"Forms are stored as HTML files in the following structure:
src/config/
└── {domain}/
└── {form-path}/
└── form.html
Example:
src/config/
└── FIS12/
└── loan-amount-adjustment-form/
└── form.html
Forms use EJS templating and receive the following variables:
actionUrl: The submission URL (automatically injected)session_id: Session identifiertransaction_id: Transaction identifierflow_id: Flow identifier
Example form template:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Form Title</title>
</head>
<body>
<form method="POST" action="<%= actionUrl %>">
<label for="field1">Field 1</label>
<input type="text" id="field1" name="field1" />
<input type="submit" value="Submit" />
</form>
</body>
</html>Forms are integrated into flows via the automation-config-service. Configure forms in your flow YAML files as follows:
In your flow configuration file (e.g., automation-config-service/src/config/FIS12/V-2.0.2/goldLoan/flows/index.yaml):
sequence:
- key: loan_amount_adjustment_form
label: Loan Amount Adjustment Form
type: HTML_FORM
unsolicited: false
pair: null
owner: BPP
expect: false
input:
- name: form_submission_id
label: Enter Form Submission id
type: HTML_FORM
reference: $.reference_data.loan_amount_adjustment_formKey Points:
type: HTML_FORMindicates a static formreferencefield points to the form URL in reference data (e.g.,$.reference_data.loan_amount_adjustment_form)- The form URL should match the
urlfield inautomation-form-service/src/config/index.yaml - Form is rendered inline in the frontend
sequence:
- key: verification_status
label: Verification Status Form
type: DYNAMIC_FORM
unsolicited: false
pair: null
owner: BPP
expect: false
input:
- name: form_submission_id
label: Enter Form Submission id
type: DYNAMIC_FORM
payloadField: "form_submission_id"
reference: $.reference_data.verification_statusKey Points:
type: DYNAMIC_FORMindicates a dynamic formreferencefield points to the form URL in reference datapayloadFieldspecifies where to store the submission ID- Form opens in a new window/tab
- Frontend polls for submission status
The form URL must be provided in the reference data of the previous API response. For example:
{
"reference_data": {
"loan_amount_adjustment_form": "FIS12/loan_amount_adjustment_form",
"verification_status": "FIS12/verification_status"
}
}The form service will look up forms using the pattern: {domain}/{formUrl}
GET /forms/:domain/:formUrl
Retrieves and renders a form.
Query Parameters:
session_id(required): Session identifiertransaction_id(required): Transaction identifierflow_id(required): Flow identifierdirect(optional): For dynamic forms, set totrueto render HTML directly
Response for Static Forms:
- Returns HTML content directly
Response for Dynamic Forms (without direct=true):
{
"success": true,
"type": "dynamic",
"formUrl": "http://localhost:3001/forms/FIS12/verification_status?flow_id=...&session_id=...&transaction_id=...&direct=true",
"message": "Please open this URL to fill the form"
}Response for Dynamic Forms (with direct=true):
- Returns HTML content directly
POST /forms/:domain/:formUrl/submit
Handles form submission.
Query Parameters:
session_id(required): Session identifiertransaction_id(required): Transaction identifierflow_id(required): Flow identifier
Request Body: Form data as key-value pairs (standard HTML form submission)
Response for Static Forms:
- Calls mock service to continue flow
- Returns success response
Response for Dynamic Forms:
- Updates main session with submission status
- Returns HTML success page
- Does NOT call mock service (frontend handles flow continuation)
-
Create the form HTML file:
mkdir -p src/config/FIS12/my-new-form touch src/config/FIS12/my-new-form/form.html
-
Write the form HTML:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>My New Form</title> </head> <body> <form method="POST" action="<%= actionUrl %>"> <!-- Your form fields here --> <input type="submit" value="Submit" /> </form> </body> </html>
-
Register the form in
src/config/index.yaml:- name: "My New Form" url: "my_new_form" path: "FIS12/my-new-form" type: "static" sessionUpdateFunction: "update-session.ts" successRedirect: "https://example.com/success"
-
Add form to flow configuration:
- key: my_new_form label: My New Form type: HTML_FORM input: - name: form_submission_id type: HTML_FORM reference: $.reference_data.my_new_form
Follow the same steps as static forms, but:
- Set
type: "dynamic"inindex.yaml - Use
type: DYNAMIC_FORMin flow configuration - Include
payloadFieldin the input configuration
When a form is submitted, the service:
- Generates a unique
submission_id(UUID) - Updates the transaction session with form data:
{ form_data: { [formUrl]: { ...formData, form_submission_id: submission_id } } }
For dynamic forms, the service also updates the main session to track submission status:
{
formSubmissions: {
[transaction_id]_[formUrl]: {
submitted: true,
submission_id: "uuid",
timestamp: "ISO timestamp",
formUrl: "form_url"
}
}
}The frontend polls this data to detect when a dynamic form has been submitted.
| Feature | Static Form (HTML_FORM) | Dynamic Form (DYNAMIC_FORM) |
|---|---|---|
| Rendering | Inline in frontend | New window/tab |
| User Experience | Part of main flow | Separate window |
| Submission Detection | Immediate | Polling-based |
| Flow Continuation | Automatic via mock service | Frontend handles proceed |
| Use Case | Simple forms | Complex/long forms |
| Configuration Type | type: "static" |
type: "dynamic" |
| Flow Config Type | type: HTML_FORM |
type: DYNAMIC_FORM |
- Verify the form is registered in
src/config/index.yaml - Check that the
urlfield matches the reference data - Ensure the form HTML file exists at the specified
path
- Check that the form HTML file is valid
- Verify EJS template syntax (use
<%= %>for variables) - Check server logs for errors
- Verify
updateMainSessionWithFormSubmissionis being called - Check that the frontend is polling the correct session
- Ensure
formUrlparameter is passed correctly
- Verify
transaction_idis correct - Check Redis connection (if using Redis for sessions)
- Review session service logs
# Development mode with hot reload
npm run dev
# Build for production
npm run build
# Run tests
npm testautomation-form-service/
├── src/
│ ├── config/
│ │ ├── index.yaml # Form registry
│ │ ├── central-config.ts # Configuration service
│ │ └── {domain}/ # Domain-specific forms
│ │ └── {form-path}/
│ │ └── form.html
│ ├── controllers/
│ │ └── form-controller.ts # Form request handlers
│ ├── routes/
│ │ └── form-routes.ts # Express routes
│ ├── services/
│ │ └── session-service.ts # Session management
│ └── index.ts # Application entry point
└── package.json
- automation-config-service: Defines flow configurations with form actions
- automation-frontend: Renders forms and handles user interactions
- automation-mock-service: Continues flow after form submission (static forms)