A Single Jira Ticket - Templated MessageML

A JIRA integration bot sends a message as a result of a new ticket being created. The message is submitted as V2 MessageML + EntityJSON. The MessageML includes template directives which means that the same MessageML could be submitted with multiple messages containing different EntityJSON representing different JIRA tickets.

MessageML

MessageML
<messageML>
    <div class="entity" data-entity-id="jiraIssueCreated">
        <card class="barStyle">
            <header>
                <img src="${entity['jiraIssueCreated'].issue.priority.iconUrl}"/>
                <a href="${entity['jiraIssueCreated'].issue.url}">${entity['jiraIssueCreated'].issue.key}</a>
                <span>${entity['jiraIssueCreated'].issue.subject} - </span>
                <mention email="${entity['jiraIssueCreated'].user.emailAddress}"/>
                <span class="action">Created</span>
            </header>
            <body>
                <div class="entity" data-entity-id="jiraIssueCreated">
                    <div class="labelBackground badge">
                        <p>
                            <span class="label">Description:</span>
                            <span>${entity['jiraIssueCreated'].issue.description}</span>
                        </p>
                        <p>
                            <span class="label">Assignee:</span>
                            <mention email="${entity['jiraIssueCreated'].issue.assignee.emailAddress}"/>
                        </p>
                    </div>
                    <div class="labelBackground badge">
                        <p>
                            <span class="label">Type:</span>
                            <img src="${entity['jiraIssueCreated'].issue.issueType}"/>
                            <span class="label">Priority:</span>
                            <img src="${entity['jiraIssueCreated'].issue.priority.iconUrl}"/>
                            <span>${entity['jiraIssueCreated'].issue.priority.name}</span>
                            <span class="label">Labels:</span>
                            <#list entity['jiraIssueCreated'].issue.labels as label>
                                <hash tag="${label.text}"/>
                            </#list>
                        </p>
                    </div>
                </div>
            </body>
        </card>
    </div>
</messageML>

EntityJSON

EntityJSON
{
  "jiraIssueCreated": {
    "type": "com.symphony.integration.jira.event.created",
    "version": "1.0",
    "user": {
      "type": "com.symphony.integration.user",
      "version": "1.0",
      "id": 123456,
      "emailAddress": "bot.user01@symphony.com",
      "username": "bot.user01",
      "displayName": "Bot User01"
    },
    "issue": {
      "type": "com.symphony.integration.jira.issue",
      "version": "1.0",
      "key": "SAM-25",
      "url": "https://whiteam1.atlassian.net/browse/SAM-25/",
      "subject": "Issue Test",
      "description": "Only for test",
      "issueType": "Story",
      "labels": [
        {
          "type": "com.symphony.integration.jira.label",
          "version": "1.0",
          "text": "production"
        }
      ],
      "priority": {
        "type": "com.symphony.integration.jira.priority",
        "version": "1.0",
        "iconUrl": "https://whiteam1.atlassian.net/images/icons/priorities/highest.svg",
        "name": "Highest"
      },
      "assignee": {
        "type": "com.symphony.integration.user",
        "version": "1.0",
        "id": 654321,
        "emailAddress": "bot.user02@symphony.com",
        "username": "bot.user02",
        "displayName": "Bot User02"
      }
    }
  }
}

Internal Representation

The API Agent converts the submitted MessageML into PresentationML and expands hastags, cashtags and user mentions into EntityJSON data, generating the following message: A Single Jira Ticket - PresentationML.

Standard Freemarker template macros are used to complete the final PresentationML from the supplied JSON data. Note that value substitution is achieved by syntax like 

${entity["jiraUpdated"].issue.link}

which simply navigates down the JSON structure.

Looping is achieved with syntax like

<#list entity["jiraUpdated"].issue.changeLog.changeList as change>

which iterates over all values of 

entity["jiraUpdated"].issue.changeLog.changeList

Note that the ${} syntax is not needed (or allowed) inside the <#....> </#...> macro markup. Full details of Freemarker are available at http://freemarker.org/

Need help? Email help@finos.org we'll get back to you.

Content on this page is licensed under the CC BY 4.0 license.
Code on this page is licensed under the Apache 2.0 license.