Question on sml:SendEMails module

58 views
Skip to first unread message

Sanjeev Devireddy

unread,
Nov 6, 2019, 8:54:04 AM11/6/19
to TopBraid Suite Users
Hi,

  Is there any example project/document on how to use sml:SendEMails module to send email notifications using the instances of email:Message?


Thanks,
Sanjeev

TopQuadrant Support

unread,
Nov 6, 2019, 2:37:03 PM11/6/19
to TopBraid Suite Users
Hi Sanjeev,

If you have already created the instances of email:Message, then you can simply send them like this:

<sml:SendEMails/>

The module will take the instances from the current graph context and send them using the SMTP server parameters set up in Server Administration.

If you need a more complete example, EDG uses this module internally to send notifications.  For example, when using the Tasks feature, there is a ui:Method called whenever a change is made to a task:

<ui:setContext ui:queryGraph=\"{= IRI(CONCAT(str(ui:tempGraph), ui:uniqueId())) }\">
   
<ui:update ui:updateQuery=\"{!
            INSERT {
                ?message a email:Message .
                ?message email:subject ?subject .
                ?message email:body ?body .
                ?message email:from ?from .
                ?message email:to ?to .
                ?from email:address ?sender .
                ?to a email:Address .
                ?to email:address ?email .
            }
            WHERE {
                BIND (BNODE() AS ?message) .
                BIND (BNODE() AS ?from) .
                BIND (BNODE() AS ?to) .
                BIND (CONCAT(&quot;[TopBraid Tasks] Update: &quot;, ?title) AS ?subject) .
                BIND (CONCAT(?header, ?text) AS ?body) .
                BIND (teamwork:getFromAddress() AS ?fromAddress) .
                BIND (COALESCE(?fromAddress, &quot;noreply@example
.com&quot;) AS ?sender) .
            } }\"
/>
   
<sml:SendEMails/>
</ui:setContext>


Hope this helps!

Sanjeev Devireddy

unread,
Nov 15, 2019, 9:30:41 AM11/15/19
to TopBraid Suite Users
Hi,

    As of now I am still trying to understand how the instances of email:Message can be created. Actually I am looking for an example, which helps me to understand where to start and how to implement email notifications using different methods/modules available in composer.


Thanks,
Sanjeev

Holger Knublauch

unread,
Nov 15, 2019, 7:41:40 PM11/15/19
to topbrai...@googlegroups.com

As a general technique to find examples, look at the EDG implementation itself. For example, open edg.topbraidlive.org/1.0/collection/COLLECTION_EDG-all-...ttl and then select email:Message and Find References. One of them is in teamwork:sendNotifications:

<ui:setContext let:body="{= ?header }{= ?text }{= ?footer }"


                       ui:queryGraph="{= IRI(CONCAT(str(ui:tempGraph), ui:uniqueId())) }">

            <ui:forEach ui:resultSet="{#
                    SELECT DISTINCT ?email
                    WHERE {
                        ( ?property ?projectGraph ) teamwork:partyInGovernanceRoleAtProjectGraph ?party .
                        ?party teamwork:workflowParticipantEmails ?email .


                    } }">
                <ui:update ui:updateQuery="{!
                        INSERT {
                            ?message a email:Message .

                            ?message email:subject ?title .


                            ?message email:body ?body .
                            ?message email:from ?from .
                            ?message email:to ?to .

                            ?from a email:Address .


                            ?from email:address ?sender .
                            ?to a email:Address .
                            ?to email:address ?email .
                        }
                        WHERE {
                            BIND (BNODE() AS ?message) .
                            BIND (BNODE() AS ?from) .
                            BIND (BNODE() AS ?to) .

                            BIND (teamwork:singularProjectTypeLabel(teamwork:getProjectType(?projectGraph)) AS ?typeLabel) .
                            BIND (swa:labelInGraph(?notification, ui:graph) AS ?rawLabel) .
                            BIND (CONCAT(&quot;[TopBraid] Notification: &quot;, spif:replaceAll(?rawLabel, &quot;Vocabulary&quot;, ?typeLabel)) AS ?title) .


                            BIND (teamwork:getFromAddress() AS ?fromAddress) .

                            BIND (COALESCE(?fromAddress, &quot;nor...@topquadrant.com&quot;) AS ?sender) .
                        } }"/>
            </ui:forEach>
            <sml:SendEMails/>
        </ui:setContext>

HTH
Holger

--
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topbraid-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/a05f58e5-a548-4833-8466-ecef8f56327a%40googlegroups.com.

Sanjeev Devireddy

unread,
Feb 17, 2020, 2:25:35 AM2/17/20
to TopBraid Suite Users
Hi Holger,
      Thanks for your response. Please check my queries below.

       From the above example it looks like that the variable named "body" contains the body of the email and that is fine. But why different Graphs are queried and/or updated to send email notification is still a question for us? Could you please help us to understand it better?

       Our requirement is to send a simple/custom email notification whenever a taxonomy is updated. For that, we first implemented an event listener (by extending teamwork:EditRules) to capture the taxonomy changes/updates. Now, we are trying to read those already captured events and send custom email notifications. Is there any simple way to send email notifications unlike the above example given above, which involves querying/updating other graphs?

Thanks,
Sanjeev

Holger Knublauch

unread,
Feb 17, 2020, 2:53:12 AM2/17/20
to topbrai...@googlegroups.com

Hi Sanjeev,

so the update happens to populate a temp graph with the email that shall be sent. For example the variable values for ?body become ?message email:body ?body triples in the temp query graph.

The SELECT DISTINCT loop is just there to iterate over all email addresses. At the end of the loop, the temp graph contains one email:Message instance for each workflow participant email. That technique is the only way to send emails, unless you want to somehow bypass TopBraid and use your in-house email services directly (e.g. with a sml:PostRequest).

In your case you can probably build an email from the ui:addedGraph and ui:deletedGraph triples in your EditRule?

Holger

--
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topbraid-user...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages