Skip to content

Commit

Permalink
Send Email to employees
Browse files Browse the repository at this point in the history
  • Loading branch information
docwho2 committed Nov 29, 2023
1 parent df5e53f commit dc2c75e
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,16 @@ public Function<Request, Object> getExecutor() {
// Put the callingNumber in the subject if it exists, it might not if using lex console for example
final var subject = getCallingNumber() == null ? r.subject :
"[From " + getCallingNumber() + "] " + r.subject;

// If ChatGPT returns something that looks like an Object, convert to JSON and then to Pretty String
final var message_body = r.message instanceof String ? r.message : mapper.valueToTree(r.message).toPrettyString();

final var ses = SesClient.create();
final var id = ses.sendEmail((email) -> {
email.destination(dest -> dest.toAddresses(r.employee_email))
.message((mesg) -> {
mesg.body((body) -> {
body.text(cont -> cont.data(r.message));
body.text(cont -> cont.data(message_body));
}).subject(cont -> cont.data(subject));
}).source("[email protected]");
});
Expand Down

0 comments on commit dc2c75e

Please sign in to comment.