Integrations
Inbox for JIRA supports:
- custom renderer from JEditor
- approvals from JIRA Service Desk.
Something missing? Please raise a request here Rixter Portal and will see to it being added to the product.
As of Inbox for Jira version 4.2 it's possible to interact with the Inbox using API. There are two ways; either via REST
or via the exported service "NotificationService
"
Use the API to notify users outside of the regular Jira event stream. Useful for scenarios such as when you programmatically change something and wish to notify a user of that change.
REST API
Http Request
Request specifications for calling Inbox API
URL
HTTPS_YOUR_JIRA_INSTANCE_URL/rest/inbox/1.0/notification/message/{user_name_to_notify}
METHOD:
HTTP POST
RESPONSE
HTTP 200 OK if successful
Example:
https://your.jira.instance.com/rest/inbox/1.0/notification/message/ratkm
PAYLOAD
Json body payload:
{
"phrase" = Notification header phrase, can include HTML and keywords
"text" = The notificartion text
"issueKey" = The issue the noitification is about. Optional. Can be omitted if no issue is related the notificaiton
}
Keywords
{actor}
= prints the actor's name. The actor is the one that the notification is from. The actor is per default the logged-in user that requests this endpoint. See the Authentication below.
{target-user}
= prints the target user name. The target user is the notification receiver
{issue}
= prints the issue with HTTP link to the issue
Example
POST body example:
{
"phrase" : "{actor} sent a <b>message</b> to {target-user} regarding {issue}",
"text" : "You have been added to this issue",
"issueKey" : "JIRAKEY-1"
}
AUTHENTICATION
The authentication is based on JIRA Basic auth authentications. The user credentials used for authentication will be the {actor}
(notification sender) mentioned above.
JAVA API
Use the java service "NotificationService
" for scripted integration such as using Groovy.
GROOVY EXAMPLES
import com.atlassian.jira.component.ComponentAccessor; import com.atlassian.jira.event.type.EventType; //Get hold of NotificationService Class notificationService = ComponentAccessor.getPluginAccessor().getClassLoader().findClass("com.inboxforjira.api.NotificationService"); def notificationServiceInstance = ComponentAccessor.getOSGiComponentInstanceOfType(notificationService); //Get Application users def fromUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser() def toUser = ComponentAccessor.getUserManager().getUserByName("sven") //Get comment last def lastComment = ComponentAccessor.getCommentManager().getLastComment(issue) String message = "" //Example 1. Send message without an issue message = "Hello without an issue!" notificationServiceInstance.notifyInboxWithCustomMessage(fromUser.getId(),toUser.getId(),null,"{actor} sent {target-user} a message",message) //Example 2. Send message without an issue message = "Hello with an issue!" notificationServiceInstance.notifyInboxWithCustomMessage(fromUser.getId(),toUser.getId(),issue.getKey(),"{actor} sent {target-user} a message on {issue}",message) //Example 3. Notify as an event has been triggered notificationServiceInstance.notifyInbox(fromUser.getId(),toUser.getId(),issue.getKey(),EventType.ISSUE_ASSIGNED_ID ) //Example 4. Notify as an event has been triggered notificationServiceInstance.notifyInboxWithComment(fromUser.getId(),toUser.getId(),issue.getKey(),EventType.ISSUE_COMMENTED_ID,lastComment.getId() ) //Example 3. Notify as an event has been triggered notificationServiceInstance.notifyInbox(fromUser.getId(),toUser.getId(),issue.getKey(),EventType.ISSUE_ASSIGNED_ID ) //Example 4. Notify as an event has been triggered notificationServiceInstance.notifyInboxWithComment(fromUser.getId(),toUser.getId(),issue.getKey(),EventType.ISSUE_COMMENTED_ID,lastComment.getId() )
Javadoc specification
NotificationService notifyInboxWithCustomMessage
/** * Notify a Inbox user programmatically using the API * * @param fromUserId User Id of the user that notifies another this user, required * @param toUserId User Id of user to notify, required * @param issueKey Issue Key, optional. Null if not used. * @param phrase The notification header phrase. Use keywords and html in phrase. * Null for default message. * * Keywords: * {actor} = the one that sends the notification message * {target-user} = the user that receives the notification * {issue} = the issue * * Example: {actor} sent {target-user} a message regarding {issue} * @param message The notification message. Message text can contain html. * @throws NullPointerException if fromUser, toUser or message is null * @throws IllegalArgumentException if users does not exist * @throws IllegalArgumentException if issue key is provided but does not exist */ public void notifyInboxWithCustomMessage(Long fromUserId, Long toUserId, String issueKey, String phrase, String message);
NotificationService notifyInbox
/** * Notify a Inbox user programmatically using the API * @param fromUserId User Id of the user that notifies another this user, required * @param toUserId User Id of user to notify, required * @param issueKey Issue Key, required * @param eventTypeId Issue Event type id see @{@link com.atlassian.jira.event.type.EventType} , required * @throws NullPointerException if fromUser, toUser or message is null * @throws IllegalArgumentException if users does not exist * @throws IllegalArgumentException if issue does not exist */ public void notifyInbox(Long fromUserId, Long toUserId, String issueKey, long eventTypeId);
NotificationService notifyInbox
/** * Notify a Inbox user programmatically using the API * @param fromUserId User Id of the user that notifies another this user, required * @param toUserId User Id of user to notify, required * @param issueKey Issue Key, required * @param eventTypeId Issue Event type id see @{@link com.atlassian.jira.event.type.EventType, required * @param commentId Id of issue comment related to this notification. -1 if no comment related. * @throws NullPointerException if fromUser, toUser or message is null * @throws IllegalArgumentException if users does not exist * @throws IllegalArgumentException if issue does not exist */ public void notifyInboxWithComment(Long fromUserId, Long toUserId, String issueKey, long eventTypeId, long commentId);