Sending a CSV to the Mailhook
In this tutorial we are going to send a CSV via email to the mailhook trigger to start the workflow process. The CSV is then going to be parsed. We are going to use the prebuilt template in the workflows library.
You can use any CSV file for this tutorial or you can download a sample CSV file here. The sample CSV file just contains a list of countries with related regional information.
- Create the workflow from the templates
On the sidebar, go to Workflows -> Library and search the library for "Receive a CSV file via email":
Click on "Create Workflow" and create the workflow in your desired project. The workflow will automatically load once created and will show a start service which will have the email data, a mapper to extract the CSV data from a list of attachments and finally a parser to convert the file data into an array that can be used with other services:
- Prepare the workflow for the mailhook trigger
Next click into the workflow settings by clicking on the workflow COG on the canvas or "Edit Workflow" from the orange button in the top right corner. Once the workflow config is open, click on "Triggers" and scroll down toward the bottom where you should see Mailhook and enable it:
Copy the email address that is generated and save the workflow using the orange button in the top right corner.
- Send the CSV via email
Now that the workflow is configured to receive email triggers from the mailhook, use the copied email address to create a new email and attach a CSV file (you can use the sample from earlier) to it. Next send the email and wait for the workflow to start; it could take a couple of minutes to come through.
- Review the runtime
Once the runtime has stopped you will be able to view the logs to show the output at each stage. In the start service, you'll see the email which will contain information such as sender and subject but also show the CSV in the attachments:
The file data will be encoded but once run through the CSV parser will be visible in the logs. If you used the sample CSV it will output a list of countries in an array for each line of the CSV:
Although this is a simple example, it could get quite complex. From here you could do anything you wanted with the data such as importing it into various systems.
To summarize, we:
- Created a workflow from the templates
- Prepared the workflow for a mailhook trigger
- Sent a CSV to an email address and let the workflow run
- Reviewed the output of the workflow in the runtime logs
Feel free to reach out in the chat if you have any comments or questions.