Home United States USA — software Creating an Email Bot in Apache NiFi Creating an Email Bot in...

Creating an Email Bot in Apache NiFi Creating an Email Bot in Apache NiFi

351
0
SHARE

Learn how to create an email bot in Apache NiFi that sends emails based on subject, body content, attachments, time of day, sender domain, and other variables.
This is the first piece. After this, I will add some Spark Machine Learning to intelligently reply to emails from a list of pre-trained responses. With supervised learning, it will learn what emails to send to whom based on subject, who an email is from, body content, attachments, time of day, sender domain, and many other variables.
For now, it just reads some emails and checks for a hard-coded subject.
I could use this to trigger other processes, such as running a batch Spark job.
Since most people send and use HTML email, I will send and receive HTML emails to make it look more legit.
I could also run my fortune script and return that as my email content, making me sound wise, or pull in a random selection of tweets about Hadoop or even recent news, making the email very current and fresh.
Snippet example of a mixed content email message (attachments removed to save space)
Python script to parse email messages:
mailnifi.sh:
Python needs the email component for parsing the message. You can install this via PIP.
I am using Python 2.7. You could use a newer Python 3.x. I recommend Python 3. See this documentation for more tips.
Here is the flow:
For the final part of the flow, I read the files created by the parsing, load them to HDFS, and delete them from the file system using the standard GetFile.

Continue reading...