Hello everyone,
We hope to present the various Zoho services that support Deluge through a series of posts. In today's post let us explore Deluge in Zoho Mail.
Filters
is the
Zoho Mail
feature that encompasses Deluge. When a Deluge function is associated with a Zoho Mail filter, the configured filter criteria acts as a rule based on which the Deluge function will be triggered.
Example
Let's assume a vendor sends invoices of your purchases to your email from
vendor@zylker.com
. Whenever you receive the invoice email, you post the
invoice ID, invoice date,
and
Total amount
details in a Zoho Cliq channel. However, manually posting the invoice details in a channel is not only monotonous but also could lead to accidental blunders or any manipulation of data. To overcome this, Deluge can be used to automate the whole process. All the invoices follow the below structure.
Follow the below steps to achieve the mentioned automation.
Step 1: Navigate to Deluge
1. Click settings icon on the right pane and click Create New Incoming Filter from the Filters card.
2. A Deluge function needs to be triggered whenever a mail is received from
vendors@zylker.com
. Hence, provide the following filter conditions, choose
Custom function (Creator)
under Actions, and click
Select Function.
3. A popup window with
Deluge custom function
, frequently used Deluge functions as
gallery functions
and
Deluge's connections page
will be displayed.
Step 2: Script using Deluge
1. Navigate to
DRE Connectors tab
and create a Zoho OAuth
connection
with scopes
ZohoMail.messages.READ
and
ZohoCliq.Webhooks.CREATE
. Name the connection as
extractandpost
.
Note:
This connection is used to authenticate the Zoho Cliq account in which the message will be posted.
2. Navigate to Custom function tab, write the following script, and click Save. You can use the Test Run button to execute your script for a specific email.
-
// Fetch message details using
Zoho Mail integration task
-
messageDetails = zoho.mail.getMessage(mail_messageId, "extractandpost");
-
-
//
Get
the mail content
-
mailContent = messageDetails.get("CONTENT");
-
-
// Handle the returned text to structure it in a valid XML format
-
mailContent = mailContent.replaceAll("<meta />","");
-
mailContent = mailContent.replaceAll(" ","");
-
-
// Use
XPath to fetch
the required details from the XML
-
invoiceId = mailContent.executeXPath("/div/div/div/div[7]/text()");
-
invoiceDate = mailContent.executeXPath("/div/div/div/div[8]/text()");
-
invoiceTotal = mailContent.executeXPath("/div/div/div/div[13]/text()");
-
-
// Format the fetched details to post in Zoho Cliq channel
-
textToPost = "Zylker invoice\nInvoice ID: " + invoiceId + "\nInvoice Date: " + invoiceDate + "\nTotal: " + invoiceTotal;
-
-
// Post the formatted text in the required
Zoho Cliq Channel
-
zoho.cliq.postToChannel("OrdersChannel", textToPost, "extractandpost");
3. Click
Select Custom Function
button to associate the function with the Filter.
Step 3: Save the filter
Now that the configuration is done, if an email is received from
vendors@zylker.com
, the mail content will be parsed and the required details will be posted in Zoho Cliq Channel automatically.
Note:
This example assumes emails from
vendors@zylker.com
always follow the same email template. The XML handling and XPath used in the provided example script is specific to this email template.
Please check the attachments for the sample XML file based on which the provided example script works.
We hope you found this post useful. We will explore Deluge in Zoho Writer in the next post. Please let us know your questions, feedback, and suggestions in the comments or write to us at
support@zohodeluge.com
.
Stay safe!
Related Links