Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

 

In this tutorial, we will follow the guideline for developing a plugin to develop our Slack Webhook Tool plugin. Please also refer to the very first tutorial 如何开发一个Bean Shell Hash Variable插件 for more details steps.

1. What is the problem?

We want to send message to Slack when something is completed in Joget Workflow.

2. How to solve the problem?

We will develop a 流程工具/POST表单提交处理插件 to send message to Slack

3. What is the input needed for your plugin?

To develop a Slack Webhook Tool plugin, we will consider providing the parameters available in Slack Incoming Webhook as our plugin input.

4. What is the output and expected outcome of your plugin?

When the tool is execute, a message will send to Slack based on the configuration.

5. Are there any resources/API that can be reused?

We can use slack-webhook library to integrate with Slack.

6. Prepare your development environment

We need to always have our Joget Workflow Source Code ready and builded by following this guideline

The following tutorial is prepared with a Macbook Pro and the Joget Source Code is version 5.0.1. Please refer to the 如何开发插件 article for other platform commands.

在本教程中,我们将遵循开发插件  来开发我们的Slack Webhook工具插件的  指导原则。 有关更多详细信息步骤,请参阅第一个教程  如何开发一个Bean Shell哈希变量插件

1.什么问题?

当在Joget Workflow中完成某些事情时,我们要发送消息给Slack

2.如何解决问题?

我们将开发一个  流程工具/ POST表单提交处理插件  发送消息给Slack。 

3.你的插件需要什么输入?

为了开发一个Slack Webhook工具插件,我们将考虑提供Slack Incoming Webhook中可用的参数   作为我们的插件输入。

4.你的插件的输出和预期结果是什么?

工具执行时,会根据配置将消息发送到Slack。

5.是否有任何资源/ API可以重复使用?

我们可以使用  slack-webhook库来与Slack集成。

6.准备你的开发环境

我们需要始终准备好Joget Workflow Source Code,并按照这个指导方针建立起来  。 

下面的教程是用Macbook Pro编写的,Joget源代码是5.0.1版本。 其他平台命令请参阅  如何开发插件文章。

假设我们的文件夹目录如下所示。 Let's say our folder directory is as follows. 

Code Block
- Home
  - joget
    - plugins
    - jw-community
      -5.0.1

The "plugins" directory is the folder we will create and store all our plugins and the "jw-community" directory is where the Joget Workflow Source code is stored.

  - jw-community
      -5.0.1

“插件”目录是我们将创建和存储我们所有插件的文件夹,“jw-community”目录是Joget Workflow源代码的存储位置。

运行以下命令在“plugins”目录下创建一个maven项目。Run the following command to create a maven project in "plugins" directory.

Code Block
languagebash
cd joget/plugins/
~/joget/jw-community/5.0.1/wflow-plugin-archetype/create-plugin.sh org.joget slack_webhook 5.0.1

Then, the shell script will ask us to key in a version number for the plugin and ask us for a confirmation before it generates the maven project.然后,shell脚本会要求我们输入插件的版本号,并在生成maven项目之前要求我们确认。

Code Block
languagebash
Define value for property 'version':  1.0-SNAPSHOT: : 5.0.0
[INFO] Using property: package = org.joget
Confirm properties configuration:
groupId: org.joget
artifactId: slack_webhook
version: 5.0.0
package: org.joget
Y: : y

We should get a "BUILD SUCCESS" message shown in our terminal and a "slack_webhook" folder created in the "plugins" folder.

我们应该在终端上显示“BUILD SUCCESS”消息,在“plugins”文件夹中创建一个“slack_webhook”文件夹。

用你最喜欢的IDE打开maven项目。我将使用  NetBeansOpen the maven project with your favourite IDE. I will be using NetBeans.  

7. Just code it!

a.

...

扩展插件类型的抽象类

在“org.joget”包下创建一个“SlackWebhookTool”类。然后,使用Create a "SlackWebhookTool" class under "org.joget" package. Then, extend the class with org.joget.plugin.base.DefaultApplicationPlugin abstract class. Please refer to 抽象类来扩展  该类。请参考  流程工具/ POST表单提交处理插件. We will need to implement 。我们还需要实现  org.joget.plugin.base.PluginWebSupport interface class as well to provide a send test message button in plugin properties page. Please refer to Web Service 插件.

b. Implement all the abstract methods

接口类,并在插件属性页面提供一个发送测试消息按钮。请参考  Web服务插件

b. 实现所有的抽象方法

像往常一样,我们必须执行所有的抽象方法。我们将使用AppPluginUtil.getMessage方法来支持i18n,并使用常量变量MESSAGE_PATH作为消息资源包目录。As usual, we have to implement all the abstract methods. We will using AppPluginUtil.getMessage method to support i18n and using constant variable MESSAGE_PATH for message resource bundle directory.

Code Block
languagejava
titleImplementation of all basic abstract methods
collapsetrue
package org.joget;
 
import org.joget.apps.app.service.AppPluginUtil;
import org.joget.apps.app.service.AppUtil;
import org.joget.plugin.base.DefaultApplicationPlugin;
import org.joget.plugin.base.PluginWebSupport;
 
public class SlackWebhookTool extends DefaultApplicationPlugin implements PluginWebSupport {
    private final static String MESSAGE_PATH = "message/SlackWebhookTool";
    
    @Override
    public String getName() {
        return "Slack Webhook Tool";
    }
    @Override
    public String getVersion() {
        return "5.0.0";
    }
    
    @Override
    public String getClassName() {
        return getClass().getName();
    }
    
    @Override
    public String getLabel() {
        //support i18n
        return AppPluginUtil.getMessage("org.joget.SlackWebhookTool.pluginLabel", getClassName(), MESSAGE_PATH);
    }
    @Override
    public String getDescription() {
        //support i18n
        return AppPluginUtil.getMessage("org.joget.SlackWebhookTool.pluginDesc", getClassName(), MESSAGE_PATH);
    }
    
    @Override
    public String getPropertyOptions() {
        return AppUtil.readPluginResource(getClass().getName(), "/properties/slackWebhookTool.json", null, true, MESSAGE_PATH);
    }
}

Now, we have to create a UI for admin user to provide inputs for our plugin. In getPropertyOptions method, we already specify our 插件属性选项与配置 definition file is located at "/properties/slackWebhookTool.json". Let us create a directory "resources/properties" under "slack_webhook/src/main" directory. After creating the directory, create a file named "slackWebhookTool.json" in the "properties" folder.

现在,我们必须为管理员用户创建一个UI,为我们的插件提供输入。在getPropertyOptions方法中,我们已经指定了我们的  插件属性选项和配置  定义文件位于“/properties/slackWebhookTool.json”。让我们在“slack_webhook / src / main”目录下创建一个目录“resources / properties”。创建目录后,在“properties”文件夹中创建一个名为“slackWebhookTool.json”的文件。

在属性定义选项文件中,我们需要提供如下的选项。请注意,我们可以在我们的属性选项中使用“@@ message.key @@”语法来支持i18n。In the properties definition options file, we will need to provide options as below. Please note that we can use "@@message.key@@" syntax to support i18n in our properties options.

Code Block
languagejs
[{
    title : '@@SlackWebhookTool.config@@',
    properties : [{
        name : 'url',
        label : '@@SlackWebhookTool.url@@',
        type : 'textfield',
        required : 'true'
    },
    {
        label : '@@SlackWebhookTool.from@@',
        type : 'header'
    },
    {
        name : 'username',
        label : '@@SlackWebhookTool.fromUsername@@',
        type : 'textfield',
        value : '@@SlackWebhookTool.fromUsername.value@@'
    },
    {
        name : 'customIcon',
        label : '@@SlackWebhookTool.customIcon@@',
        type : 'selectbox',
        value : 'joget',
        options : [{
            value : '',
            label : '@@SlackWebhookTool.customIcon.none@@'
        },
        {
            value : 'joget',
            label : '@@SlackWebhookTool.customIcon.joget@@'
        },
        {
            value : 'url',
            label : '@@SlackWebhookTool.customIcon.url@@'
        },
        {
            value : 'emoji',
            label : '@@SlackWebhookTool.customIcon.emoji@@'
        }]
    },
    {
        name : 'iconUrl',
        label : '@@SlackWebhookTool.customIcon.url@@',
        type : 'textfield',
        required : 'true',
        control_field: 'customIcon',
        control_value: 'url',
        control_use_regex: 'false'
    },
    {
        name : 'iconEmoji',
        label : '@@SlackWebhookTool.customIcon.emoji@@',
        type : 'textfield',
        required : 'true',
        control_field: 'customIcon',
        control_value: 'emoji',
        control_use_regex: 'false'
    },
    {
        label : '@@SlackWebhookTool.to@@',
        type : 'header'
    },
    {
        name : 'channels',
        label : '@@SlackWebhookTool.channels@@',
        description : '@@SlackWebhookTool.channels.desc@@',
        type : 'textfield'
    },
    {
        name : 'participantIds',
        label : '@@SlackWebhookTool.participantIds@@',
        description : '@@SlackWebhookTool.participantIds.desc@@',
        type : 'textfield'
    },
    {
        name : 'usernames',
        label : '@@SlackWebhookTool.usernames@@',
        description : '@@SlackWebhookTool.usernames.desc@@',
        type : 'textfield'
    },
    {
        name : 'usernameTransform',
        label : '@@SlackWebhookTool.usernameTransform@@',
        description : '@@SlackWebhookTool.usernameTransform.desc@@',
        type : 'textfield',
        value : '@@SlackWebhookTool.usernameTransform.value@@',
        required : 'True'
    },
    {
        label : '@@SlackWebhookTool.message@@',
        type : 'header'
    },
    {
        name : 'text',
        label : '@@SlackWebhookTool.text@@',
        description : '@@SlackWebhookTool.text.desc@@',
        type : 'codeeditor',
        required : 'True'
    },
    {
        name : 'unfurl_links',
        label : '@@SlackWebhookTool.unfurl_links@@',
        description : '@@SlackWebhookTool.unfurl_links.desc@@',
        type : 'checkbox',
        value : 'true',
        options : [{
            value : 'true',
            label : ''
        }]
    },
    {
        name : 'unfurl_media',
        label : '@@SlackWebhookTool.unfurl_media@@',
        description : '@@SlackWebhookTool.unfurl_media.desc@@',
        type : 'checkbox',
        value : 'true',
        options : [{
            value : 'true',
            label : ''
        }]
    }],
    buttons : [{
        name : 'sendTestMessage',    
        label : '@@SlackWebhookTool.sendTestMessage@@',
        ajax_url : '[CONTEXT_PATH]/web/json/app[APP_PATH]/plugin/org.joget.SlackWebhookTool/service?action=sendTestMessage',
        fields : ['url'],
        addition_fields : [
            {
                name : 'testChannel',
                label : '@@SlackWebhookTool.sendTestMessage.testChannel@@',
                type : 'textfield'
            }
        ]
    }]
},
{
    title : '@@SlackWebhookTool.attachment@@',
    properties : [{
        name:'fallback',
        label:'@@SlackWebhookTool.attachment.fallback@@',
        description:'@@SlackWebhookTool.attachment.fallback.desc@@',
        type:'textfield',
        value: '@@SlackWebhookTool.attachment.fallback.value@@',
        required : 'True'
    },
    {
        name:'color',
        label:'@@SlackWebhookTool.attachment.color@@',
        description:'@@SlackWebhookTool.attachment.color.desc@@',
        type:'textfield'
    },
    {
        name:'pretext',
        label:'@@SlackWebhookTool.attachment.pretext@@',
        description:'@@SlackWebhookTool.attachment.pretext.desc@@',
        type:'textfield'
    },
    {
        name:'author_name',
        label:'@@SlackWebhookTool.attachment.author_name@@',
        description:'@@SlackWebhookTool.attachment.author_name.desc@@',
        type:'textfield'
    },
    {
        name:'author_link',
        label:'@@SlackWebhookTool.attachment.author_link@@',
        description:'@@SlackWebhookTool.attachment.author_link.desc@@',
        type:'textfield'
    },
    {
        name:'author_icon',
        label:'@@SlackWebhookTool.attachment.author_icon@@',
        description:'@@SlackWebhookTool.attachment.author_icon.desc@@',
        type:'textfield'
    },
    {
        name:'attachment_title',
        label:'@@SlackWebhookTool.attachment.title@@',
        description:'@@SlackWebhookTool.attachment.title.desc@@',
        type:'textfield'
    },
    {
        name:'attachment_title_link',
        label:'@@SlackWebhookTool.attachment.title_link@@',
        description:'@@SlackWebhookTool.attachment.title_link.desc@@',
        type:'textfield'
    },
    {
        name:'attachment_text',
        label:'@@SlackWebhookTool.attachment.text@@',
        description:'@@SlackWebhookTool.attachment.text.desc@@',
        type:'textfield'
    },
    {
        name:'fields',
        label:'@@SlackWebhookTool.attachment.fields@@',
        description : '@@SlackWebhookTool.attachment.fields.desc@@',
        type:'grid',
        columns:[{
            key:'title',
            label:'@@SlackWebhookTool.attachment.fields.title@@'
        },
        {
            key:'value',
            label:'@@SlackWebhookTool.attachment.fields.value@@'
        },
        {
            key:'short',
            label:'@@SlackWebhookTool.attachment.fields.short@@',
            options: [
            {
                value : 'false',
                label : '@@SlackWebhookTool.attachment.fields.short.no@@'
            },{
                value : 'true',
                label : '@@SlackWebhookTool.attachment.fields.short.yes@@'
            }]
        }]
    },
    {
        name:'image_url',
        label:'@@SlackWebhookTool.attachment.image_url@@',
        description:'@@SlackWebhookTool.attachment.image_url.desc@@',
        type:'textfield'
    },
    {
        name:'thumb_url',
        label:'@@SlackWebhookTool.attachment.thumb_url@@',
        description:'@@SlackWebhookTool.attachment.thumb_url.desc@@',
        type:'textfield'
    }]
}]

After completing the properties option to collect input, we can work on the main methods of the plugin which is execute method.在完成收集输入的属性选项后,我们可以处理作为执行方法的插件的主要方法。

Code Block
languagejava
    private SlackApi api = null;
 
    @Override
    public Object execute(Map props) {
        final Set<String> channelList = new HashSet<String>();
        
        String channels = getPropertyString("channels");
        if (!channels.isEmpty()) {
            String[] temp = channels.split(";");
            for (String t : temp) {
                if (t.startsWith("#")) {
                    channelList.add(t);
                }
            }
        }
        
        WorkflowAssignment wfAssignment = (WorkflowAssignment) getProperty("workflowAssignment");
        
        String participantIds = getPropertyString("participantIds");
        if (wfAssignment != null && !participantIds.isEmpty()) {
            String[] temp = participantIds.split(";");
            if (temp.length > 0) {
                WorkflowManager workflowManager = (WorkflowManager) AppUtil.getApplicationContext().getBean("workflowManager");
                WorkflowProcess process = workflowManager.getProcess(wfAssignment.getProcessDefId());
                for (String pid : temp) {
                    pid = pid.trim();
                    if (!pid.isEmpty()) {
                        Collection<String> userList = WorkflowUtil.getAssignmentUsers(process.getPackageId(), wfAssignment.getProcessDefId(), wfAssignment.getProcessId(), wfAssignment.getProcessVersion(), wfAssignment.getActivityId(), "", pid);
                        if (userList != null && userList.size() > 0) {
                            for (String username : userList) {
                                channelList.add(getSlackUsername(username, wfAssignment));
                            }
                        }
                    }
                }
            }
        }
        
        String usernames = getPropertyString("usernames");
        if (!usernames.isEmpty()) {
            String[] temp = usernames.split(";");
            for (String username : temp) {
                channelList.add(getSlackUsername(username, wfAssignment));
            }
        }
        
        Thread sendMessageThread = new PluginThread(new Runnable() {
            public void run() {
                try {
                    LogUtil.info(SlackWebhookTool.class.getName(), "SlackWebhookTool: Sending message to=" + channelList.toString());
                    sendMessage(channelList);
                    LogUtil.info(SlackWebhookTool.class.getName(), "SlackWebhookTool: Sending message completed to=" + channelList.toString());
                } catch (Exception ex) {
                    LogUtil.error(SlackWebhookTool.class.getName(), ex, "");
                }
            }
        });
        
        sendMessageThread.setDaemon(true);
        sendMessageThread.start();
        
        return null;
    }
    
    protected SlackApi getApi() {
        if (api == null) {
            api = new SlackApi(getPropertyString("url"));
        }
        return api;
    }
    
    protected String getSlackUsername(String username, WorkflowAssignment assignment) {
        String syntax = getPropertyString("usernameTransform");
        syntax = syntax.replaceAll(StringUtil.escapeRegex("{username}"), StringUtil.escapeRegex(username));
        return AppUtil.processHashVariable(syntax, assignment, null, null);
    }
    
    protected void sendMessage(Set<String> channels) {
        SlackMessage message = createMessage();
        if (channels != null && !channels.isEmpty()) {
            for (String channel : channels) {
                if (!channel.isEmpty()) {
                    sendMessage(channel, message);
                }
            }
        } else {
            sendMessage(null, message);
        }
    }
    
    protected void sendMessage(String channel, SlackMessage message) {
        if (channel != null && !channel.isEmpty()) {
            message.setChannel(channel);
        }
        
        getApi().call(message);
    }
    
    protected SlackMessage createMessage() {
        SlackMessage message = new SlackMessage(getPropertyString("text"));
        
        String username = getPropertyString("username");
        if (!username.isEmpty()) {
            message.setUsername(username);
        }
        
        String customIcon = getPropertyString("customIcon");
        if (!customIcon.isEmpty()) {
            if ("joget".equals(customIcon)) {
                HttpServletRequest request = WorkflowUtil.getHttpServletRequest();
                if (request != null) {
                    String url = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/images/v3/logo.png";
                    message.setIcon(url);
                }
            } else if ("url".equals(customIcon)) {
                message.setIcon(getPropertyString("iconUrl"));
            } else {
                message.setIcon(getPropertyString("iconEmoji"));
            }
        }
        
        message.setUnfurlLinks("true".equalsIgnoreCase(getPropertyString("unfurl_links")));
        message.setUnfurlMedia("true".equalsIgnoreCase(getPropertyString("unfurl_media")));
        
        boolean hasAttachment = false;
        SlackAttachment atatchment = new SlackAttachment();
        
        String fallback = getPropertyString("fallback");
        if (!fallback.isEmpty()) {
            atatchment.setFallback(fallback);
        }
        
        String color = getPropertyString("color");
        if (!color.isEmpty()) {
            atatchment.setColor(color);
        }
        
        String pretext = getPropertyString("pretext");
        if (!pretext.isEmpty()) {
            atatchment.setPretext(pretext);
            hasAttachment = true;
        }
        
        String author_name = getPropertyString("author_name");
        if (!author_name.isEmpty()) {
            atatchment.setAuthorName(author_name);
        }
        
        String author_link = getPropertyString("author_link");
        if (!author_link.isEmpty()) {
            atatchment.setAuthorLink(author_link);
        }
        
        String author_icon = getPropertyString("author_icon");
        if (!author_icon.isEmpty()) {
            atatchment.setAuthorIcon(author_icon);
        }
        
        String attachment_title = getPropertyString("attachment_title");
        if (!attachment_title.isEmpty()) {
            atatchment.setTitle(attachment_title);
            hasAttachment = true;
        }
        
        String attachment_title_link = getPropertyString("attachment_title_link");
        if (!attachment_title_link.isEmpty()) {
            atatchment.setTitleLink(attachment_title_link);
        }
        
        String attachment_text = getPropertyString("attachment_text");
        if (!attachment_text.isEmpty()) {
            atatchment.setText(attachment_text);
            hasAttachment = true;
        }
        
        String image_url = getPropertyString("image_url");
        if (!image_url.isEmpty()) {
            atatchment.setImageUrl(image_url);
            hasAttachment = true;
        }
        
        String thumb_url = getPropertyString("thumb_url");
        if (!thumb_url.isEmpty()) {
            atatchment.setThumbUrl(thumb_url);
            hasAttachment = true;
        }
        
        Object[] fields = null;
        Object fieldsProperty = getProperty("fields");
        if (fieldsProperty != null && fieldsProperty instanceof Object[]){
            fields = (Object[]) fieldsProperty;
        }
 
        if (fields != null && fields.length > 0) {
            for (Object o : fields) {
                Map mapping = (HashMap) o;
                String title = mapping.get("title").toString();
                String value = mapping.get("value").toString();
                String isShort = mapping.get("short").toString();
                SlackField field = new SlackField();
                field.setTitle(title);
                field.setValue(value);
                field.setShorten("true".equalsIgnoreCase(isShort));
                
                atatchment.addFields(field);
                hasAttachment = true;
            }
        }
        
        if (hasAttachment) {
            message.addAttachments(atatchment);
        }
        
        return message;
    }  return message;
    }

在我们的插件属性中,我们有一个按钮来发送测试消息。让我们实现webService方法来提供一个API来发送测试消息。In our plugin properties, we have a button to send test message. Let implement the webService method to provide an API to send test message.

Code Block
languagexml
    public void webService(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        boolean isAdmin = WorkflowUtil.isCurrentUserInRole(WorkflowUserManager.ROLE_ADMIN);
        if (!isAdmin) {
            response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
            return;
        }
        
        String action = request.getParameter("action");
        if ("sendTestMessage".equals(action)) {
            String message = "";
            try {
                AppDefinition appDef = AppUtil.getCurrentAppDefinition();
                
                String url = AppUtil.processHashVariable(request.getParameter("url"), null, null, null, appDef);
                String testChannel = AppUtil.processHashVariable(request.getParameter("testChannel"), null, null, null, appDef);
                
                setProperty("url", url);
                setProperty("text", AppPluginUtil.getMessage("SlackWebhookTool.testMessage", getClassName(), MESSAGE_PATH));
                
                if (testChannel != null && !testChannel.isEmpty()) {
                    Set<String> channels = new HashSet<String>();
                    channels.add(testChannel);
                    sendMessage(channels);
                } else {
                    sendMessage(null);
                }
                
                message = AppPluginUtil.getMessage("SlackWebhookTool.sendTestMessage.success", getClassName(), MESSAGE_PATH);
            } catch (Exception e) {
                LogUtil.error(this.getClassName(), e, "Fail to send Test Message to Slack");
                message = AppPluginUtil.getMessage("SlackWebhookTool.sendTestMessage.fail", getClassName(), MESSAGE_PATH) + "\n" + StringEscapeUtils.escapeJavaScript(e.getMessage());
            }
            try {
                JSONObject jsonObject = new JSONObject();
                jsonObject.accumulate("message", message);
                jsonObject.write(response.getWriter());
            } catch (Exception e) {
                //ignore
            }
        } else {
            response.setStatus(HttpServletResponse.SC_NO_CONTENT);
        }
    }

c.

...

管理你的插件的依赖库

我们需要在我们的POM文件中包含“jsp-api”和“slack-webhook”库。We need to include "jsp-api" and "slack-webhook" libraries in our POM file.

Code Block
        <!-- Change plugin specific dependencies here -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.0</version>
        </dependency>
        <dependency>
            <groupId>net.gpedro.integrations.slack</groupId>
            <artifactId>slack-webhook</artifactId>
            <version>1.1.1</version>
        </dependency>
        <!-- End change plugin specific dependencies here -->

d. Make your plugin internationalization (i18n) ready

We are using i18n message key in getLabel and getDescription method. We will use i18n message key in our properties options definition as well. Then, we will need to create a message resource bundle properties file for our plugin.

plugin specific dependencies here -->

d. 让你的插件国际化(国际化)准备就绪

我们在getLabel和getDescription方法中使用i18n消息密钥。我们将在我们的属性选项定义中使用i18n消息密钥。然后,我们将需要为我们的插件创建一个消息资源包属性文件。

在“slack_webhook / src / main”目录下创建一个目录“resources / message”。然后,在该文件夹中创建一个“SlackWebhookTool.properties”文件。在属性文件中,添加所有消息密钥及其标签,如下所示。Create a directory, "resources/message", under "slack_webhook/src/main" directory. Then, create a "SlackWebhookTool.properties" file in the folder. In the properties file, add all the message keys and its label as below.

Code Block
org.joget.SlackWebhookTool.pluginLabel=Slack Webhook Tool
org.joget.SlackWebhookTool.pluginDesc=Used to send message to Slack through incoming webhook
SlackWebhookTool.config=Configure Slack Webhook Tool
SlackWebhookTool.url=Webhook URL
SlackWebhookTool.from=From
SlackWebhookTool.fromUsername=Username
SlackWebhookTool.fromUsername.value=Joget Workflow
SlackWebhookTool.customIcon=Custom Icon
SlackWebhookTool.customIcon.none=None
SlackWebhookTool.customIcon.joget=Joget Workflow Logo
SlackWebhookTool.customIcon.url=Image URL
SlackWebhookTool.customIcon.emoji=Emoji Code
SlackWebhookTool.to=To
SlackWebhookTool.channels=Channels
SlackWebhookTool.channels.desc=Separated by semicolon(;). E.g. #general;#info
SlackWebhookTool.participantIds=Participant Ids
SlackWebhookTool.participantIds.desc=Separated by semicolon(;). E.g. applicant;approver
SlackWebhookTool.usernames=Usernames
SlackWebhookTool.usernames.desc=Separated by semicolon(;). E.g. admin;cat
SlackWebhookTool.usernameTransform=Transform username to Slack username
SlackWebhookTool.usernameTransform.desc=Hash Variable can be used to transform username to Slack username. Eg. @#form.slack.username[{username}]#
SlackWebhookTool.usernameTransform.value=@{username}
SlackWebhookTool.message=Message
SlackWebhookTool.text=Text
SlackWebhookTool.text.desc=Refer to <a href="https://api.slack.com/docs/formatting" target="_blank">Slack Message Formatting</a>.
SlackWebhookTool.unfurl_links=Unfurling Links
SlackWebhookTool.unfurl_links.desc=Automatically find URLs in a message and create attachments based on the content of those URLs
SlackWebhookTool.unfurl_media=Unfurling Media
SlackWebhookTool.unfurl_media.desc=Automatically find Media URLs in a message and create attachments based on the media of those URLs
SlackWebhookTool.attachment=Attachment
SlackWebhookTool.attachment.fallback=Fallback
SlackWebhookTool.attachment.fallback.desc=A plain-text summary of the attachment. This text will be used in clients that don't show formatted text (eg. IRC, mobile notifications) and should not contain any markup.
SlackWebhookTool.attachment.fallback.value=Attachment fail to display.
SlackWebhookTool.attachment.color=Color
SlackWebhookTool.attachment.color.desc=An optional value that can either be one of good, warning, danger, or any hex color code (eg. #439FE0). This value is used to color the border along the left side of the message attachment.
SlackWebhookTool.attachment.pretext=Pretext
SlackWebhookTool.attachment.pretext.desc=This is optional text that appears above the message attachment block.
SlackWebhookTool.attachment.author_name=Author Name
SlackWebhookTool.attachment.author_name.desc=Small text used to display the author's name.
SlackWebhookTool.attachment.author_link=Author Link
SlackWebhookTool.attachment.author_link.desc=A valid URL that will hyperlink the Author Name text mentioned above. Will only work if Author Name is present.
SlackWebhookTool.attachment.author_icon=Author Icon
SlackWebhookTool.attachment.author_icon.desc=A valid URL that displays a small 16x16px image to the left of the Author Name text. Will only work if Author Name is present.
SlackWebhookTool.attachment.title=Attachment Title
SlackWebhookTool.attachment.title.desc=The Attachment Title is displayed as larger, bold text near the top of a message attachment.
SlackWebhookTool.attachment.title_link=Attachment Title Link
SlackWebhookTool.attachment.title_link.desc=By passing a valid URL in the Attachment Title Link parameter (optional), the Attachment Title text will be hyperlinked.
SlackWebhookTool.attachment.text=Text
SlackWebhookTool.attachment.text.desc=This is the main text in a message attachment, and can contain standard message markup. The content will automatically collapse if it contains 700+ characters or 5+ linebreaks, and will display a "Show more..." link to expand the content.
SlackWebhookTool.attachment.fields=Fields
SlackWebhookTool.attachment.fields.desc=Fields will be displayed in a table inside the message attachment.
SlackWebhookTool.attachment.fields.title=Title
SlackWebhookTool.attachment.fields.value=Value
SlackWebhookTool.attachment.fields.short=Short
SlackWebhookTool.attachment.fields.short.no=No
SlackWebhookTool.attachment.fields.short.yes=Yes
SlackWebhookTool.attachment.image_url=Image URL
SlackWebhookTool.attachment.image_url.desc=A valid URL to an image file that will be displayed inside a message attachment. We currently support the following formats: GIF, JPEG, PNG, and BMP. Large images will be resized to a maximum width of 400px or a maximum height of 500px, while still maintaining the original aspect ratio.
SlackWebhookTool.attachment.thumb_url=Thumbnail URL
SlackWebhookTool.attachment.thumb_url.desc=A valid URL to an image file that will be displayed as a thumbnail on the right side of a message attachment. We currently support the following formats: GIF, JPEG, PNG, and BMP. The thumbnail's longest dimension will be scaled down to 75px while maintaining the aspect ratio of the image. The filesize of the image must also be less than 500 KB.
SlackWebhookTool.sendTestMessage=Send Test Message
SlackWebhookTool.sendTestMessage.testChannel=Test Channel
SlackWebhookTool.sendTestMessage.success=Test message sent.
SlackWebhookTool.sendTestMessage.fail=Fail to sent test message. Error:
SlackWebhookTool.testMessage=Test Message

e.

...

注册你的插件到Felix框架

接下来,我们将需要在Activator类(在同一个类包中自动生成)中注册我们的插件类,以告诉Felix框架这是一个插件。Next, we will have to register our plugin class in the Activator class (Auto generated in the same class package) to tell the Felix Framework that this is a plugin.

Code Block
languagejava
    public void start(BundleContext context) {
        registrationList = new ArrayList<ServiceRegistration>();
        //Register plugin here
        registrationList.add(context.registerService(SlackWebhookTool.class.getName(), new SlackWebhookTool(), null));
    }

f.

...

建立它并测试

让我们建立我们的插件。构建过程完成后,我们将在“slack_webhook / target”目录下找到一个“slackLet's build our plugin. Once the building process is done, we will find a "slack_webhook-5.0.0.jar" file created under "slack_webhook/target" directory.

Then, let's upload the plugin jar to Manage Plugins. After uploading the jar file, double check that the plugin is uploaded and activated correctly.

Image Removed

Check the Slack Webhook Tool is available in process tool mapping.

Image Removed

Now, let us configure the Incoming Webhooks in Slack platform.

jar”文件。

然后,让我们上传插件jar到  管理插件。上传jar文件后,再次检查插件是否正确上传并激活。

Image Added

检查过程工具映射中可用的Slack Webhook Tool。

Image Added

现在,让我们在Slack平台上配置Incoming Webhooks。

  1. 转到  Go to your_team.slack.com/services/new.
  2. Search for Incoming WebHook and click in Add
  3. new。
  4. 搜索  传入的WebHook  ,然后单击 Add
  5. 选择要发布的频道并按 Choose Channel to Post and press Add Incoming WebHooks Integration
  6. Into Setup Instructions, you've a WebHook URL. This is the argument will use for the "Webhook URL" later. Then, copy it.
  7. 进入  设置说明,你有一个WebHook网址。这是稍后将用于“ Webhook URL ” 的参数。然后,复制它。

配置Slack Webhook工具。Configure the Slack Webhook Tool.

The message is received in Slack.该消息在Slack中接收。

8.

...

再进一步,分享或出售

您可以从You can download the source code from slack_webhook_src.zip.下载源代码  。

要下载现成的插件jar,请在To download the ready-to-use plugin jar, please find it in http://marketplace.joget.org/. (Coming Soon)找到它  。(快来了)