Zoho Creator Deluge Script for Voice/Chat Automation
This script integrates Zoho Chatter (or a voice assistant) with Zoho Creator to automate form entries. It listens to user inputs, validates mandatory fields, and creates records automatically.
1. Use Case
- A user sends a chat message (via Zoho Chatter or a voice assistant).
- The script parses the input, checks for mandatory fields, and creates a record in Zoho Creator.
- If required fields are missing, it asks the user for clarification before proceeding.
2. Deluge Script (Zoho Creator)
Scenario: Automating a "Purchase Order" Form
// =============================================
// Deluge Script for Zoho Creator Automation
// Trigger: On User Message (Chatter/Voice Input)
// =============================================
// 1. Define the Creator Form (Replace with your form name)
formName = "Purchase_Order";
creatorConnection = zoho.creator.getConnection("your-connection-name");
// 2. Parse User Input (Example: "Create PO for Vendor: ABC Corp, Item: Laptop, Qty: 5")
userInput = "Create PO for Vendor: ABC Corp, Item: Laptop, Qty: 5";
// 3. Extract Fields Using Regex (Customize based on expected input format)
vendorRegex = "Vendor:\\s*([^,]+)";
itemRegex = "Item:\\s*([^,]+)";
qtyRegex = "Qty:\\s*(\\d+)";
vendor = if(regexMatch(userInput, vendorRegex), regexMatch(userInput, vendorRegex).get(0), "");
item = if(regexMatch(userInput, itemRegex), regexMatch(userInput, itemRegex).get(0), "");
qty = if(regexMatch(userInput, qtyRegex), regexMatch(userInput, qtyRegex).get(0), "");
// 4. Check Mandatory Fields (If missing, ask user via Chatter)
mandatoryFields = {
"Vendor": vendor,
"Item": item,
"Quantity": qty
};
missingFields = {};
for each field in mandatoryFields.keys() {
if(mandatoryFields.get(field).isEmpty()) {
missingFields.put(field, true);
}
}
// 5. If Missing Fields, Ask User via Chatter (or Voice Assistant)
if(missingFields.size() > 0) {
missingFieldsList = missingFields.keys().toList();
responseMessage = "Missing fields: " + missingFieldsList.toString(", ") + ". Please provide them.";
// Send back to Chatter (or Voice Assistant)
zoho.chatter.postMessage(
"me",
responseMessage,
"Your_Bot_Name"
);
return;
}
// 6. If All Fields Present, Create Record in Zoho Creator
recordData = {
"Vendor": vendor,
"Item": item,
"Quantity": qty.toLong(),
"Status": "Draft"
};
createResponse = creatorConnection.addRecord(
formName,
recordData
);
// 7. Confirm Success to User
if(createResponse.get("code") == 3000) {
successMessage = "Purchase Order created successfully! ID: " + createResponse.get("id");
zoho.chatter.postMessage(
"me",
successMessage,
"Your_Bot_Name"
);
} else {
errorMessage = "Failed to create record. Error: " + createResponse.get("message");
zoho.chatter.postMessage(
"me",
errorMessage,
"Your_Bot_Name"
);
}
3. How It Works
-
User Input Parsing
- Extracts
Vendor, Item, and Quantity from a structured message.
- Example:
"Create PO for Vendor: ABC Corp, Item: Laptop, Qty: 5"
-
Mandatory Field Check
- If any field is missing, the bot asks the user to provide it.
-
Record Creation in Zoho Creator
- If all fields are present, it creates a new record in the specified form.
-
Confirmation Message
- Sends a success/failure message back to the user via Zoho Chatter (or a voice assistant).
4. Extending for Voice Input
If using a voice assistant (e.g., Zoho SalesIQ, Dialogflow, Alexa), modify the input parsing to handle natural language instead of structured text.
Example: Voice Input Handling
// Example: User says "Create a purchase order for 10 laptops from ABC Corp"
userInput = "Create a purchase order for 10 laptops from ABC Corp";
// Use AI/NLP to extract entities (Vendor, Item, Quantity)
vendor = if(userInput.contains("from"), userInput.split("from")[1].trim(), "");
item = if(userInput.contains("for"), userInput.split("for")[1].split("from")[0].trim(), "");
qty = if(userInput.contains("for"), userInput.split("for")[0].replaceAll("[^0-9]", "").trim(), "");
// Rest of the logic remains the same...
5. Deployment Steps
-
Set Up Zoho Creator Form
- Ensure your form has fields like
Vendor, Item, Quantity, etc.
-
Configure Zoho Chatter Bot
- Use Zoho Flow or Zoho SalesIQ to trigger this script when a user sends a message.
-
Test & Debug
- Use
info statements to log variables.
- Test with different input formats.
-
Deploy
- Run this script in Zoho Creator’s Deluge Editor or via Zoho Flow.
6. Enhancements
✅ Multi-Language Support – Use NLP to parse different languages.
✅ OAuth Security – Secure API calls with OAuth2.
✅ Error Handling – Better validation for incorrect inputs.
✅ Hybrid Input – Allow both voice and chat inputs.
Final Notes
- Replace
your-connection-name with your Zoho Creator connection.
- Customize regex patterns based on your expected input format.
- For voice inputs, consider integrating Zoho SalesIQ or Dialogflow.
Would you like me to extend this for a specific Zoho Creator form or voice assistant integration? 🚀