Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

1.7 KB
Raw Blame
import { createAction, Property } from '@activepieces/pieces-framework';
import { jiraDataCenterAuth } from '../../auth';
import { HttpMethod } from '@activepieces/pieces-common';
import { sendJiraRequest } from '../common';
import { getProjectIdDropdown, getIssueIdDropdown } from '../common/props';

export const listIssueCommentsAction = createAction({
	auth: jiraDataCenterAuth,
	name: 'list_issue_comments',
	classification: 'SEARCH',
	displayName: 'List Issue Comments',
	description: 'Returns all comments for an issue.',
	audience: 'both',
	aiMetadata: {
		description:
			'Returns the comments on a Jira Data Center/Server issue, ordered by creation date (ascending or descending) and capped by a limit. Use to read the discussion history of an issue. Read-only and idempotent.',
		idempotent: true,
	},
	props: {
		projectId: getProjectIdDropdown(),
		issueId: getIssueIdDropdown({ refreshers: ['projectId'] }),
		orderBy: Property.StaticDropdown({
			displayName: 'Order By',
			required: true,
			defaultValue: '-created',
			options: {
				disabled: false,
				options: [
					{
						label: 'Created (Descending)',
						value: '-created',
					},
					{
						label: 'Created (Ascending)',
						value: '+created',
					},
				],
			},
		}),
		limit: Property.Number({
			displayName: 'Limit',
			description: 'Maximum number of results',
			required: true,
			defaultValue: 10,
		}),
	},
	async run(context) {
		const { issueId, orderBy, limit } = context.propsValue;

		const response = await sendJiraRequest({
			method: HttpMethod.GET,
			url: `issue/${issueId}/comment`,
			auth: context.auth,
			queryParams: {
				orderBy: orderBy,
				maxResults: limit.toString(),
			},
		});
		return response.body;
	},
});