How to send parsed email data to webhooks
With Parseur you can easily parse text from emails and attachments and send it to any app or server via a webhook. Email to webhook feature can be used in various ways for automating your business workflow and sending data to custom systems.
Let's see how to set up webhooks in Parseur!
What is a webhook?
A webhook is used by application developers and programmers to exchange data between applications and servers. In technical terms, a webhook is an HTTP callback. It is an HTTP POST that gets triggered when something happens. You can view webhooks as a simple event-notification via HTTP POST.
In Parseur a webhook can be triggered when a new document is received and over various types of events. Parseur sends the data extracted text formatted as JSON.
Step 1: Setup your Parseur mailbox
Parseur is free to use for a reasonably low amount of documents to process. If you don’t have one already, let’s go ahead and create an account.
After registration, Parseur asks you to create your first mailbox and setup your templates.
Step 2: Add webhook URL
Open the "create webhook" page
To set up your webhook in Parseur:
- Go to the Export section (on the let menu)
- Click the Webhook tab
- Click the Create a new webhook button
A popup page will appear:
Choose the trigger event
The trigger event determines when to send a webhook and how the payload looks like.
You can choose between:
- Document processed: this is the default and what you need, most of the time. Payload format is the same as when viewing the document and clicking on "view as JSON".
- Document processed (flattened): this choice will only be available if you use table fields in your mailbox. It is useful for endpoints that doesn't support deep JSON structures as it will "flatten" your table fields.
- Template needed: this event is triggered when a document fails to process (status = "New Template Needed"). It can be useful to set up such endpoint to automatically notify your systems there was a problem with parsing (Parseur can also send an email for such event).
- Table item processed: this choice will only be available if you use table fields in your mailbox. When selected, you'll have to choose the table field it relates to. Use this event to send the data as a JSON array of items (one row per table field item, non-table field items repeated on each row).
Choose the target URL
The target URL is the URL where you want to POST your data to. Make sure to use an HTTPS URL to encrypt your data as it transits between servers.
If your target is protected by Basic Authentication, you can add it in the form of https://user:firstname.lastname@example.org/your-api-url and credentials be sent. User name and password will be encoded into a base64 sequence before being sent to the server. This encoding is easily reversible so make sure to use HTTPS to secure the credentials from eavesdropping.
Choose a Name (optional)
You can name this webhook to make it easier for you to remember where the data is sent to.
Add headers (optional)
If your webhook needs specific HTTP headers (like for example an authorization token), add them here. For example, if you need to add token abc-123456-789 to the X-Authorization header, enter the following into the box:
If you need to add several headers, enter one per line.
Note: you don't need to add the Content-Type header, Parseur will automatically add it for you (set to application/json)
You can create as many webhooks for as many triggers as you want.
Step 3: Test your webhook and check the logs
To test your webhook, you can either:
- send a new document
- or reprocess an existing one
Then check the document status on Parseur:
- Processed means your document was correctly extracted and webhook successfully sent
- Export Failed means there was a problem while sending your document
Access the logs to see the details:
- Go to the document list or document view
- Click on the magnifying glass icon, it will open the logs page
- The logs will tell you the story of events for a document
- Click on an event to view the details such as the payload or the error message
Pause / Activate a webhook
You can temporarily put a webhook on pause just by clicking on the pause icon and re-activate it by clicking the play icon. This is useful if you want to make some changes to your server and pause webhooks in the meantime. It is also useful if you want to switch between your development and production servers.
Manage webhooks across different mailboxes
You can easily manage your webhooks across your mailboxes. When you create a webhook, it will be visible in all your mailboxes. By default, created webhook is only activated on the mailbox where you created it (and paused in all the other ones).
This allows you to easily activate and edit the target URL of a webhook across all your mailboxes.
Delete a webhook
You can delete a webhook by clicking on the red trash icon.
Note that deleting a webhook will delete it from all your mailboxes. If you want to remove a webhook from only one mailbox and not others, pause it.
And that is how you do email to webhook! Reach us on the chat for any question.