Class SlackFunctions
java.lang.Object
flexagon.fd.services.groovy.functions.BaseFunctions
flexagon.fd.services.groovy.functions.SlackFunctions
- Direct Known Subclasses:
WebhookSlackFunctions
Utility functions used to get information from a Slack payload
- Since:
- 5.3
-
Field Summary
FieldsFields inherited from class flexagon.fd.services.groovy.functions.BaseFunctions
mFLOG -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcleanup()getUserFromSlackId(String pSlackId) Returns the FlexDeploy User corresponding to the given Slack user id.voidpostAttachment(String pSlackAccountCode, String pChannel, File pFile, String pMessage, String pParentMessage) Uploads an attachment to the given Slack channel.voidpostAttachment(String pSlackAccountCode, String pChannel, InputStream pInputStream, String pMessage, String pParentMessage) Uploads an attachment to the given Slack channel.postMessage(String pSlackAccountCode, String pChannel, FlexSlackMessage pMessage) Posts a Slack message using JSON formatted based on Slack API.postMessage(String pSlackAccountCode, String pChannel, String pJson) Posts a Slack message using JSON formatted based on Slack API.postSimpleMessage(String pSlackAccountCode, String pChannel, String pMessageText) Posts a simple Slack message to the specified channel.Methods inherited from class flexagon.fd.services.groovy.functions.BaseFunctions
captureSecureValues, captureSecureValuesForLogFunction, decryptIntegrationInstance, doSimpleGet, findIntegrationInstanceByCode, getBinding, getLogFunctions, getServerBaseUrl, setBinding
-
Field Details
-
APPROVE_STRING
- See Also:
-
REJECT_STRING
- See Also:
-
-
Constructor Details
-
SlackFunctions
-
-
Method Details
-
getUserFromSlackId
public FDUser getUserFromSlackId(String pSlackId) throws FlexCheckedException, FlexNotFoundException Returns the FlexDeploy User corresponding to the given Slack user id. This will only work if the user has added their Slack Id in their FlexDeploy User Profile- Parameters:
pSlackId- The Slack user id. This can be found in the Slack payload from incoming webhook messages.- Returns:
- FlexDeploy User Object.
- Throws:
FlexNotFoundException- If no FlexDeploy user was found for the given Slack id.FlexCheckedException- All other exceptions
-
postAttachment
public void postAttachment(String pSlackAccountCode, String pChannel, InputStream pInputStream, String pMessage, String pParentMessage) throws FlexCheckedException, FlexNotFoundException Uploads an attachment to the given Slack channel. The bot being used should have the file:write scope.- Parameters:
pSlackAccountCode- Messaging account code for Slack account.pChannel- Name or Id of channel where the attachment will be uploaded. Use user channel Id to send direct messages.pInputStream- The input stream to upload.pMessage- Text to display giving context about the attachmentpParentMessage- Parent message/ts id if you wish to post attachment as a reply, leave as null otherwise- Throws:
FlexNotFoundException- If no account is found for give codeFlexCheckedException- Since:
- 5.4
-
postAttachment
public void postAttachment(String pSlackAccountCode, String pChannel, File pFile, String pMessage, String pParentMessage) throws FlexCheckedException, FlexNotFoundException Uploads an attachment to the given Slack channel. The bot being used should have the file:write scope.- Parameters:
pSlackAccountCode- Messaging account code for Slack account.pChannel- Name or Id of channel where the attachment will be uploaded. Use user channel Id to send direct messages.pFile- The file to upload.pMessage- Text to display giving context about the attachmentpParentMessage- Parent message/ts id if you wish to post attachment as a reply, leave as null otherwise- Throws:
FlexNotFoundException- If no account is found for give codeFlexCheckedException- Since:
- 5.4
-
postMessage
public String postMessage(String pSlackAccountCode, String pChannel, FlexSlackMessage pMessage) throws FlexCheckedException Posts a Slack message using JSON formatted based on Slack API.- Parameters:
pSlackAccountCode- Messaging account code for Slack account.pChannel- Name or Id of channel where the notification will be sent. Use user channel Id to send direct messages.pMessage- FlexSlackMessage to post. Formatted based on Slack API.- Returns:
- Slack ts message value. This string can be used to reply to this message or start a thread
- Throws:
FlexCheckedException- Since:
- 5.4
-
postMessage
public String postMessage(String pSlackAccountCode, String pChannel, String pJson) throws FlexCheckedException Posts a Slack message using JSON formatted based on Slack API.- Parameters:
pSlackAccountCode- Messaging account code for Slack account.pChannel- Name or Id of channel where the notification will be sent. Use user channel Id to send direct messages.pJson- Json string of your Slack message body. Formatted based on Slack API.- Returns:
- Slack ts message value. This string can be used to reply to this message or start a thread
- Throws:
FlexCheckedException- Since:
- 5.4
-
postSimpleMessage
public String postSimpleMessage(String pSlackAccountCode, String pChannel, String pMessageText) throws FlexCheckedException Posts a simple Slack message to the specified channel. Slack account code that is passed must have the bearer token which is generated by Slack after adding the app to the workspace.- Parameters:
pSlackAccountCode- Messaging account code for Slack account.pChannel- Name or Id of channel where the notification will be sent. Use user channel Id to send direct messages.pMessageText- Text for the message that will be sent.- Throws:
FlexNotFoundExceptionFlexCheckedException- Since:
- 5.4
-
getGroovyKey
- Specified by:
getGroovyKeyin classBaseFunctions
-
cleanup
public void cleanup()- Specified by:
cleanupin classBaseFunctions
-