-
Notifications
You must be signed in to change notification settings - Fork 5.5k
ServiceNow - actions to create tickets #18694
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Thank you so much for submitting this! We've added it to our backlog to review, and our team has been notified. |
Thanks for submitting this PR! When we review PRs, we follow the Pipedream component guidelines. If you're not familiar, here's a quick checklist:
|
WalkthroughAdds ServiceNow app helpers, shared severity constants, two new actions to create Case and Incident trouble tickets, and bumps the ServiceNow component package version and platform dependency. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor User
participant Action as Create Action (Case/Incident)
participant App as ServiceNow App
participant API as ServiceNow API
User->>Action: Provide inputs (name, description, severity, ...)
Action->>App: buildNotes(workNote, comment)
Action->>App: buildRelatedParties({...})
Action->>App: buildChannel(channelName)
alt Creating ticket
Action->>App: createTroubleTicket({ ticketType: "Case" | "Incident", ... })
App->>App: baseUrl() & authHeaders()
App->>API: POST /trouble_ticket (payload)
API-->>App: 201 Created / Error
App-->>Action: API response
Action-->>User: Export summary + response
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
components/servicenow/actions/create-incident/create-incident.mjs (1)
66-108
: Consider consolidating channelName and contactMethod propDefinitions.Both
create-case
andcreate-incident
actions use similar concepts (channelName
vscontactMethod
) that map to the same API parameter. The propDefinitions inservicenow.app.mjs
have nearly identical descriptions:
channelName
: "The channel that the ticket was created through."contactMethod
: "Method of contact that the ticket was created through."Consider using a single propDefinition (e.g.,
channelName
) for both actions to reduce duplication and maintain consistency, unless there's a specific ServiceNow business reason to distinguish between them.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (5)
components/servicenow/actions/create-case/create-case.mjs
(1 hunks)components/servicenow/actions/create-incident/create-incident.mjs
(1 hunks)components/servicenow/common/constants.mjs
(1 hunks)components/servicenow/package.json
(2 hunks)components/servicenow/servicenow.app.mjs
(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
components/servicenow/actions/create-case/create-case.mjs (2)
components/servicenow/actions/create-incident/create-incident.mjs (3)
notes
(83-86)relatedParties
(88-91)response
(93-103)components/servicenow/servicenow.app.mjs (1)
notes
(117-117)
components/servicenow/actions/create-incident/create-incident.mjs (2)
components/servicenow/actions/create-case/create-case.mjs (3)
notes
(83-86)relatedParties
(88-91)response
(93-103)components/servicenow/servicenow.app.mjs (1)
notes
(117-117)
components/servicenow/servicenow.app.mjs (3)
components/servicenow/common/constants.mjs (2)
DEFAULT_SEVERITY_OPTIONS
(1-18)INCIDENT_SEVERITY_OPTIONS
(20-26)components/servicenow/actions/create-case/create-case.mjs (1)
notes
(83-86)components/servicenow/actions/create-incident/create-incident.mjs (1)
notes
(83-86)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Lint Code Base
- GitHub Check: Publish TypeScript components
- GitHub Check: Verify TypeScript components
🔇 Additional comments (12)
components/servicenow/package.json (1)
3-3
: LGTM!The version bump to 0.7.0 and platform dependency update to ^3.1.0 appropriately reflect the addition of new actions and features in this PR.
Also applies to: 16-16
components/servicenow/common/constants.mjs (2)
1-18
: LGTM!The severity options are well-structured with clear labels and string values that align with typical API enum patterns.
20-31
: LGTM!The incident severity options appropriately extend the default options with an additional "Planning" level, and the export structure is clean.
components/servicenow/servicenow.app.mjs (4)
1-7
: LGTM!Clean imports and constant destructuring from the new constants module.
93-104
: LGTM!The authentication methods correctly construct the base URL and authorization headers using OAuth bearer token.
105-149
: LGTM!The helper methods properly handle empty/undefined inputs and return appropriate data structures for the ServiceNow API.
150-180
: Confirm field mappings against the SD-WAN Trouble Ticket API spec
The POST endpoint/api/sn_ind_tsm_sdwan/ticket/troubleTicket
correctly supports both Case and Incident; ensure the request-body fields (notes
,relatedParties
,channel
,ticketType
, etc.) align with the API’s supported fields.components/servicenow/actions/create-case/create-case.mjs (3)
1-8
: LGTM!The component key follows the correct format
app_name_slug-slugified-component-name
as per Pipedream guidelines.
9-65
: LGTM!All prop definitions correctly reference the ServiceNow app's propDefinitions.
66-108
: LGTM!The action correctly builds notes and related parties, validates required fields, and calls the ServiceNow API with appropriate parameters for creating a case.
components/servicenow/actions/create-incident/create-incident.mjs (2)
1-8
: LGTM!The component key follows the correct format as per Pipedream guidelines.
9-65
: LGTM!All prop definitions correctly reference the ServiceNow app's propDefinitions, using incident-specific fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
components/servicenow/actions/create-case/create-case.mjs (1)
84-86
: Consider marking description as required in propDefinition.Instead of validating at runtime, mark the
description
prop as required in its propDefinition. This provides:
- Earlier validation before the action runs
- Clearer error messages to users
- Better developer experience
Update the propDefinition in
servicenow.app.mjs
:description: { type: "string", label: "Description", description: "Description of the case", optional: false, // or simply omit 'optional' as props are required by default },Then remove the runtime validation from this action.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
components/servicenow/actions/create-case/create-case.mjs
(1 hunks)components/servicenow/actions/create-incident/create-incident.mjs
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- components/servicenow/actions/create-incident/create-incident.mjs
🧰 Additional context used
🧬 Code graph analysis (1)
components/servicenow/actions/create-case/create-case.mjs (2)
components/servicenow/actions/create-incident/create-incident.mjs (3)
notes
(88-91)relatedParties
(93-96)response
(98-108)components/servicenow/servicenow.app.mjs (1)
notes
(117-117)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Publish TypeScript components
- GitHub Check: Verify TypeScript components
- GitHub Check: pnpm publish
- GitHub Check: Lint Code Base
🔇 Additional comments (3)
components/servicenow/actions/create-case/create-case.mjs (3)
1-13
: LGTM! Metadata follows component guidelines.The component key follows the required format, and all metadata fields are properly configured.
88-112
: LGTM! Action logic follows established patterns.The implementation correctly uses the servicenow app helper methods and follows the same structure as create-incident. The response handling and summary export are appropriate.
14-70
: Props naming is appropriate and intentional. The property names differ because ServiceNow usesaccountId
,contactId
, andchannelName
for cases andcompanyId
,userId
, andcontactMethod
for incidents—no changes needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
components/servicenow/actions/create-incident/create-incident.mjs (1)
14-70
: Consider alignment with Case action prop naming.The props are correctly defined, but there's a naming inconsistency between actions:
- Create Incident uses
contactMethod
(line 40-44)- Create Case uses
channelName
(in create-case.mjs)Both map to
contact_type
in the API and serve the same purpose. Consider standardizing the prop name across both actions for consistency.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
components/servicenow/actions/create-case/create-case.mjs
(1 hunks)components/servicenow/actions/create-incident/create-incident.mjs
(1 hunks)components/servicenow/servicenow.app.mjs
(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
components/servicenow/actions/create-case/create-case.mjs (2)
components/servicenow/actions/create-incident/create-incident.mjs (4)
channel
(84-84)notes
(91-94)relatedParties
(86-89)response
(96-108)components/servicenow/servicenow.app.mjs (1)
notes
(117-117)
components/servicenow/servicenow.app.mjs (3)
components/servicenow/common/constants.mjs (2)
DEFAULT_SEVERITY_OPTIONS
(1-18)INCIDENT_SEVERITY_OPTIONS
(20-26)components/servicenow/actions/create-case/create-case.mjs (1)
notes
(86-89)components/servicenow/actions/create-incident/create-incident.mjs (1)
notes
(91-94)
components/servicenow/actions/create-incident/create-incident.mjs (2)
components/servicenow/actions/create-case/create-case.mjs (4)
channel
(84-84)relatedParties
(91-94)notes
(86-89)response
(96-108)components/servicenow/servicenow.app.mjs (1)
notes
(117-117)
🔇 Additional comments (14)
components/servicenow/actions/create-case/create-case.mjs (4)
1-13
: LGTM!The component metadata and imports are well-structured. The documentation link addresses the past review comment.
14-70
: LGTM!Props are correctly defined using propDefinitions from the ServiceNow app, maintaining consistency with the component pattern.
71-95
: LGTM!The destructuring and helper method calls are clean and consistent with the established pattern.
96-113
: LGTM!The API call structure correctly passes the data object to
createTroubleTicket
, which forwards it as the request payload. The summary message is clear and appropriate.components/servicenow/actions/create-incident/create-incident.mjs (3)
1-13
: LGTM!The component metadata and imports follow the same pattern as the create-case action, maintaining consistency across the codebase.
71-95
: LGTM!The destructuring and helper method calls are correctly implemented. The use of
companyId
/userId
for incidents (vsaccountId
/contactId
for cases) aligns with ServiceNow's data model where incidents relate to companies and users, while cases relate to accounts and contacts.
96-113
: LGTM!The API call structure and response handling are correctly implemented, mirroring the create-case action with the appropriate ticket type.
components/servicenow/servicenow.app.mjs (7)
1-8
: LGTM!The imports and constant destructuring are correctly structured and align with the platform dependencies.
12-48
: LGTM!The propDefinitions are well-structured with appropriate types, labels, descriptions, and options. The distinction between case and incident severity options is correctly implemented.
49-54
: LGTM!The label/description mismatch from the past review comment has been addressed. The label "Contact Method" now correctly aligns with the description.
55-90
: LGTM!The propDefinitions correctly use backticks for field names like
Sys_id
, addressing the past review comment. All descriptions are clear and consistent.
92-112
: LGTM!The helper methods for URL construction, authentication headers, and channel building are correctly implemented with appropriate null handling.
113-149
: LGTM!Both helper methods correctly construct the ServiceNow API payload structures with appropriate filtering and null handling. The
buildRelatedParties
method correctly filters out entries without IDs before mapping.
150-160
: LGTM!The
createTroubleTicket
method correctly constructs and executes the API request. The past review comment acknowledged that having a single request method is acceptable for this app given it's the only endpoint being used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Note to @vunguyenhung : we couldn't get the ServiceNow setup working for these components. It seems additional app setup is needed which we couldn't really figure out, but decided to move on with these two actions since they are following the API specs. |
Hey @GTFalcao, I can setup the ServiceNow dev instance on my side. Please refer to 1PW, I put my working creds (client id, client secret, instance name) there. |
@vunguyenhung you also need to add the Telecommunications Assurance Workflows application to create the tables this API uses (from the API docs). I couldn't figure out how to do it and at least on this support thread from 2019 it says it's not possible to install apps in a dev instance. Also, if someone tries to use your (client id, client secret, instance name) on Pipedream, it opens a ServiceNow tab asking you to log in with the username and password, but when you put in the username and password of the account it doesn't accept it for some reason. You should see what I'm talking about if you do it in an incognito window or maybe if you clear your ServiceNow cookies. |
Closes #16112
Summary by CodeRabbit