- What You Can Do with JS Param Modifier
- Generate Code with AI
- Working with parameters:
- Test Script
- How It Works
- Available Functions
- Namespaces
- Fail-Safe Behavior
- Limitations & Security
- Allowed
- Not Allowed
- Component Structure
- Examples
- Example 1: Convert Age Range → Single Value
- Example 2: Convert US Phone from E.164 → Local Format
- When This Is Useful
- Important
- Best Practices
- Common Mistakes
- When to Use AI vs Manual Code
- Use AI when:
- Write manually when:
JS Param Modifier
Updated 2 days ago
JS Param Modifier (JS Node) is a Call Flow component in Dialics that allows you to execute custom JavaScript during a call.
It is designed to modify, calculate, and prepare data in real time without requiring backend changes.
What You Can Do with JS Param Modifier
Use JS Param Modifier when you need lightweight logic inside your call flow:
- transform incoming data (phone, ZIP, age, state, etc.)
- calculate new values
- combine multiple parameters
- normalize formats
- set routing flags
- prepare data for Ping/Post requests
Generate Code with AI
You don't need to write JavaScript manually.
JS Param Modifier includes AI Code Generation:
- Describe what you want in plain English Example:
"Convert Caller Identity age range like 60-70 into a single number"
- Click Generate Script
- AI generates a ready-to-use script
- Review and apply the generated code
You can edit the generated script manually if needed.
Working with parameters:
- Use double quotes and square brackets:
getParam("[Caller Identity:age_range]") - Right-click in the editor to open a list of available parameter groups and keys
- Select a parameter from the list to insert it into your script
Test Script
You can use Test Script to verify how your script modifies parameters before publishing:
- Click Test Script
- Paste a Call UUID
- Click Run Test
Result:
You will see parameter changes:
- Before — original value
- After — updated value
Test runs in simulation mode — original call data is not changed.
How It Works
- The script runs synchronously during the call
- It works with live call parameters
- It does not return values — it updates parameters directly
Available Functions
getParam("[namespace:key]")
updateParam("[namespace:key]",value)
getParam— retrieve a parameterupdateParam— create or update a parameter
Namespaces
Parameters are grouped into namespaces:
- Caller Identity
- Caller Profile
- Traffic Source Parameters
- Custom Parameters
- Session Data
- Call Flow
Fail-Safe Behavior
If the script throws an error:
- the error is logged
- the call continues
- the flow moves to On Failure
Limitations & Security
JS Param Modifier runs in a sandbox environment.
Allowed
- JavaScript (ES5 only)
- Math, Date
- String, Number, Boolean
- Object, Array, JSON
Not Allowed
require,importfetch,XMLHttpRequestsetTimeout,setInterval- file system or network access
Execution is limited by:
- timeout
- memory usage
Component Structure
The node includes:
- Node Name — label displayed in the call flow
- Script Editor — field to write or generate JavaScript code
- Test Script — tool to simulate script execution using a Call UUID
- Outputs:
- On Success — continues flow if script executes without errors
- On Failure — triggered if script execution fails
Examples
Example 1: Convert Age Range → Single Value
Caller Identity may return:
callerIdentityParams:age_range = "60-70"
To convert it into a number:
var ageRange=getParam("[Caller Identity:age_range]");
if (ageRange&&ageRange.indexOf("-")!==-1) {
var parts=ageRange.split("-");
var avgAge= (parseInt(parts[0],10)+parseInt(parts[1],10))/2;
updateParam("[Caller Identity:age_range]", Math.round(avgAge));
}Result:
callerIdentityParams:age_range = 65
Example 2: Convert US Phone from E.164 → Local Format
Caller Profile may return a phone number in E.164 format:
callerProfileParams:original_format = "+14155551234"
To convert it into a 10-digit US local number:
var phone=getParam("[Caller Profile:original_format]")
if (phone) {
// Remove all non-digit characters
var normalized=String(phone).replace(/\D/g,"");
// Remove leading US country code (1)
if (normalized.length===11&&normalized.charAt(0)==="1") {
normalized=normalized.substring(1);
}
updateParam("[Custom Parameters:phone_local_format]",normalized);
}Result:
customParams:phone_local_format = "4155551234"
When This Is Useful
- buyers require 10-digit US numbers
- your source sends E.164 format
- you need consistent formatting before routing or pinging
Important
This example works for US numbers only.
Best Practices
- Always validate input before processing
- Handle unexpected formats safely
- Keep scripts short and focused
- Avoid complex logic (use backend if needed)
Common Mistakes
- Not checking if parameter exists
- Assuming fixed format (e.g., always "60-70")
- Forgetting to normalize data before processing
- Overcomplicating scripts
When to Use AI vs Manual Code
Use AI when:
- you don't know how to implement logic
- you need quick results
- the logic is moderately complex
Write manually when:
- the script is simple
- you need precise control
- What You Can Do with JS Param Modifier
- Generate Code with AI
- Working with parameters:
- Test Script
- How It Works
- Available Functions
- Namespaces
- Fail-Safe Behavior
- Limitations & Security
- Allowed
- Not Allowed
- Component Structure
- Examples
- Example 1: Convert Age Range → Single Value
- Example 2: Convert US Phone from E.164 → Local Format
- When This Is Useful
- Important
- Best Practices
- Common Mistakes
- When to Use AI vs Manual Code
- Use AI when:
- Write manually when:
Was this article helpful?