작업 플로우는 사용자가 정의한 자동화 워크플로우입니다. 각 작업 플로우는 플로우를 시작하는 작업 플로우 트리거와 하나 이상의 작업으로 구성됩니다.
사용자 지정 코드 단계를 통해 사용자 지정 JavaScript를 실행하여 미리 정의된 작업 및 단계로는 불가능한 복잡한 데이터 변환, 서식화 및 고급 논리를 수행할 수 있습니다. 예를 들어 사용자 지정 코드 단계를 사용하여 이메일 주소의 민감한 부분을 마스킹하기 위한 정보를 얻거나, 이메일 또는 주문 ID의 형식을 검증하거나, 후속 알림에 대한 향후 날짜를 계산할 수도 있습니다.
사용자 지정 코드 단계 추가하기 및 구성하기
작업 플로우의 일부로 코드를 실행해야 하는 경우에는 사용자 지정 코드 단계를 추가할 수 있습니다. 사용자 지정 코드 단계의 입력 및 출력에 지원되는 데이터 유형을 알아보려면 지원되는 데이터 유형을 참조하세요.
- 작업 플로우를 엽니다.
- 작업 빌더에서 기존 단계 아래의 단계 추가 아이콘(
)을 클릭합니다. - 단계 사이드바의 플로우 제어 및 유틸리티 아래에서 사용자 지정 코드를 클릭합니다.
- 단계 사이드바에서 입력 추가를 클릭하여 사용자 지정 코드에 대한 입력을 추가합니다.
- 단계 사이드바에서 출력 추가를 클릭하여 하나 이상의 출력을 추가합니다.
- 단계 사이드바의 코드 아래에 사용자 지정 JavaScript 코드를 입력합니다.
- 저장을 클릭합니다.
사용자 지정 코드가 예상대로 작동하는지 확인하기 위해 작업 플로우를 테스트하세요. 문제가 발생하면 사용자 지정 코드 단계 문제 해결하기를 참조하세요.
사용자 지정 코드 단계에 입력 추가하기
사용자 지정 코드 단계는 최대 25개의 입력을 가질 수 있습니다.
- 작업 플로우를 엽니다.
- 작업 빌더에서 기존 사용자 지정 코드 단계를 클릭하거나 단계 추가 아이콘(
)을 클릭하여 사용자 지정 코드 단계를 추가합니다. - 단계 사이드바에서 입력 추가를 클릭합니다.
-
변수 선택 아래에서 이전 단계나 작업 플로우 트리거의 변수를 선택합니다.참고: 입력의 데이터 유형은 선택된 변수로부터 추론됩니다.
- 선택한 변수에 따라 자동으로 채워지지만 편집할 수 있는 입력의 이름 값을 확인합니다. 입력 이름은 이러한 요구 사항을 준수해야 합니다.
- 저장을 클릭합니다.
사용자 지정 코드 단계에 출력 추가하기
- 작업 플로우를 엽니다.
- 작업 빌더에서 기존 사용자 지정 코드 단계를 클릭하거나 단계 추가 아이콘(
)을 클릭하여 사용자 지정 코드 단계를 추가합니다. - 단계 사이드바에서 출력 추가를 클릭합니다.
- 출력의 고유한 이름을 입력합니다.
이러한 요구 사항을 준수해야 합니다.
- 출력의 데이터 유형을 선택합니다.
- 저장을 클릭합니다.
사용자 지정 코드 추가하기
사용자 지정 코드 단계의 JavaScript는 입력 개체를 가져와서 출력 개체를 리턴하는 함수를 내보내야 합니다. 작업 플로우에 사용자 지정 코드 단계를 추가할 때마다 이 프레임워크로 미리 채워지며 이를 수정하거나, 확장하거나, 삭제하거나, 새로 시작할 수 있습니다.
사용자 지정 코드 단계는 가능한 한 사용자 친화적으로 디자인되었지만 관리자는 이러한 단계를 구현할 때 여전히 엔지니어링 지원이 필요할 수 있습니다.
- 각 단계의 코드는 최대 10,000자까지 가능합니다.
- 사용자 지정 코드는 단계에 정의된 각 출력에 대한 값을 리턴해야 합니다.
- 작업 플로우에서 사용하는 코드는 빠르게 실행되고 합리적인 양의 메모리를 사용해야 합니다.
- 다음과 같은 JavaScript 제한 사항이 적용됩니다.
- 함수는 동기식이어야 합니다. 즉,
async,await및promise는 지원되지 않습니다. -
fetch,XMLHttpRequest및 jQuery AJAX와 같은 네트워크 요청은 지원되지 않습니다. - 외부 라이브러리나 모듈을
import또는require할 수 없습니다.
- 함수는 동기식이어야 합니다. 즉,
- 작업 플로우를 엽니다.
- 작업 빌더에서 기존 사용자 지정 코드 단계를 클릭하거나 단계 추가 아이콘(
)을 클릭하여 사용자 지정 코드 단계를 추가합니다. -
코드 아래에서 제공된 예시를 확장하고, 예제를 삭제한 후 직접 자체 논리를 작성하거나 AI 프롬프트를 사용하여 사용자 지정 코드를 생성합니다.코드는 입력 개체를 가져와서 출력 개체를 리턴하는 함수를 내보내야 합니다. 예:
// In the Inputs section for this step, add an input named status. // In the Outputs section for this step, add a text output named message. module.exports = (inputs) => { // Access inputs using inputs.<name> const msg = 'Your text was ' + inputs.status + '.' // This return must include all outputs. return { message: msg } }참고: 코드를 작성할 때 편집기는 올바른 JavaScript 작업에 대한 유용한 제안을 합니다. 오타와 올바르지 않은 코드는 구불구불한 빨간색 밑줄로 표시됩니다. 밑줄 친 부분에 커서를 갖다 대면 오류 메시지가 보입니다. - 저장을 클릭합니다.
사용자 지정 코드 입력 및 출력에 지원되는 데이터 유형
사용자 지정 코드 단계는 다음과 같은 데이터 유형을 수락하고 반환하며, 각 데이터 유형은 상응하는 JavaScript 유형으로 코드에 나타납니다.
| 입력 유형 | JavaScript 데이터 유형 | 예 |
|---|---|---|
| 텍스트 | 문자열 | “안녕하세요!” |
| 숫자 | 숫자 | 123, -5, 0 |
| 소수 | 숫자 | 12.67, 1.0, 0.0 |
| 참/거짓 | 부울 | 참, 거짓 |
| 날짜* | 문자열 | "2025-10-27" |
| 날짜 및 시간* | 문자열 |
UTC 날짜 및 시간 "2025-10-27T10:30:00Z" 시간대 오프셋이 포함된 날짜 및 시간: "2025-06-22T05:11:28+10:00" 밀리초 단위의 UTC 날짜 및 시간: "2025-03-08T06:01:21.415Z" 시간대 오프셋과 밀리초가 있는 날짜 및 시간: "2025-07-23T13:33:17.031-3:00" |
| 텍스트 배열 | 문자열의 배열 | ["안녕하세요!", "어떻게 지내세요?"] |
| 숫자 배열 | 숫자의 배열 | [12, 34, 56, 0] |
| 소수 배열 | 숫자의 배열 | [2.1, 6.3, 6.01, 0.1] |
| 참/거짓 배열 | 부울의 배열 | [참, 참, 거짓] |
| 날짜 배열 | 문자열의 배열 | ["1997-08-29", "2004-07-25", "2011-04-21"] |
| 날짜/시간 배열 | 문자열의 배열 | ["1977-05-25T12:45Z", "1980-05-21T15:00Z", "1983-05-25T19:30Z"] |
- 개체
- 개체 배열
- 혼합 배열
- 배열 배열
작업 플로우 단계의 사용자 지정 JavaScript 코드 생성을 위한 AI 프롬프트 기본서식
다음 프롬프트는 ChatGPT와 같은 AI 도구와 함께 사용하여 사용자 지정 코드 단계에 대한 코드를 생성할 수 있습니다. 프롬프트에는 코드에 지원되는 데이터 유형과 필요한 구조에 대한 안내가 포함되어 있습니다.
프롬프트 1
Write a piece of JavaScript code. The code must export a function that takes an inputs object and returns an outputs object, for example:
module.exports = (inputs) => {
let msg = "Your text was " + inputs.inputText + "."
return {
outputMessage: msg
}
}
Supported data types:
Strings, numbers, booleans, dates (YY-MM-DD) and datetimes (YY-MM-DDTHH:mm:SSZ) are supported. Arrays of those are supported too.
Objects, arrays of arrays, and arrays of objects are not supported. When used as inputs or outputs they must be stringified and passed as strings.
Check for missing or invalid data, and ensure it is handled gracefully by returning a valid output:
for strings, output the empty string ""
for numbers, output -1
for booleans, output false
for arrays, output the empty array []
for objects, output the empty object {}
Comment the code:
Include a comment at the top which briefly describes what the code does.
Include comments directing the reader to create the inputs and outputs, for example: // Make sure to create the following inputs: field_tag (Text).
In comments, refer to variable types with the following friendly names:
string: use "Date" for dates, "Date and time" for datetimes, else use "Text"
number: use "Number” or "Decimal"
boolean: use "True/False"
array: use "Number array", "Text array" etc
The code should... <DESCRIBE WHAT YOU WANT YOUR CODE TO DO HERE>
프롬프트 2
Write a piece of JavaScript code. The code must export a function that takes an inputs object and returns an outputs object, for example:
module.exports = (inputs) => {
let msg = "Your text was " + inputs.inputText + "."
return {
outputMessage: msg
}
}
Supported input and output data types:
Strings, numbers, booleans, dates (YY-MM-DD) and datetimes (YY-MM-DDTHH:mm:SSZ) are supported. Arrays of those are supported too.
Objects, arrays of arrays, and arrays of objects are not supported. When used as inputs or outputs they must be stringified and passed as strings.
Comment the code:
Include a comment at the top which briefly describes what the code does.
Include comments directing the reader to create the inputs and outputs, for example: // Make sure to create the following inputs: field_tag (Text).
In comments, refer to variable types with the following friendly names:
string: use "Date" for dates, "Date and time" for datetimes, else use "Text"
number: use "Number" or "Decimal"
boolean: use "True/False"
array: use "Number array", "Text array" etc
The code should... <DESCRIBE WHAT YOU WANT YOUR CODE TO DO HERE>
사용자 지정 코드 단계 예시
기본 티켓 세부 정보를 사람이 읽을 수 있는 댓글로 서식화하기
module.exports = (inputs) => {
// This code takes text inputs 'status' and 'priority', and a number input 'ticket_id', and outputs a friendly message combining these values.
// Make sure to create the following inputs:
// status (Text)
// priority (Text)
// ticket_id (Number)
const message = `Ticket ${inputs.ticket_id} has status ${inputs.status} and priority ${inputs.priority}.`
// Make sure to create the following outputs:
// message (Text)
return {
message,
}
}
지금부터 다음 시간 계산하기
예에서 현재 시간은 2025-10-27T09:17:00Z입니다. 따라서 다음 코드는 2025-10-27T10:00:00Z를 리턴합니다.
module.exports = (inputs) => {
// This code calculates the next full hour from the current UTC time
// No inputs required
// Make sure to create the following outputs:
// nextHour (Date and time)
// Create a Date object for the current time
const nextHour = new Date()
// Round up to the next hour by:
// 1. Setting minutes, seconds, and milliseconds to 0
nextHour.setUTCMinutes(0, 0, 0)
// 2. Adding 1 hour
nextHour.setUTCHours(nextHour.getUTCHours() + 1)
return {
nextHour: nextHour.toISOString(),
}
}
이메일 주소의 서식 검증하기
module.exports = (inputs) => {
// This code takes a text input 'emailAddress',
// uses regex to do a basic check whether it is a valid email format,
// and outputs a boolean 'emailIsValid'.
// Make sure to create the following inputs:
// emailAddress (Text)
// Simple email regex pattern
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
const emailIsValid = emailRegex.test(inputs.emailAddress)
// Make sure to create the following outputs:
// emailIsValid (True/False)
return {
emailIsValid
}
}
이메일 주소 마스킹하기
이 예는 이메일 주소의 일부를 별표 문자로 바꿉니다. 예: "이메일 주소가 d******n@zendesk.com이 맞는지 확인해 주시겠어요?"
// This code takes an email address input and returns a masked version where the local part is partially replaced with '*', preserving the first and last characters.
// Make sure to create the following input:
// emailToMask (Text)
// Make sure to create the following output:
// maskedEmail (Text)
module.exports = (inputs) => {
const [emailName, emailDomain] = inputs.emailToMask.split("@")
let maskedEmailName = emailName
if (emailName.length > 2) {
maskedEmailName = emailName[0]
maskedEmailName += "*".repeat(emailName.length-2)
maskedEmailName += emailName[emailName.length-1]
}
return {
maskedEmail: `${maskedEmailName}@${emailDomain}`
}
}
내부 식별자를 사람이 읽을 수 있는 이름에 맵핑하기
이와 같은 맵핑은 드롭다운 티켓 필드의 태그와 같은 내부 ID를 드롭다운에 표시된 값과 같은 좀 더 사용자 친화적인 이름으로 전환하는 데 유용합니다.
- Slack 채널 ID를 채널 이름으로 전환하기
- Jira 프로젝트 ID를 프로젝트 이름으로 전환하기
- Zendesk 티켓 상태를 상응하는 JIRA 이슈 상태에 맵핑하기
const optionMap = {
option_01_ivory: 'ivory',
option_02_cream: 'cream',
option_03_white: 'white',
option_04_bone: 'bone',
}
module.exports = (inputs) => {
// This code takes a text input 'optionTag',
// and outputs the corresponding 'optionName' based on a predefined mapping.
// If the input is missing or does not match any tag, it returns an empty string.
// Make sure to create the following inputs:
// optionTag (Text)
const optionName = optionMap[inputs.optionTag] || ''
// Make sure to create the following outputs:
// optionName (Text)
return {
optionName,
}
}
목록에 있는 항목이 특정 문자로 시작하는지 확인하기
이 예에서는 목록에 있는 항목이 특정 문자로 시작하는지 확인합니다. 예를 들어, “customer”로 시작하는 항목을 검색하고 태그 목록에 [“critical_bug”, “customer_24601”, “escalation”]이 포함되어 있다면 “customer_24601”이 “customer”로 시작하기 때문에 결과는 true가 될 것입니다.
module.exports = (inputs) => {
// This code takes a text array 'tags' and a text string 'searchTerm',
// and outputs a boolean 'matchFound' indicating whether any tag begins with the searchTerm.
// Make sure to create the following inputs:
// tags (Text array)
// searchTerm (Text)
const matchFound = inputs.tags.some(tag => tag.startsWith(inputs.searchTerm))
// Make sure to create the following outputs:
// matchFound (True/False)
return {
matchFound
}
}
두 개의 값 목록 비교하기
이 예는 두 개의 목록을 비교하여 두 번째 목록에도 있는 첫 번째 목록의 모든 값을 제거합니다.
예를 들어, 티켓 참조 목록과 허용되지 않는 사용자 목록이 있다면 참조 목록에 있는 허용되지 않는 모든 사용자는 출력 목록에서 제외됩니다(cleanCCs). 이 방법은 티켓이나 사용자로부터 제거해야 할 태그를 필터링하는 데에도 사용할 수 있습니다.
module.exports = (inputs) => {
// This code takes two number arrays: ticketCCs and disallowedUsers,
// and outputs a number array cleanCCs which includes only those items from ticketCCs that are NOT in disallowedUsers.
// Make sure to create the following inputs:
// ticketCCs (Number array)
// disallowedUsers (Number array)
const cleanCCs = inputs.ticketCCs.filter(cc => !inputs.disallowedUsers.includes(cc))
// Make sure to create the following outputs:
// cleanCCs (Number array)
return {
cleanCCs,
}
}
텍스트 내에서 주문 ID 찾기
이 예는 티켓 댓글과 같은 텍스트 문자열에서 주문 ID를 추출합니다. 필요에 따라 특정 주문 ID 형식에 맞게 정규 표현식(/GO-\d{8,9}/)을 조정할 수 있습니다.
// Regex for order number: "GO-" followed by 8 or 9 digits
const ORDER_NUMBER_REGEX = /GO-\d{8,9}/
// Searches comment for order number and returns it if found.
const findOrderNumber = comment => comment.match(ORDER_NUMBER_REGEX)[0]
module.exports = (inputs) => {
// This code uses regex to look for an orderNumber with pattern "GO-" followed by 8 or 9 digits
// Make sure to create the following inputs:
// commentBody (Text)
const orderNumber = findOrderNumber(inputs.commentBody)
// Make sure to create the following outputs:
// orderNumber (Text)
// matchFound (True/False)
return {
orderNumber,
matchFound: Boolean(orderNumber),
}
}
무작위 번호 생성하기
이 예는 지정한 범위 내에서 무작위 숫자를 생성합니다. 값 52를 변경하여 무작위 숫자에 대해 원하는 상한을 설정할 수 있습니다.
module.exports = (inputs) => {
// This code outputs a random integer number between 1 and 52 inclusive.
// No inputs required.
// Make sure to create the following outputs:
// randomNumber (Number)
const randomNumber = Math.floor(Math.random() * 52) + 1
return {
randomNumber
}
}
1개와 7개 사이에서 3개의 무작위 번호 생성하기
module.exports = (inputs) => {
// This code outputs three unique random integer numbers between 1 and 7 inclusive.
// No inputs required.
// Make sure to create the following outputs:
// randomNumber1 (Number)
// randomNumber2 (Number)
// randomNumber3 (Number)
const numbers = []
while (numbers.length < 3) {
const candidate = Math.floor(Math.random() * 7) + 1
if (!numbers.includes(candidate)) {
numbers.push(candidate)
}
}
return {
randomNumber1: numbers[0],
randomNumber2: numbers[1],
randomNumber3: numbers[2]
}
}
module.exports = (inputs) => {
// This code outputs an array of three unique random numbers between 1 and 7 inclusive.
// No inputs required.
// Make sure to create the following outputs:
// randomNumbers (Number array)
const numbers = []
while (numbers.length < 3) {
const candidate = Math.floor(Math.random() * 7) + 1
if (!numbers.includes(candidate)) {
numbers.push(candidate)
}
}
return {
randomNumbers: numbers
}
}