Sending a PDF to the Mailhook
In this tutorial we are going to send a PDF invoice via email to the mailhook trigger to start the workflow process. The PDF is then going to be read. We are going to use the prebuilt template in the workflows library.
Please download the sample invoice PDF here to use with this tutorial.
- Create the workflow from the templates
On the sidebar, go to Workflows -> Library and search the library for "Receive a PDF invoice 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 PDF data from a list of attachments and finally a document PDF reader to exact the PDF information that can be used with other services:
Although the PDF reader is already set up for the template, if you want to check out
Click of the Document PDF service and open the settings. Select the "PDF" tab and then select the sample file you downloaded in the "Upload Document" section and upload it:
Once it is uploaded, click on "Configure PDF" and then "Start PDF Configuration" which will display how the fields and tables are mapped:
- 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 PDF 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 the PDF 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 PDF in the attachments:
The file data will be encoded but once run through the PDF reader will be visible in the logs. When using the sample PDF you will get the invoice details such as address and who to deliver to along with an array of the ordered items in the invoice:
Although this is a simple example, it could get quite complex. From here you could do anything you wanted with the data such as checking inventory and creating a sales order in various systems.
To summarize, we:
- Created a workflow from the templates
- Prepared the workflow for a mailhook trigger
- Sent a PDF 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.