Skip to content

Instantly share code, notes, and snippets.

@zeyneloz
Created April 4, 2019 22:52
Show Gist options
  • Save zeyneloz/baec405550c9d92f3e1813964c09a998 to your computer and use it in GitHub Desktop.
Save zeyneloz/baec405550c9d92f3e1813964c09a998 to your computer and use it in GitHub Desktop.
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