diff --git a/email-sender/readme.md b/email-sender/readme.md index 39e9237..35a5caf 100644 --- a/email-sender/readme.md +++ b/email-sender/readme.md @@ -31,8 +31,8 @@ add OPENAI_API_KEY, SENDGRID_API_KEY, FROM_EMAIL, TO_EMAIL in .env ```bash npm i -npm build -npm dev +npm run build +npm run dev ``` Your code will be running and syncing with Restack engine to execute workflows or functions. @@ -55,4 +55,4 @@ In another shell: npm run schedule-retries ``` -Will schedule to start example workflow immediately. The code for this is on `scheduleWorkflowRetries.ts`. In here you can see how the sendEmailWorkflow is scheduled to be exectuted and the step to generate email content is force to have a failure and show how Restack will handle retries automatically for you. Step will fail once and be successfull on the next retry, then rest of steps defined on workflow will be exectuted correctly +This will schedule the example workflow to start immediately. The code for this is in `scheduleWorkflowRetries.ts`. In this file, you can see how the `sendEmailWorkflow` is scheduled for execution. The step to generate email content is intentionally set to fail once, demonstrating how Restack automatically handles retries. After the first failure, the step will succeed on the next retry, and the remaining steps in the workflow will execute as expected. diff --git a/email-sender/src/functions/sendEmail.ts b/email-sender/src/functions/sendEmail.ts index 44a02c8..5cd2236 100644 --- a/email-sender/src/functions/sendEmail.ts +++ b/email-sender/src/functions/sendEmail.ts @@ -36,4 +36,6 @@ export async function sendEmail({ text, subject, to }: EmailInput) { } catch (error) { throw FunctionFailure.nonRetryable('Failed to send email'); } + + return 'Email sent successfully'; } diff --git a/email-sender/src/workflows/sendEmail.ts b/email-sender/src/workflows/sendEmail.ts index 83edbe2..3c7627b 100644 --- a/email-sender/src/workflows/sendEmail.ts +++ b/email-sender/src/workflows/sendEmail.ts @@ -36,4 +36,5 @@ export async function sendEmailWorkflow({ }); log.info('Email sent successfully'); + return 'Email sent successfully'; }