How to create an API REST to send e-mails with FlowEngine?
This tutorial will show how to create, from the FlowEngine, a REST API to send e-mails.
In this case, you will create the API and the API will be public. Follow these steps:
- Select "My Digital Flows" in the menu DEVELOPMENT:
- Select the domain that belongs to your user (or create it if you donf´t have created it before):
- Once in the domain, drag a node of "OnesaitPlatform API REST" type to the flow to create the API. Fill in the properties, checking the box "is Public".
- Now drag to the flow a node of "OnesaitPlatform API REST operation" type. Link this node to the previous API node, and fill in the properties as shown next:
For this example, the information about recipient, sender, subject and message body will be provided as data in a POST request. - Once the operation is defined, let's prepare the logic of sending mail. Process the data received for the POST request, and prepare them to call the MailGun API. You can do all this in a "Function" type node:
- Once the input data is ready, pass them to a "Http request" type node. With this node, you will send the mail sending request to MailGun. Following the MailGun API specifications, fill in the properties like this:
- To end the flow, you need to return a reply to the initial operation call. For this example, it will be enough if you return what the MailGun API returns to your request. Drag a node "OnesaitPlatform API REST operation response" type and connect it to the previous node output:
- You only need now to deploy the changes for the API to register. TO do this, click on the "deploy" button:
Having reached this point, your API is created and ready to be used, as any other API in the platform:
, multiple selections available,