How to Add custom flows in Form

Hi,
I am exploring the Forms (Early feature).
Can any one guide me how to add another action in Form->Flows->Action
like there some inbuilt functions given e.g. send mail using sendgrid.
But if We have configured SES as external mail provider then how can we add another action there send mail using SES

Step 1: Set Up AWS SES

  • Verify your email addresses: Ensure that you have verified the email addresses or domains you plan to use in SES.

  • Obtain your AWS credentials: You’ll need your AWS Access Key ID and Secret Access Key.

Step 2: Create a Lambda Function for Sending Email via SES

  • Go to the AWS Lambda console.

  • Create a new function.

  • Choose “Author from scratch.”

  • Assign a name to your function and select a runtime, such as Node.js or Python.

  • Attach the AmazonSESFullAccess policy to the Lambda execution role to allow sending emails via SES.

Write the Lambda Function Code:

Here is an example using Node.js:

const AWS = require('aws-sdk');
AWS.config.update({ region: 'us-east-1' });

exports.handler = async (event) => {
    const ses = new AWS.SES();

    const params = {
        Destination: {
            ToAddresses: [event.toEmail],
        },
        Message: {
            Body: {
                Text: { Data: event.body },
            },
            Subject: { Data: event.subject },
        },
        Source: event.fromEmail,
    };

    try {
        const data = await ses.sendEmail(params).promise();
        console.log(data);
        return { statusCode: 200, body: JSON.stringify(data) };
    } catch (error) {
        console.error(error);
        return { statusCode: 500, body: JSON.stringify(error) };
    }
};

Step 3: Set Up API Gateway

Create a new API:

  • Go to the API Gateway console.
  • Create a new REST API.

Create a Resource and Method:

  • Create a new resource.
  • Add a POST method to this resource.

Integrate the Method with Lambda:

  • Select Lambda Function as the integration type.
  • Enter your Lambda function name.

Deploy the API:

  • Deploy the API to a stage.
  • Note down the invoke URL, as you’ll need it to call this endpoint.

Step 4: Add Custom Action in Form Flow

Configure your Form Action to Use the API Gateway Endpoint:

  • In your form flow configuration, add a custom action.
  • Use the API Gateway endpoint URL to make a POST request.

Example Configuration:

  • Assuming you’re using a system like Zapier, Integromat, or a custom backend:
{
    "action": "custom",
    "url": "https://your-api-id.execute-api.us-east-1.amazonaws.com/your-stage/your-resource",
    "method": "POST",
    "headers": {
        "Content-Type": "application/json"
    },
    "body": {
        "toEmail": "{{email}}",
        "fromEmail": "your-verified-email@example.com",
        "subject": "Your Subject Here",
        "body": "Your email body here"
    }
}

Step 5: Test Your Integration

  • Submit the Form: Ensure that the form data triggers the action.
  • Check SES: Verify that the email was sent via SES and received by the recipient.

By following these steps, you can configure your custom action to send emails using AWS SES in your Form Flows. GMSocrates This process involves creating a Lambda function to handle the email sending logic, setting up an API Gateway to expose the function, and configuring your form to call this API.

1 Like

Hi @atul.gupta2,

Welcome to the Auth0 Community!

Yes, that’s correct. There are some built-in actions for Forms. However, they do not include one for sending mail using SES.

Currently, there are only built-in actions for sending mail using SendGrid and Mailjet.

If you need to send mail using SES, you might need to write your own custom action form.

For example, you could create an HTTP request action in your flow to make a request to send mail using SES:

For a guide on constructing the request, I would refer to the Amazon SES API docs.

Keep me posted on how this goes for you.

Thanks,
Rueben

Hi @Lorena783lopez,

Thanks for helping on this one!