Chad Knutson gave a talk to setup a simple form to find the best date for a party. That was useful, but that his query was answered he only knew by inspecting the data file in the cloud.
I would like to be signaled that there was a successful interaction with my website, i.e. someone who has added to the file in the cloud.
H.W.,
You’re looking for a proactive notification instead of a manual check. The Wolfram Language is perfect for automating that step.
We can use the SendMail function right after the data has been written.
Using SendMail in Your FormFunction
Assuming your original FormFunction looked something like the first line below, here is how you would modify the function that handles the form data (#):
(* The new action function is enclosed in parentheses for clarity *)
CloudDeploy[
FormFunction[
{"name" -> "String", "date" -> "DateObject"},
(
(* 1. Write the new data to the cloud file *)
Export["cloud:///Path/To/Your/DataFile.mx", #, "Append"];
(* 2. Send the Notification Email *)
SendMail[
"To" -> "your.email@example.com", (* <--- Your Email Address *)
"Subject" -> "✅ New Form Submission Received!",
"Body" -> "A new entry has been submitted for the party date finder.
Name: " <> #name <> "
Date: " <> ToString[#date]
];
(* 3. Provide a response to the user *)
"Thank you for your input! Your suggestion has been saved."
) &
]
]
Key Points
-
Cloud Credits: Using
SendMailconsumes a small number of cloud credits, as it is a service-based operation. -
#nameAccess: The symbol#in theFormFunctionrepresents the submitted form data as anAssociation.You can directly access the submitted fields using#name,#date, etc. -
ToString: Since the values are Wolfram Language expressions (like aDateObject), it’s often best practice to wrap them inToStringbefore concatenating them with a string, to ensure they format correctly in the email body.
Alternative: Using Wolfram Data Drop
A Data Drop is specifically designed for collecting time-series or event-based data from external sources.
-
Create a Data Drop:
data = CreateDataDrop[] -
Integrate: Use
DropData[data, #] &as the action for yourFormFunction -
Monitor: You can set up monitoring or alerts directly on your Data Drop in the Cloud interface or by using functions like
DataDropContentMonitor