Trigger Business Process Via Email

Hello guys,

i would like to know if we can start automatically a process once we receive an email. in case it is possible please share documentation to implement this activity.

Thanks,

Comments

  • jpluimers
    jpluimers E Community Moderator

    @MAGE , that is possible with the Email connector. The documentation for that is a bit hidden though.

    High level steps are to add a new trigger to the <triggers> section in the email connector config, which has a rules section and a message section.
    In the AppWorks Platform Administration Guide search see section 'Configuring the E-mail connector' and scroll down till 'See the sample configuration XML for the Email box configuration', which shows an example for the email connector to trigger a method called receiveEmail.

    A trigger has a rules config part to define which fields from an email are extracted from the email. And a <message> part which defines which AppWorks webservice to executed. The webservice is called via the <namespace> and <method> combination. The <mappings> section defines what data is passed to the webservice.
    Keep the receiveEmail config intake, just copy it and update.

    You can for example create a BPM process and expose that as a webservice and have that called when an email is received.

  • @jpluimers thanks for your response. Am going to apply your tips.

  • Hello @jpluimers

    I have applied your suggestion but am facing this problem below when we restart the container. Find attached my xml configuration

    .

    However note that the connection to the mail server is not stable. Sometime i get this issue when i try to execute for example the getMail ws. Find attached the full log file.

    Thanks in advance,

  • @MAGE ,In the attached mailbox configuration,2 trigger definitions are mentioned inside triggers.Please remove one of them and try the scenario.

    Below are the sample configuration details for classic pop3.

  • @MAGE ,In the attached mailbox configuration,2 trigger definitions are mentioned inside triggers.Please remove one of them and try the scenario.

    Below are the sample configuration details for classic pop3

  • Thanks @Polepalli Subhashini

    i will take consideration your inputs.

  • MAGE
    edited August 18, 2023 #8

    @Polepalli Subhashini please can we know how into your mailbox configuration you addressed the bpm web service to be called. below it is my configuration but the process is not executed.:

    <emailboxes xmlns="http://schemas.cordys.com/1.0/email/configuration">
    <emailbox>
    <name>Development</name>
    <username>ag02@pgi.com</username>
    <password>Start123</password>
    <folders>
    <folder>INBOX</folder>
    </folders>
    <triggers>
    <trigger appliesTo="INBOX">
    <name>AllFolders</name>
    <rules>
    <rule section="SUBJECT">
    <pattern type="REGEX">
    <value>.+</value>
    <store>
    <token>
    <name>Subject</name>
    <value>0</value>
    </token>
    </store>
    </pattern>
    </rule>
    <rule section="TO">
    <pattern type="REGEX">
    <value>.+</value>
    <store>
    <token>
    <name>To</name>
    <value>0</value>
    </token>
    </store>
    </pattern>
    </rule>
    <rule section="FROM">
    <pattern type="REGEX">
    <value>.+</value>
    <store>
    <token>
    <name>From</name>
    <value>0</value>
    </token>
    </store>
    </pattern>
    </rule>
    <rule section="MULTIPART">
    <pattern type="CUSTOM">
    <value>com.eibus.applicationconnector.email.sample.Base64Plugin</value>
    <store>
    <token>
    <name>Base64Attachment</name>
    <value>string</value>
    </token>
    </store>
    </pattern>
    </rule>
    </rules>
    <message>
    <method>IncomingCorrespondence</method>
    <namespace>http://schemas.cordys.com/default</namespace>
    <user>cn=cheikh,cn=organizational users,o=PGI,cn=cordys,cn=appworkinst,o=planetgroupint.com</user>
    <sync>true</sync>
    <namespacemappings>
    <namespacemapping>
    <prefix>ns</prefix>
    <namespace>http://schemas.cordys.com/default</namespace>
    </namespacemapping>
    </namespacemappings>
    <input xmlns:ns="http://schemas.cordys.com/bpm/execution/1.0">
    <ns:src />
    <ns:subject />
    <ns:content />
    </input>
    <mappings xmlns:tns="http://schemas.cordys.com/1.0/email/configuration">
    <mapping>
    <source>.//subject</source>
    <value src="Subject" />
    <source>.//src</source>
    <value src="To" />
    <source>.//content</source>
    <value src="Base64Attachment" />
    </mapping>
    </mappings>
    </message>
    </trigger>
    </triggers>
    <automaticrestart xmlns:tns="http://schemas.cordys.com/1.0/email">true</automaticrestart>
    <restartinprogress xmlns:tns="http://schemas.cordys.com/1.0/email/configuration">false</restartinprogress>
    </emailbox>
    </emailboxes>

    Thanks,

  • jpluimers
    jpluimers E Community Moderator

    The <method> and <namespace> determine the webservice that is called.
    In your case that will be:

    <method>IncomingCorrespondence</method>
    <namespace>http://schemas.cordys.com/default</namespace>

    And it will be called with below three input parameters:
    <input xmlns:ns="http://schemas.cordys.com/bpm/execution/1.0">
    <ns:src/>
    <ns:subject/>
    <ns:content/>
    </input>

    The email connector will send a request something like this:

    <SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
    <SOAP:Body>
    <IncomingCorrespondence xmlns="http://schemas.cordys.com/default">
    <src>PARAMETER/src>
    <subject>PARAMETER/subject>
    <content>PARAMETER/content>
    </IncomingCorrespondence>
    </SOAP:Body>
    </SOAP:Envelope>

    Try to execute that to see if it start the BPM process.
    I expect that the email connector logfile also will contain some info about the execution of the web-service. Maybe it will give more when you enable DEBUG loglevel.

  • @jpluimers below you see my ws , it run the process when i invoke the it. But unfortunately from the email connector the ws is not invoked. i have not any data from the log file for helping.

    maybe my emailbox configuration is not ok. i will have a deeper look.

    thanks you really.