0 votes
asked by (120 points)

I am using Harlowe 2.0 in twine. I have user data at the end that I want to auto-generate and auto-send in an email. I also want to do it without a backend server. I do not need to keep the data after the person finishes the current passage. This is a training app and I want to send the current variable $positiveChoices and $negativeChoices values at the end of the scenario before they start over and the variables are reset to 0. 

**The slides deploy and the aircraft is evacuated.  Passengers scatter and the aircraft begins to now burn on the inside of the fuselage as well.  Aircraft has significant damage, lives are also lost!**
(link-goto: "Play again! Click here","Choose")
(set: $currentValue to 0)
"You have made $positiveChoices good choices during this scenerio"
"You have made $negativeChoices bad choices during this scenerio"
(if: $positiveChoices > $negativeChoices)["Nice job in choosing choices that mitigated this emergency effectively."]
(if: $positiveChoices < $negativeChoices)["Lets see if next time we can improve our choices during our mitigation of this ememrgency."]
(set: $negativeChoices to 0)
(set: $positiveChoices to 0)

 

 

1 Answer

+1 vote
answered by (116k points)

The story HTML you create using the Publish to File option is a standard HTML / CSS / Javascript web-application which means it relies on (and is limited to) the functionality of the web-browser it is being run on.

Web-browsers support three basic methods for sending email:

1. The mailto protocol

When used the web-browser will request the operating system (OS) to open the locally installed email handling application that has been previously configured as the OS's default, and there are many reasons why this request may fail. This method will require the user to interact with said email application.

2. Using the HTTP(S) protocol (directly or via JavaScript Ajax) to communicate with your own web-server.

There will need to be some sort of script on the web-browser to handle the request, and the web-server will need access to an email transfer agent / routing facility (and be pre-configured to use it) like Sendmail.

3. The same as point 2 except communicating with someone else's web-server.

There are numerous on-line companies / services that you can create an (free / paid) account on which will allow you to programatically send email through their site from your static HTML page or web-application, how secure or reliable those sites are I leave up to you (or others) to determine.

I can't recommend a particular service but after a quick search on google some of them are (in no particular order): formspree.io, SendGrid, mailgun, EmailJS, and even via Google Script

Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.
...