Created
April 4, 2019 22:52
-
-
Save zeyneloz/baec405550c9d92f3e1813964c09a998 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const AWS = require('aws-sdk'); | |
const stepFunctions = new AWS.StepFunctions({}); | |
exports.handler = async (event) => { | |
const notes = await getNotes(user.id); // Fetch user notes from database. | |
const sfnInput = { // Prepare Step Functions input | |
translateInput: { // translate Task will use this input. | |
text: notes, | |
language: event.translateTo | |
}, | |
sendMailInput: { // sendMail Task will user this input. | |
to: user.email, | |
subject: "Your notes", | |
message: "", // Notice the message is empty, adapter will set it later. | |
} | |
}; | |
const params = {stateMachineArn: "translateEmailSFN", input: JSON.stringify(sfnInput) }; | |
stepFunctions.startExecution(params); // Start translateEmailSFN Step Function. | |
return { message: "You will receive the email soon" };. | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment