Group Abstract Group Abstract

Message Boards Message Boards

0
|
1.5K Views
|
1 Reply
|
0 Total Likes
View groups...
Share
Share this post:

How do I get a message indicating someone gave input to my website?

Posted 1 year ago

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.

POSTED BY: H.W. Wilschut
Posted 1 month ago

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

  1. Cloud Credits: Using SendMail consumes a small number of cloud credits, as it is a service-based operation.

  2. #name Access: The symbol # in the FormFunction represents the submitted form data as an Association. You can directly access the submitted fields using #name, #date, etc.

  3. ToString: Since the values are Wolfram Language expressions (like a DateObject), it's often best practice to wrap them in ToString before 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.

  1. Create a Data Drop: data = CreateDataDrop[]

  2. Integrate: Use DropData[data, #] & as the action for your FormFunction

  3. Monitor: You can set up monitoring or alerts directly on your Data Drop in the Cloud interface or by using functions like DataDropContentMonitor

Getting Started with the Wolfram Data Drop

POSTED BY: Rob Pacey
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard