7. Webhook
Webhook
- Introduction
Webhook is a node in the process of Light Flow applications. It allows you to automatically trigger and use functions provided by third-party system APIs when data flows through this node. This can include adding new members to DingTalk, calling Google Calendar, sending emails, adding Trello cards, creating GitHub issues, etc. Webhook supports secondary development based on Anffy to connect with your company's existing systems.
Webhook also supports global configuration. After configuring and saving in the Light Mall-Plugin Center-Third-Party Connection-Webhook Configuration interface, you can create a globally available webhook template for easier use in the future.
Note: The webhook function is currently available only to enterprise version users. To try it out or upgrade, please contact your Anffy colleague.
- Setup Steps
- Version Confirmation: Webhook is a Q-Robot node, currently exclusive to Enterprise Edition and above users. For trials or upgrades, contact Anffy support.
- Installation: Install the Webhook function in Light Mall-Plugin Center-Third-Party Connection.
- Adding a Webhook Node: When editing the application process, add a Webhook node to access the configuration content.
Configuration Item Name | Fillable content | Usage Description |
Configuration Mode | Customize / Use Plug-in Center Template / Use Connection Center Template | If you want to use the existing webhook global configuration or the existing template in the connection center, you can select the corresponding template and use it directly, eliminating the need for further configuration. |
Authentication Method | Existing authentication in the plug-in center | Existing authentication can be utilized, thereby eliminating the need for additional authentication steps. |
URL | The URL of the third-party system API can be inserted into the fields in the form within the application. | Set to the URL specified in the third-party system API definition. |
Method | Currently Supports POST/PUT/DELETE/GET | |
Trigger Mode | Default/Custom | By default, Anffy's predefined data structure will be sent to the specified URL. |
Header | Header information sent with the request | Requested header information supports custom values or field insertion from the form. |
Body | url-encoded, application/json, application/xml | The requested body information is compatible with the above three formats. |
x-www-form- urlencoded | Key-value pairs of body content | |
application/json | Body content with a custom JSON structure; fields can be inserted. | This section pertains to the advanced content of the Anffy webhook. You can customize the request body content to support the transmission of ordinary fields, table subfields, and the entire table. |
application/xml | Body content with a custom XML structure; fields can be inserted. | This section is part of the advanced content of the Anffy webhook. It allows for customization of the request body content and supports the transmission of ordinary fields, table subfields, and the entire table. |
Callback to Update Current Data | Custom parsing of returned data can be performed, and current form fields can be updated. | Supports parsing returned data in XML and JSON formats, and updates to the current form according to custom rules. |
3. Precautions
Inserted Fields | Actual Content |
Member Field | Email address bound to the member. |
Applicant | Applicant’s email address. |
Upload Attachment | URL of the attachment. |
Date | Example: 2020-09-18 14:09:46, changes with the setting accuracy. |
Drop-Down Selection, Single Selection | Option names, separated by spaces. |
- Field Insertion: Pay attention to the actual content inserted for different field types.
- Array Format Result: For single-value format fields, only the first object value of the array is used.
- Table Field JSON Path Parsing: Must result in an array.
- Timeout: Set at 60 seconds.
3. Webhook Global Configuration
For frequently used specific webhook configurations, templates can be set in the plugin center with "variables" and "variable default values." Once saved, the template can be used in all application processes in the workspace. Template usage involves selecting the template and filling in the template variables.
1 Usage Restrictions
- Available only to enterprise version users.
- Accessible post-plugin center installation.
5. Template Configuration
In the Anffy Mall-Plugin Center-Third-Party Connection-Webhook section, configure the Webhook template. The template configuration involves creating "variables" for use in subsequent configurations.
Template Features
- Expand/collapse, copy, delete support.
- Set default values for each variable.
- Supports configuring authentication method, URL, QueryParam, Header, Method, and Body Type.
- Variables can be inserted into URL and RequestBody.
6. Webhook Template Configuration
The configuration of a Webhook template is similar to a standard Webhook setup. The key difference lies in the ability to create "variables," which can be utilized in subsequent configurations. Here's an overview of how it works:
Variable Creation and Usage
- Variables: They are created within the template and can be used in later configurations. When implementing the template in a process, simply configure the value of these variables to complete the setup.
- Template Features: The template supports various functionalities, including the ability to expand/collapse, copy, and delete elements.
- Default Values: Each variable can have a set default value. If the webhook node in a process uses the template without binding a specific value to a variable, the default value will be applied.
- Variable Deletion: If a variable is deleted but its insertion point remains, 'null' will be inserted when initiating a request.
7. Configuration Options
Authentication Method: Choose from existing methods configured in the Plugin Center's Authentication section. Custom methods are not supported.
URL, QueryParam, Header, Method, and Body Type: These elements can be configured within the template.
BodyType and RequestBody: When choosing "POST/PUT/DELETE" as the method, you can set the BodyType (url-encoded, application/json, or application/xml) and accordingly select the RequestBody type (FormBody, JsonBody, or XmlBody).
Variables Insertion: Variables can be inserted into both the URL and the RequestBody.
8. Customization
QueryParam, Header, and FormBody: The values of these parameters can either be customized or utilize previously set variables.
9.Template Case Example
Consider a Webhook template configured to use Anffy for sending messages to an Enterprise WeChat robot. In this scenario:
Message Type: The message being pushed is of the "image and text" type.
Variable Matching: The created variables in the template correspond to specific fields in the form, ensuring that the message content is dynamically generated based on the form data.
10. Use Configuration
In the Anffy application, add process -> add node -> Webhook -> configuration mode, select "Use Plugin Center Template", bind variables to the template, and update configuration.
The value assigned to a "variable" in a Webhook template can originate from various sources, including a field within the current application's form, a system parameter, or a custom-defined string. This flexibility allows for a wide range of data to be dynamically incorporated into the Webhook process.
For any "variables" that are not explicitly bound to a value, the behavior is determined by the template settings:
- Default Values: If a default value has been defined for a variable within the template, this default value will be automatically used whenever the variable is inserted into the Webhook configuration.
- Unbound Variables: In cases where no default value is set and the variable remains unbound, the system will insert 'null' for that variable when the Webhook request is initiated.
11. Variable Binding Interpolation
- Field restrictions: Cannot select fields like QLinker, OCR, table, rich text, description text. Table subfields are selectable.
- Multi-value type fields are separated by commas or other specified delimiters.
- Option type fields (single selection, multiple selection, dropdown selection, picture selection) use the option name.
- Locate fields and address fields use addresses, separating detailed addresses with commas.
- Member fields use the email address.
- Department fields use department names, with commas separating ancestor to selected departments.
- Start and end times follow the format "YYYY-MM-DD HH:MM:SS~YYYY-MM-DD HH:MM:SS".
- Dates follow the format "YYYY-MM-DD HH:MM:SS".