English
Fx.message
About 2477 wordsAbout 8 min
2026-01-09
Table of Contents
Summary
The overview of this document is as follows: Used to send text messages and card messages.
Function Categories
Message Sending Module
| Method Name | Description | Syntax |
|---|---|---|
| send (Text Message) | Send text message | Fx.message.send(...) |
| send (Card Message) | Send card message | Fx.message.send(...) |
send (Text Message)
Function: Send text message.
Syntax: Fx.message.send(String message, List receiverIds, Channel channel)
Request parameters: See the example below.
Example:
Channel channel = Channel.Service("FSAID_bebd374")
List receiverIds = [1000] // Message recipient users
def (error,date,errorMessage) = Fx.message.send("This is a text message",receiverIds,channel)Reference:
- See Channel
send (Card Message)
Fx.message.send(<String card>, <List receiverIds>, <Channel channel>)
Send card message;
Fx.message.send(<String card>, <List receiverIds>, <Channel channel>)
Request parameters
Request Body
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| card | String | Card message. The structure is complex, please use ObjectCard.builder to construct | Y |
| receiverIds | List[Integer] | List of recipient IDs | Y |
| channel | Channel | Do not define manually. Please use the reference class com.fxiaoke.functions.model.Channel, Channel channel = Channel.Service("appiD"); //Send service account, Channel channel = Channel.ObjectSession("AccountObj", "61848edfd9007e00019ee222") //Send customer group | Y |
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| card | String | Card message. The structure is complex, please use ObjectCard.builder to construct | -- |
| head | Head | Card header | -- |
| body | Body | Card content | -- |
| foot | Foot | Card footer | -- |
| objectApiName | String | Card associated object details. Requires object apiname and objectId to be used together, can replace the link address below (optional) | -- |
| objectId | String | Card associated object details. Requires object objectId and apiname to be used together, can replace the link address below (optional) | -- |
| innerDirectWebUrl | String | Card's web redirect URL within Fxiaoke (optional) | -- |
| innerDirectMobileUrl | String | Card's mobile redirect URL within Fxiaoke (uses web URL if not provided, optional) | -- |
| outerDirectUrl | String | Card's redirect URL when pushed to external platforms (optional) | -- |
| head | Head | Card header | Required |
|---|---|---|---|
| title | String | Card title (required) | -- |
| body | Body | Card content | Required |
|---|---|---|---|
| content | String | Card title (required) | -- |
| entries | Map | Card table (optional) | -- |
| foot | Foot | Card footer | Required |
|---|---|---|---|
| title | String | Card title (required) | -- |
Code examples
def card = ObjectCard.builder {
head {
title = "head title" //Card title (Required)
}
foot {
title = "foot title" //Card footer (Required)
}
body {
content = "body content" //Card content (Required)
entries = [key: "value"] //Card table (Optional)
}
objectApiName = "AccountObj" //Target object's APIName (Required)
objectId = "5cbd28e47cfed9ea0cca09e4" //Target object's ID (Required)
}
Channel channel = Channel.Service("DSTX")
List receiverIds = [1000]
def (error,date,errorMessage) = Fx.message.send(card,receiverIds,channel)Notification Module
| Method Name | Description | Syntax |
|---|---|---|
| sendNotice | Send notification | Fx.message.sendNotice(...) |
| sendNotice (Without Data Association) | Send notification without data association | Fx.message.sendNotice(...) |
sendNotice
Send CRM Notification
Fx.message.sendNotice(<String title>, <String content>, <List receiverIds>, <Notice notice>)
Request parameters
Request Body
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| title | String | CRM notification title | Y |
| content | String | CRM notification content | Y |
| receiverIds | List[Integer] | List of recipient IDs | Y |
| notice | Notice | Notification type. Current options: defaultNotice: Regular notification, Notice notice = Notice.defaultNotice() objectNotice: CRM notification with object detail page link, requires passing object's apiName and dataId, Notice notice = Notice.objectNotice(String apiName, String dataId) | Y |
Code examples
List receiverIds = ['1000', '1001']
Notice objectNotify = Notice.objectNotice("AccountObj","5fa4de2f832a9d00012868b8")
def (Boolean error, String data, String errorMessage) = Fx.message.sendNotice("This is also a title","This is the notification content",receiverIds, objectNotify)
if (error) {
log.info(errorMessage)
} else {
log.info(data)
}sendNotice (Without Data Association)
Send CRM Notification
Fx.message.sendNotice(<String title>, <String content>, <List receiverIds>, <String entityId>, <String objectId>)
Request parameters
Request Body
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| title | String | CRM notification title | Y |
| content | String | CRM notification content | Y |
| receiverIds | List[Integer] | List of recipient IDs | Y |
| entityId | String | Object API name | -- |
| objectId | String | Object data ID | -- |
Code examples
Map data = context.data
String entityId = data.get("object_describe_api_name")
String objectId = data.get("_id")
log.info(entityId+":"+objectId)
//Title, Content, Recipient, Object API Name (optional), Object Data ID (optional)
//If Object API Name and Object Data ID are left blank, the sent message will not redirect to the data details page.
//Only when both Object API Name and Data ID are provided will the message redirect to the data details page.
Fx.message.sendNotice("Title", "Content", ["1007"], "", "")Exception Handling Module
| Method Name | Description | Syntax |
|---|---|---|
| throwErrorMessage | Throw error message | Fx.message.throwErrorMessage(...) |
| throwException | Throw exception | Fx.message.throwException(...) |
throwErrorMessage
Throw exception messages for known and confirmed exceptions, primarily used to interrupt execution; displays as successful on the function list page.
Fx.message.throwErrorMessage()
Code examples
Fx.message.throwErrorMessage("Function interrupted")throwException
Throw exception message for unknown or uncertain errors, primarily used for error throwing; displays as "Failed" on the function list page.
Fx.message.throwException()
Code examples
Fx.message.throwException("Function exception")Enterprise Messaging and Group Module
| Method Name | Description | Syntax |
|---|---|---|
| createTrustGroup | Create enterprise messaging group | Fx.message.createTrustGroup(...) |
| sendIMMessage | General enterprise IM message sending API | Fx.message.sendIMMessage(...) |
createTrustGroup
Create enterprise messaging group
Fx.message.createTrustGroup(<String apiName>, <String dataId>)
Request parameters
Request Body
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| apiName | String | Object API name | Y |
| dataId | String | Object data ID | Y |
Code examples
def (Boolean error, Map data, String errorMessage) = Fx.message.createTrustGroup('object_94QeC__c', '5dae6f48a5083da25946e68c')
if(error) {
log.info(errorMessage)
} else {
log.info(data)
}Notice
- When using this function, it is necessary to enable the business group feature for this object in the enterprise message management section of the admin backend and complete the relevant configurations.
sendIMMessage
General Enterprise IM Message Sending API
Fx.message.sendIMMessage(<String sessionId>, <String messageType>, <String messageContent>, <Integer env>, <String employeeId>)
Request parameters
Request Body
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| sessionId | String | Target conversation ID. The operator's enterprise must have access to this conversation, and non-system operators need to be group members | Y |
| messageType | String | Message type. Common types: Text (T), Image (I), Mixed Content (MIX), File (D), Advanced Text (AT), Universal Template Message (UGT) | Y |
| messageContent | String | Message content. Text uses string format, other types use corresponding JSON format (refer to existing message formats in Enterprise IM) | Y |
| env | Integer | Interconnection flag: 0 for intra-enterprise, 1 for inter-enterprise | Y |
| employeeId | String | Sender information in format: E.EnterpriseAccount.EmployeeID | Y |
Code examples
String content = "Hello everyone"
String employeeId = "E.78810.1004"
def(boolean error, Map data, String message) = Fx.message.sendIMMessage("d5a3f0ba6dff4c488069efdd6d00a747", "T", content, 0, employeeId)
if (error) {
log.info("error: " + message)
} else {
log.info(data)
}Email Module
Used to send emails and send emails using templates.
| Method Name | Description | Syntax |
|---|---|---|
| sendEmail (Basic) | Send email | Fx.message.sendEmail(List toList, String subject, String content, boolean useSystemSend) |
| sendEmail (CC/BCC) | Send email with CC and BCC support | Fx.message.sendEmail(EmailAttribute attribute) |
| sendEmailByTemplate (Basic) | Send email using an email template and data | Fx.message.sendEmailByTemplate(String templateId, String objectId, String toList, boolean userSystemSend) |
| sendEmailByTemplate (CC/BCC) | Send email using an email template and data, with CC and BCC support | Fx.message.sendEmailByTemplate(EmailAttribute attribute) |
sendEmail (Basic)
Send Email
Fx.message.sendEmail(<List toList>, <String subject>, <String content>, <boolean useSystemSend>)
Request parameters
Request Body
| Parameter Name | Type | Description | Required |
|---|---|---|---|
| toList | List[String] | List of recipient email addresses | Y |
| subject | String | Email subject | Y |
| content | String | Email body content | Y |
| useSystemSend | boolean | Whether to send using system identity (true: use system email address; false: use the Fxiaoyou email address bound to the function trigger executor) | Y |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| error | boolean | Indicates whether execution encountered an exception |
| data | object | |
| errorMessage | String | Error message for exception cases |
| data | object | Description |
|---|---|---|
| toList | List[String] | List of recipient email addresses |
| subject | String | Email subject |
| content | String | Email body content |
Return an example
{
"error": false,
"data": {
"toList": ["admin01@fxiaoke.com"],
"subject": "This is the subject",
"content": "This is the body content"
},
"errorMessage": ""
}Code examples
// Email subject
String subject = "Jaime Enrique Garcia Lopez, Senior Software Development Manager at Capital One"
String content = "\"At the time, no single team member knew Go, but within a month, everyone was writing in Go and we were building out the endpoints. It was the flexibility, how easy it was to use, and the really cool concept behind Go (how Go handles native concurrency, garbage collection, and of course safety+speed.) that helped engage us during the build. Also, who can beat that cute mascot!\""
// Recipient email list
List toList = ["admin01@fxiaoke.com"]
// Use system email to send
boolean useSystemSend = true
def(error, data, errorMessage) = Fx.message.sendEmail(toList, subject, content, true)
if (error) {
log.info(errorMessage)
} else {
log.info(data)
}sendEmail (CC/BCC)
Send emails, supporting CC (carbon copy) and BCC (blind carbon copy)
Fx.message.sendEmail(<EmailAttribute attribute>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| attribute | EmailAttribute | Email related information | Y |
Return Parameters
| Parameter Name | APIResult | Parameter list |
|---|---|---|
| error | boolean | Whether execution encountered an exception |
| data | Return result | |
| errorMessage | String | Exception message |
Return an example
{
"error": false,
"data": {},
"errorMessage": ""
}Code examples
// Email subject
String subject = 'go1.22.3.windows-amd64.zip'
String content = 'cab2af6951a6e2115824263f6df13ff069c47270f5788714fa1d776f7f60cb39'
// Email attachments
// The structure of object attachment field values differs from email attachments and requires the following conversion
// Get attachment field from data
def attachmentVaule = context.data.field_fCuoH__c
// Email attachment content
def attachments = []
// Conversion logic
// emailAttachement ⇄ fieldValue
// index ⇄ index
// name ⇄ filename
// fileId ⇄ path
// size ⇄ size
attachmentVaule.eachWithIndex { item, index ->
attachments << [
'index': index,
'name': item['filename'],
'fileId': item['path'],
'size': item['size']
]
}
// Recipient email addresses
List toList = ['admin01@fxiaoke.com']
// CC email addresses
List ccList = ['admin02@fxiaoke.com']
// BCC email addresses
List bccList = ['admin02@fxiaoke.com']
// Use system email for sending
boolean useSystemSend = false
// Sender address (must be a pre-configured system email in backend)
String sender = 'system@fxiaoke.com'
EmailAttribute attribute = EmailAttribute.builder()
.toList(toList)
.ccList(ccList)
.bccList(bccList)
.subject(subject)
.content(content)
.sender(sender)
.attachments(attachments)
.useSystemSend(useSystemSend)
.build()
def(error, data, errorMessage) = Fx.message.sendEmail(attribute)
if (error) {
log.info(errorMessage)
} else {
log.info(data)
}Reference Interface
Reference guide: EmailAttribute
Reference guide: Email
Notice
- Please note the structure of the attachment data. Do not directly use the value of the attachment field from the data as-is, as this is incorrect.
- Refer to the sample for specific conversion logic.
sendEmailByTemplate (Basic)
Send emails using templates and data
Fx.message.sendEmailByTemplate(<String templateId>, <String objectId>, <String toList>, <boolean userSystemSend>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| templateId | String | Template ID | Y |
| objectId | String | Object data ID | Y |
| toList | String[String] | Recipient email address list | Y |
| userSystemSend | boolean | Whether to use system email address (true: send using system email, false: send using the Fxiaoke email address bound to the function trigger user) | Y |
Return Parameters
| Parameter Name | APIResult | Parameter List |
|---|---|---|
| error | boolean | Indicates whether execution encountered an exception |
| data | Return result | |
| errorMessage | String | Exception message |
Return an example
{
"error": false,
"data": {},
"errorMessage": ""
}Code examples
// Email template ID
String templateId = "64fecf9677e6c00ba21ac99e"
// Object data ID
String dataId = "663dd7ea96f31400079c210e"
// Recipient email addresses
List toList = ["admin01@fxiaoke.com"]
// Use system email for sending
boolean useSystemSend = true
def (error, data, errorMessage) = Fx.message.sendEmailByTemplate(templateId, dataId, toList, useSystemSend)
if(error){
log.info(errorMessage)
} else {
log.info(data)
}sendEmailByTemplate (CC/BCC)
Send emails using templates and data, supporting CC (carbon copy) and BCC (blind carbon copy)
Fx.message.sendEmailByTemplate(<EmailAttribute attribute>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| attribute | EmailAttribute | Email related information | Y |
Return Parameters
| Parameter Name | APIResult | Parameter list |
|---|---|---|
| error | boolean | Whether execution encountered an exception |
| data | Return result | |
| errorMessage | String | Exception message |
Return an example
{
"error": false,
"data": {},
"errorMessage": ""
}Code examples
// Email template ID
String templateId = "64fecf9677e6c00ba21ac99e"
// Object data ID
String dataId = "663dd7ea96f31400079c210e"
// Email attachment
Map attachment = [
"index": 0,
"name": "go1.22.3.windows-amd64.zip",
"fileId": "N_202409_12_e18599a6fc724e9e8502a94d0a5775cd.zip",
"size": 76246156
]
// Email attachment
// The structure of object attachment field value differs from email attachment structure, requiring the following conversion
// Get the attachment field from the data
def attachmentVaule = context.data.field_fCuoH__c
// Email attachment content
def attachments = []
// Conversion logic
// emailAttachement ⇄ fieldValue
// index ⇄ index
// name ⇄ filename
// fileId ⇄ path
// size ⇄ size
attachmentVaule.eachWithIndex { item, index ->
attachments << [
'index': index,
'name': item['filename'],
'fileId': item['path'],
'size': item['size']
]
}
// Recipient email addresses
List toList = ["admin01@fxiaoke.com"]
// CC email addresses
List ccList = ["admin02@fxiaoke.com"]
// BCC email addresses
List bccList = ["admin02@fxiaoke.com"]
// Use system email for sending
boolean useSystemSend = true
EmailAttribute attribute = EmailAttribute.builder()
.toList(toList)
.ccList(ccList)
.bccList(bccList)
.templateId(templateId)
.objectId(dataId)
.attachments(attachments)
.useSystemSend(useSystemSend)
.build();
def (error, data, errorMessage) = Fx.message.sendEmailByTemplate(attribute)
if(error){
log.info(errorMessage)
} else {
log.info(data)
}Reference Interface
Reference guide: EmailAttribute
Reference guide: Email
Notice
- Please note the structure of the attachment data. Do not directly use the value of the attachment field from the data as-is, as this is incorrect.
- Refer to the sample for specific conversion logic.
Reference Class com.fxiaoke.functions.model.Channel
Field description
| Parameter Name | object | Description |
|---|---|---|
| (No field description) | - | - |
Service
Enterprise Messaging Service Account Channel
Channel.Service()
Code examples
Channel channel = Channel.Service("appiD") // Service account for sending messagesOwner:斯作益seth
ObjectSession
Customer Group Channel
Channel.ObjectSession()
Code examples
Channel channel = Channel.ObjectSession("AccountObj", "61848edfd9007e00019ee222") // Target audience groupOwner:斯作益seth
Reference Class com.fxiaoke.functions.model.EmailAttribute
Field description
| Parameter Name | object | Description |
|---|---|---|
| useSystemSend | java.lang.Boolean | Whether to send as system identity (true means using system mailbox to send, false means using the Fxiaoke mailbox bound to the function trigger personnel). Default is true |
| attachments | java.util.List | Attachments |
| sender | java.lang.String | Specified sender email (must be a system mailbox configured in backend email management) |
| subject | java.lang.String | Email subject |
| bccList | java.util.List | BCC email list |
| ccList | java.util.List | CC email list |
| attachmentZipList | java.util.List | Attachment download links |
| toList | java.util.List | Recipient email list |
| templateId | java.lang.String | Template ID |
| objectId | java.lang.String | Object data ID |
| content | java.lang.String | Email body content |
Reference Class com.facishare.function.impl.dto.SendEmail.Email
Field description
| Parameter Name | object | Description |
|---|---|---|
| toList | array[String] | |
| subject | String | Email subject |
| content | String | Email body content |
| sender | String | Specified sender email address (must be a system email configured in backend email management) |
| ccList | List[String] | CC recipient address list |
| bccList | List[String] | BCC recipient address list |
| attachments | List[Object] | Attachment list |
| attachmentZipList | List[Object] | Attachment URL list |
| crmObjApiName | String | Bound object name (for email record purposes) |
| crmObjDataId | String | Bound data ID (for email record purposes) |
Field examples
{
"toList": [
"admin01@fxiaoke.com"
],
"subject": "subject_570f35483d97",
"content": "content_ab8286a1a8ff",
"sender": "sender_eeeaaca45e0c",
"ccList": [
"admin02@fxiaoke.com"
],
"bccList": [
"admin03@fxiaoke.com"
],
"attachments": [
{}
],
"attachmentZipList": [
{}
],
"crmObjApiName": "crmObjApiName_52b29fd536de",
"crmObjDataId": "crmObjDataId_4999c93ed3dd"
}Changelog
| Version | Date | Changes | Author |
|---|---|---|---|
| v1.0 | 2026-05-20 | Initial version |
Background
This document provides detailed information about the Fx.message API functionality and usage, helping developers integrate relevant capabilities.
Applicable Scenarios
Specific applicable scenarios are determined by actual business needs. Developers can select the appropriate API for integration as required.
Prerequisites
- Access to Fxiaoke Open Platform
- Application authorization and configuration completed
- Basic knowledge of relevant business domain
Steps
Please refer to the detailed instructions for each API.
Compatibility note: This version currently has no deprecated or compatibility notes.
