mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
feat(tools): added zendesk, pylon, intercom, & mailchimp (#2126)
* feat(tools): added zendesk, pylon, intercom, & mailchimp * finish zendesk and pylon * updated docs
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -33,10 +33,12 @@ import {
|
||||
HunterIOIcon,
|
||||
ImageIcon,
|
||||
IncidentioIcon,
|
||||
IntercomIcon,
|
||||
JinaAIIcon,
|
||||
JiraIcon,
|
||||
LinearIcon,
|
||||
LinkupIcon,
|
||||
MailchimpIcon,
|
||||
Mem0Icon,
|
||||
MicrosoftExcelIcon,
|
||||
MicrosoftOneDriveIcon,
|
||||
@@ -57,6 +59,7 @@ import {
|
||||
PipedriveIcon,
|
||||
PostgresIcon,
|
||||
PosthogIcon,
|
||||
PylonIcon,
|
||||
QdrantIcon,
|
||||
RedditIcon,
|
||||
ResendIcon,
|
||||
@@ -83,6 +86,7 @@ import {
|
||||
WikipediaIcon,
|
||||
xIcon,
|
||||
YouTubeIcon,
|
||||
ZendeskIcon,
|
||||
ZepIcon,
|
||||
} from '@/components/icons'
|
||||
|
||||
@@ -90,6 +94,7 @@ type IconComponent = ComponentType<SVGProps<SVGSVGElement>>
|
||||
|
||||
export const blockTypeToIconMap: Record<string, IconComponent> = {
|
||||
zep: ZepIcon,
|
||||
zendesk: ZendeskIcon,
|
||||
youtube: YouTubeIcon,
|
||||
x: xIcon,
|
||||
wikipedia: WikipediaIcon,
|
||||
@@ -121,6 +126,7 @@ export const blockTypeToIconMap: Record<string, IconComponent> = {
|
||||
resend: ResendIcon,
|
||||
reddit: RedditIcon,
|
||||
qdrant: QdrantIcon,
|
||||
pylon: PylonIcon,
|
||||
posthog: PosthogIcon,
|
||||
postgresql: PostgresIcon,
|
||||
pipedrive: PipedriveIcon,
|
||||
@@ -140,11 +146,13 @@ export const blockTypeToIconMap: Record<string, IconComponent> = {
|
||||
microsoft_excel: MicrosoftExcelIcon,
|
||||
memory: BrainIcon,
|
||||
mem0: Mem0Icon,
|
||||
mailchimp: MailchimpIcon,
|
||||
linkup: LinkupIcon,
|
||||
linear: LinearIcon,
|
||||
knowledge: PackageSearchIcon,
|
||||
jira: JiraIcon,
|
||||
jina: JinaAIIcon,
|
||||
intercom: IntercomIcon,
|
||||
incidentio: IncidentioIcon,
|
||||
image_generator: ImageIcon,
|
||||
hunter: HunterIOIcon,
|
||||
|
||||
@@ -0,0 +1,358 @@
|
||||
---
|
||||
title: Intercom
|
||||
description: Manage contacts, companies, conversations, tickets, and messages in Intercom
|
||||
---
|
||||
|
||||
import { BlockInfoCard } from "@/components/ui/block-info-card"
|
||||
|
||||
<BlockInfoCard
|
||||
type="intercom"
|
||||
color="#E0E0E0"
|
||||
/>
|
||||
|
||||
{/* MANUAL-CONTENT-START:intro */}
|
||||
[Intercom](https://www.intercom.com/) is a leading customer communications platform that enables you to manage and automate your interactions with contacts, companies, conversations, tickets, and messages—all in one place. The Intercom integration in Sim lets your agents programmatically manage customer relationships, support requests, and conversations directly from your automated workflows.
|
||||
|
||||
With the Intercom tools, you can:
|
||||
|
||||
- **Contacts Management:** Create, get, update, list, search, and delete contacts—automate your CRM processes and keep your customer records up-to-date.
|
||||
- **Company Management:** Create new companies, retrieve company details, and list all companies related to your users or business clients.
|
||||
- **Conversation Handling:** Get, list, reply to, and search through conversations—allowing agents to track ongoing support threads, provide answers, and automate follow-up actions.
|
||||
- **Ticket Management:** Create and retrieve tickets programmatically, helping you automate customer service, support issue tracking, and workflow escalations.
|
||||
- **Send Messages:** Trigger messages to users or leads for onboarding, support, or marketing, all from within your workflow automation.
|
||||
|
||||
By integrating Intercom tools into Sim, you empower your workflows to communicate directly with your users, automate customer support processes, manage leads, and streamline communications at scale. Whether you need to create new contacts, keep customer data synchronized, manage support tickets, or send personalized engagement messages, the Intercom tools provide a comprehensive way to manage customer interactions as part of your intelligent automations.
|
||||
{/* MANUAL-CONTENT-END */}
|
||||
|
||||
|
||||
## Usage Instructions
|
||||
|
||||
Integrate Intercom into the workflow. Can create, get, update, list, search, and delete contacts; create, get, and list companies; get, list, reply, and search conversations; create and get tickets; and create messages.
|
||||
|
||||
|
||||
|
||||
## Tools
|
||||
|
||||
### `intercom_create_contact`
|
||||
|
||||
Create a new contact in Intercom with email, external_id, or role
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `email` | string | No | The contact's email address |
|
||||
| `external_id` | string | No | A unique identifier for the contact provided by the client |
|
||||
| `phone` | string | No | The contact's phone number |
|
||||
| `name` | string | No | The contact's name |
|
||||
| `avatar` | string | No | An avatar image URL for the contact |
|
||||
| `signed_up_at` | number | No | The time the user signed up as a Unix timestamp |
|
||||
| `last_seen_at` | number | No | The time the user was last seen as a Unix timestamp |
|
||||
| `owner_id` | string | No | The id of an admin that has been assigned account ownership of the contact |
|
||||
| `unsubscribed_from_emails` | boolean | No | Whether the contact is unsubscribed from emails |
|
||||
| `custom_attributes` | string | No | Custom attributes as JSON object \(e.g., \{"attribute_name": "value"\}\) |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Created contact data |
|
||||
|
||||
### `intercom_get_contact`
|
||||
|
||||
Get a single contact by ID from Intercom
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `contactId` | string | Yes | Contact ID to retrieve |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Contact data |
|
||||
|
||||
### `intercom_update_contact`
|
||||
|
||||
Update an existing contact in Intercom
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `contactId` | string | Yes | Contact ID to update |
|
||||
| `email` | string | No | The contact's email address |
|
||||
| `phone` | string | No | The contact's phone number |
|
||||
| `name` | string | No | The contact's name |
|
||||
| `avatar` | string | No | An avatar image URL for the contact |
|
||||
| `signed_up_at` | number | No | The time the user signed up as a Unix timestamp |
|
||||
| `last_seen_at` | number | No | The time the user was last seen as a Unix timestamp |
|
||||
| `owner_id` | string | No | The id of an admin that has been assigned account ownership of the contact |
|
||||
| `unsubscribed_from_emails` | boolean | No | Whether the contact is unsubscribed from emails |
|
||||
| `custom_attributes` | string | No | Custom attributes as JSON object \(e.g., \{"attribute_name": "value"\}\) |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Updated contact data |
|
||||
|
||||
### `intercom_list_contacts`
|
||||
|
||||
List all contacts from Intercom with pagination support
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `per_page` | number | No | Number of results per page \(max: 150\) |
|
||||
| `starting_after` | string | No | Cursor for pagination - ID to start after |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | List of contacts |
|
||||
|
||||
### `intercom_search_contacts`
|
||||
|
||||
Search for contacts in Intercom using a query
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `query` | string | Yes | Search query \(e.g., \{"field":"email","operator":"=","value":"user@example.com"\}\) |
|
||||
| `per_page` | number | No | Number of results per page \(max: 150\) |
|
||||
| `starting_after` | string | No | Cursor for pagination |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Search results |
|
||||
|
||||
### `intercom_delete_contact`
|
||||
|
||||
Delete a contact from Intercom by ID
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `contactId` | string | Yes | Contact ID to delete |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Deletion result |
|
||||
|
||||
### `intercom_create_company`
|
||||
|
||||
Create or update a company in Intercom
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `company_id` | string | Yes | Your unique identifier for the company |
|
||||
| `name` | string | No | The name of the company |
|
||||
| `website` | string | No | The company website |
|
||||
| `plan` | string | No | The company plan name |
|
||||
| `size` | number | No | The number of employees in the company |
|
||||
| `industry` | string | No | The industry the company operates in |
|
||||
| `monthly_spend` | number | No | How much revenue the company generates for your business |
|
||||
| `custom_attributes` | string | No | Custom attributes as JSON object |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Created or updated company data |
|
||||
|
||||
### `intercom_get_company`
|
||||
|
||||
Retrieve a single company by ID from Intercom
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `companyId` | string | Yes | Company ID to retrieve |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Company data |
|
||||
|
||||
### `intercom_list_companies`
|
||||
|
||||
List all companies from Intercom with pagination support
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `per_page` | number | No | Number of results per page |
|
||||
| `page` | number | No | Page number |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | List of companies |
|
||||
|
||||
### `intercom_get_conversation`
|
||||
|
||||
Retrieve a single conversation by ID from Intercom
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `conversationId` | string | Yes | Conversation ID to retrieve |
|
||||
| `display_as` | string | No | Set to "plaintext" to retrieve messages in plain text |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Conversation data |
|
||||
|
||||
### `intercom_list_conversations`
|
||||
|
||||
List all conversations from Intercom with pagination support
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `per_page` | number | No | Number of results per page \(max: 150\) |
|
||||
| `starting_after` | string | No | Cursor for pagination |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | List of conversations |
|
||||
|
||||
### `intercom_reply_conversation`
|
||||
|
||||
Reply to a conversation as an admin in Intercom
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `conversationId` | string | Yes | Conversation ID to reply to |
|
||||
| `message_type` | string | Yes | Message type: "comment" or "note" |
|
||||
| `body` | string | Yes | The text body of the reply |
|
||||
| `admin_id` | string | Yes | The ID of the admin authoring the reply |
|
||||
| `attachment_urls` | string | No | Comma-separated list of image URLs \(max 10\) |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Updated conversation with reply |
|
||||
|
||||
### `intercom_search_conversations`
|
||||
|
||||
Search for conversations in Intercom using a query
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `query` | string | Yes | Search query as JSON object |
|
||||
| `per_page` | number | No | Number of results per page \(max: 150\) |
|
||||
| `starting_after` | string | No | Cursor for pagination |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Search results |
|
||||
|
||||
### `intercom_create_ticket`
|
||||
|
||||
Create a new ticket in Intercom
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `ticket_type_id` | string | Yes | The ID of the ticket type |
|
||||
| `contacts` | string | Yes | JSON array of contact identifiers \(e.g., \[\{"id": "contact_id"\}\]\) |
|
||||
| `ticket_attributes` | string | Yes | JSON object with ticket attributes including _default_title_ and _default_description_ |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Created ticket data |
|
||||
|
||||
### `intercom_get_ticket`
|
||||
|
||||
Retrieve a single ticket by ID from Intercom
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `ticketId` | string | Yes | Ticket ID to retrieve |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Ticket data |
|
||||
|
||||
### `intercom_create_message`
|
||||
|
||||
Create and send a new admin-initiated message in Intercom
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `message_type` | string | Yes | Message type: "inapp" or "email" |
|
||||
| `subject` | string | No | The subject of the message \(for email type\) |
|
||||
| `body` | string | Yes | The body of the message |
|
||||
| `from_type` | string | Yes | Sender type: "admin" |
|
||||
| `from_id` | string | Yes | The ID of the admin sending the message |
|
||||
| `to_type` | string | Yes | Recipient type: "contact" |
|
||||
| `to_id` | string | Yes | The ID of the contact receiving the message |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Created message data |
|
||||
|
||||
|
||||
|
||||
## Notes
|
||||
|
||||
- Category: `tools`
|
||||
- Type: `intercom`
|
||||
File diff suppressed because it is too large
Load Diff
@@ -28,11 +28,13 @@
|
||||
"hunter",
|
||||
"image_generator",
|
||||
"incidentio",
|
||||
"intercom",
|
||||
"jina",
|
||||
"jira",
|
||||
"knowledge",
|
||||
"linear",
|
||||
"linkup",
|
||||
"mailchimp",
|
||||
"mem0",
|
||||
"memory",
|
||||
"microsoft_excel",
|
||||
@@ -52,6 +54,7 @@
|
||||
"pipedrive",
|
||||
"postgresql",
|
||||
"posthog",
|
||||
"pylon",
|
||||
"qdrant",
|
||||
"reddit",
|
||||
"resend",
|
||||
@@ -83,6 +86,7 @@
|
||||
"wikipedia",
|
||||
"x",
|
||||
"youtube",
|
||||
"zendesk",
|
||||
"zep"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,801 @@
|
||||
---
|
||||
title: Pylon
|
||||
description: Manage customer support issues, accounts, contacts, users, teams, and tags in Pylon
|
||||
---
|
||||
|
||||
import { BlockInfoCard } from "@/components/ui/block-info-card"
|
||||
|
||||
<BlockInfoCard
|
||||
type="pylon"
|
||||
color="#E8F4FA"
|
||||
/>
|
||||
|
||||
{/* MANUAL-CONTENT-START:intro */}
|
||||
[Pylon](https://usepylon.com/) is an advanced customer support and success platform designed to help you manage every aspect of your customer relationships—from support issues to accounts, contacts, users, teams, and beyond. Pylon empowers support and success teams to operate efficiently and programmatically with a rich API and comprehensive toolset.
|
||||
|
||||
With Pylon in Sim, you can:
|
||||
|
||||
- **Manage Support Issues:**
|
||||
- List, create, get, update, and delete support issues for efficient case tracking.
|
||||
- Search and snooze issues to help agents stay focused and organized.
|
||||
- Handle issue followers and external issues for seamless collaboration with internal and external stakeholders.
|
||||
|
||||
- **Full Account Management:**
|
||||
- List, create, get, update, and delete customer accounts.
|
||||
- Bulk update accounts programmatically.
|
||||
- Search accounts to quickly find customer information relevant for support or outreach.
|
||||
|
||||
- **Contact Management:**
|
||||
- List, create, get, update, delete, and search contacts—manage everyone connected to your accounts.
|
||||
|
||||
- **User and Team Operations:**
|
||||
- List, get, update, and search users in your Pylon workspace.
|
||||
- List, create, get, and update teams to structure your support organization and workflows.
|
||||
|
||||
- **Tagging and Organization:**
|
||||
- List, get, create, update, and delete tags for categorizing issues, accounts, or contacts.
|
||||
|
||||
- **Message Handling:**
|
||||
- Redact sensitive message content directly from your workflows for privacy and compliance.
|
||||
|
||||
By integrating Pylon tools into Sim, your agents can automate every aspect of support operations:
|
||||
- Automatically open, update, or triage new issues when customer events occur.
|
||||
- Maintain synchronized account and contact data across your tech stack.
|
||||
- Route conversations, handle escalations, and organize your support data using tags and teams.
|
||||
- Ensure sensitive data is properly managed by redacting messages as needed.
|
||||
|
||||
Pylon's endpoints provide granular control for full-lifecycle management of customer issues and relationships. Whether scaling a support desk, powering proactive customer success, or integrating with other systems, Pylon in Sim enables best-in-class CRM automation—securely, flexibly, and at scale.
|
||||
{/* MANUAL-CONTENT-END */}
|
||||
|
||||
|
||||
## Usage Instructions
|
||||
|
||||
Integrate Pylon into the workflow. Manage issues (list, create, get, update, delete, search, snooze, followers, external issues), accounts (list, create, get, update, delete, bulk update, search), contacts (list, create, get, update, delete, search), users (list, get, update, search), teams (list, get, create, update), tags (list, get, create, update, delete), and messages (redact).
|
||||
|
||||
|
||||
|
||||
## Tools
|
||||
|
||||
### `pylon_list_issues`
|
||||
|
||||
Retrieve a list of issues within a specified time range
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
| `startTime` | string | Yes | Start time in RFC3339 format \(e.g., 2024-01-01T00:00:00Z\) |
|
||||
| `endTime` | string | Yes | End time in RFC3339 format \(e.g., 2024-01-31T23:59:59Z\) |
|
||||
| `cursor` | string | No | Pagination cursor for next page of results |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | List of issues |
|
||||
|
||||
### `pylon_create_issue`
|
||||
|
||||
Create a new issue with specified properties
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
| `title` | string | Yes | Issue title |
|
||||
| `bodyHtml` | string | Yes | Issue body in HTML format |
|
||||
| `accountId` | string | No | Account ID to associate with issue |
|
||||
| `assigneeId` | string | No | User ID to assign issue to |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Created issue data |
|
||||
|
||||
### `pylon_get_issue`
|
||||
|
||||
Fetch a specific issue by ID
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
| `issueId` | string | Yes | The ID of the issue to retrieve |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Issue data |
|
||||
|
||||
### `pylon_update_issue`
|
||||
|
||||
Update an existing issue
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
| `issueId` | string | Yes | The ID of the issue to update |
|
||||
| `state` | string | No | Issue state |
|
||||
| `assigneeId` | string | No | User ID to assign issue to |
|
||||
| `teamId` | string | No | Team ID to assign issue to |
|
||||
| `tags` | string | No | Comma-separated tag IDs |
|
||||
| `customFields` | string | No | Custom fields as JSON object |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Updated issue data |
|
||||
|
||||
### `pylon_delete_issue`
|
||||
|
||||
Remove an issue by ID
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
| `issueId` | string | Yes | The ID of the issue to delete |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Deletion result |
|
||||
|
||||
### `pylon_search_issues`
|
||||
|
||||
Query issues using filters
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
| `filter` | string | Yes | Filter criteria as JSON string |
|
||||
| `cursor` | string | No | Pagination cursor for next page of results |
|
||||
| `limit` | number | No | Maximum number of results to return |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Search results |
|
||||
|
||||
### `pylon_snooze_issue`
|
||||
|
||||
Postpone issue visibility until specified time
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
| `issueId` | string | Yes | The ID of the issue to snooze |
|
||||
| `snoozeUntil` | string | Yes | RFC3339 timestamp when issue should reappear \(e.g., 2024-01-01T00:00:00Z\) |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Snoozed issue data |
|
||||
|
||||
### `pylon_list_issue_followers`
|
||||
|
||||
Get list of followers for a specific issue
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
| `issueId` | string | Yes | The ID of the issue |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Followers list |
|
||||
|
||||
### `pylon_manage_issue_followers`
|
||||
|
||||
Add or remove followers from an issue
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
| `issueId` | string | Yes | The ID of the issue |
|
||||
| `userIds` | string | No | Comma-separated user IDs to add/remove |
|
||||
| `contactIds` | string | No | Comma-separated contact IDs to add/remove |
|
||||
| `operation` | string | No | Operation to perform: "add" or "remove" \(default: "add"\) |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Updated followers list |
|
||||
|
||||
### `pylon_link_external_issue`
|
||||
|
||||
Link an issue to an external system issue
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
| `issueId` | string | Yes | The ID of the Pylon issue |
|
||||
| `externalIssueId` | string | Yes | The ID of the external issue |
|
||||
| `source` | string | Yes | The source system \(e.g., "jira", "linear", "github"\) |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Linked external issue data |
|
||||
|
||||
### `pylon_list_accounts`
|
||||
|
||||
Retrieve a paginated list of accounts
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
| `limit` | string | No | Number of accounts to return \(1-1000, default 100\) |
|
||||
| `cursor` | string | No | Pagination cursor for next page of results |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | List of accounts |
|
||||
|
||||
### `pylon_create_account`
|
||||
|
||||
Create a new account with specified properties
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
| `name` | string | Yes | Account name |
|
||||
| `domains` | string | No | Comma-separated list of domains |
|
||||
| `primaryDomain` | string | No | Primary domain for the account |
|
||||
| `customFields` | string | No | Custom fields as JSON object |
|
||||
| `tags` | string | No | Comma-separated tag IDs |
|
||||
| `channels` | string | No | Comma-separated channel IDs |
|
||||
| `externalIds` | string | No | Comma-separated external IDs |
|
||||
| `ownerId` | string | No | Owner user ID |
|
||||
| `logoUrl` | string | No | URL to account logo |
|
||||
| `subaccountIds` | string | No | Comma-separated subaccount IDs |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Created account data |
|
||||
|
||||
### `pylon_get_account`
|
||||
|
||||
Retrieve a single account by ID
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
| `accountId` | string | Yes | Account ID to retrieve |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Account data |
|
||||
|
||||
### `pylon_update_account`
|
||||
|
||||
Update an existing account with new properties
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
| `accountId` | string | Yes | Account ID to update |
|
||||
| `name` | string | No | Account name |
|
||||
| `domains` | string | No | Comma-separated list of domains |
|
||||
| `primaryDomain` | string | No | Primary domain for the account |
|
||||
| `customFields` | string | No | Custom fields as JSON object |
|
||||
| `tags` | string | No | Comma-separated tag IDs |
|
||||
| `channels` | string | No | Comma-separated channel IDs |
|
||||
| `externalIds` | string | No | Comma-separated external IDs |
|
||||
| `ownerId` | string | No | Owner user ID |
|
||||
| `logoUrl` | string | No | URL to account logo |
|
||||
| `subaccountIds` | string | No | Comma-separated subaccount IDs |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Updated account data |
|
||||
|
||||
### `pylon_delete_account`
|
||||
|
||||
Remove an account by ID
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
| `accountId` | string | Yes | Account ID to delete |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Deletion confirmation |
|
||||
|
||||
### `pylon_bulk_update_accounts`
|
||||
|
||||
Update multiple accounts at once
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
| `accountIds` | string | Yes | Comma-separated account IDs to update |
|
||||
| `customFields` | string | No | Custom fields as JSON object |
|
||||
| `tags` | string | No | Comma-separated tag IDs |
|
||||
| `ownerId` | string | No | Owner user ID |
|
||||
| `tagsApplyMode` | string | No | Tag application mode: append_only, remove_only, or replace |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Bulk updated accounts data |
|
||||
|
||||
### `pylon_search_accounts`
|
||||
|
||||
Search accounts with custom filters
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
| `filter` | string | Yes | Filter as JSON string with field/operator/value structure |
|
||||
| `limit` | string | No | Number of accounts to return \(1-1000, default 100\) |
|
||||
| `cursor` | string | No | Pagination cursor for next page of results |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Search results |
|
||||
|
||||
### `pylon_list_contacts`
|
||||
|
||||
Retrieve a list of contacts
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
| `cursor` | string | No | Pagination cursor for next page of results |
|
||||
| `limit` | string | No | Maximum number of contacts to return |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | List of contacts |
|
||||
|
||||
### `pylon_create_contact`
|
||||
|
||||
Create a new contact with specified properties
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
| `name` | string | Yes | Contact name |
|
||||
| `email` | string | No | Contact email address |
|
||||
| `accountId` | string | No | Account ID to associate with contact |
|
||||
| `accountExternalId` | string | No | External account ID to associate with contact |
|
||||
| `avatarUrl` | string | No | URL for contact avatar image |
|
||||
| `customFields` | string | No | Custom fields as JSON object |
|
||||
| `portalRole` | string | No | Portal role for the contact |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Created contact data |
|
||||
|
||||
### `pylon_get_contact`
|
||||
|
||||
Retrieve a specific contact by ID
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
| `contactId` | string | Yes | Contact ID to retrieve |
|
||||
| `cursor` | string | No | Pagination cursor for next page of results |
|
||||
| `limit` | string | No | Maximum number of items to return |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Contact data |
|
||||
|
||||
### `pylon_update_contact`
|
||||
|
||||
Update an existing contact with specified properties
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
| `contactId` | string | Yes | Contact ID to update |
|
||||
| `name` | string | No | Contact name |
|
||||
| `email` | string | No | Contact email address |
|
||||
| `accountId` | string | No | Account ID to associate with contact |
|
||||
| `accountExternalId` | string | No | External account ID to associate with contact |
|
||||
| `avatarUrl` | string | No | URL for contact avatar image |
|
||||
| `customFields` | string | No | Custom fields as JSON object |
|
||||
| `portalRole` | string | No | Portal role for the contact |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Updated contact data |
|
||||
|
||||
### `pylon_delete_contact`
|
||||
|
||||
Delete a specific contact by ID
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
| `contactId` | string | Yes | Contact ID to delete |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Delete operation result |
|
||||
|
||||
### `pylon_search_contacts`
|
||||
|
||||
Search for contacts using a filter
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
| `filter` | string | Yes | Filter as JSON object |
|
||||
| `limit` | string | No | Maximum number of contacts to return |
|
||||
| `cursor` | string | No | Pagination cursor for next page of results |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Search results |
|
||||
|
||||
### `pylon_list_users`
|
||||
|
||||
Retrieve a list of users
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | List of users |
|
||||
|
||||
### `pylon_get_user`
|
||||
|
||||
Retrieve a specific user by ID
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
| `userId` | string | Yes | User ID to retrieve |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | User data |
|
||||
|
||||
### `pylon_update_user`
|
||||
|
||||
Update an existing user with specified properties
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
| `userId` | string | Yes | User ID to update |
|
||||
| `roleId` | string | No | Role ID to assign to user |
|
||||
| `status` | string | No | User status |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Updated user data |
|
||||
|
||||
### `pylon_search_users`
|
||||
|
||||
Search for users using a filter with email field
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
| `filter` | string | Yes | Filter as JSON object with email field |
|
||||
| `cursor` | string | No | Pagination cursor for next page of results |
|
||||
| `limit` | string | No | Maximum number of users to return |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Search results |
|
||||
|
||||
### `pylon_list_teams`
|
||||
|
||||
Retrieve a list of teams
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | List of teams |
|
||||
|
||||
### `pylon_get_team`
|
||||
|
||||
Retrieve a specific team by ID
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
| `teamId` | string | Yes | Team ID to retrieve |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Team data |
|
||||
|
||||
### `pylon_create_team`
|
||||
|
||||
Create a new team with specified properties
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
| `name` | string | No | Team name |
|
||||
| `userIds` | string | No | Comma-separated user IDs to add as team members |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Created team data |
|
||||
|
||||
### `pylon_update_team`
|
||||
|
||||
Update an existing team with specified properties (userIds replaces entire membership)
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
| `teamId` | string | Yes | Team ID to update |
|
||||
| `name` | string | No | Team name |
|
||||
| `userIds` | string | No | Comma-separated user IDs \(replaces entire team membership\) |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Updated team data |
|
||||
|
||||
### `pylon_list_tags`
|
||||
|
||||
Retrieve a list of tags
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | List of tags |
|
||||
|
||||
### `pylon_get_tag`
|
||||
|
||||
Retrieve a specific tag by ID
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
| `tagId` | string | Yes | Tag ID to retrieve |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Tag data |
|
||||
|
||||
### `pylon_create_tag`
|
||||
|
||||
Create a new tag with specified properties (objectType: account/issue/contact)
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
| `objectType` | string | Yes | Object type for tag \(account, issue, or contact\) |
|
||||
| `value` | string | Yes | Tag value/name |
|
||||
| `hexColor` | string | No | Hex color code for tag \(e.g., #FF5733\) |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Created tag data |
|
||||
|
||||
### `pylon_update_tag`
|
||||
|
||||
Update an existing tag with specified properties
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
| `tagId` | string | Yes | Tag ID to update |
|
||||
| `hexColor` | string | No | Hex color code for tag \(e.g., #FF5733\) |
|
||||
| `value` | string | No | Tag value/name |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Updated tag data |
|
||||
|
||||
### `pylon_delete_tag`
|
||||
|
||||
Delete a specific tag by ID
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
| `tagId` | string | Yes | Tag ID to delete |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Delete operation result |
|
||||
|
||||
### `pylon_redact_message`
|
||||
|
||||
Redact a specific message within an issue
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `apiToken` | string | Yes | Pylon API token |
|
||||
| `issueId` | string | Yes | Issue ID containing the message |
|
||||
| `messageId` | string | Yes | Message ID to redact |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Redact operation result |
|
||||
|
||||
|
||||
|
||||
## Notes
|
||||
|
||||
- Category: `tools`
|
||||
- Type: `pylon`
|
||||
@@ -0,0 +1,646 @@
|
||||
---
|
||||
title: Zendesk
|
||||
description: Manage support tickets, users, and organizations in Zendesk
|
||||
---
|
||||
|
||||
import { BlockInfoCard } from "@/components/ui/block-info-card"
|
||||
|
||||
<BlockInfoCard
|
||||
type="zendesk"
|
||||
color="#E0E0E0"
|
||||
/>
|
||||
|
||||
{/* MANUAL-CONTENT-START:intro */}
|
||||
[Zendesk](https://www.zendesk.com/) is a leading customer service and support platform that empowers organizations to efficiently manage support tickets, users, and organizations through a robust set of tools and APIs. The Zendesk integration in Sim lets your agents automate key support operations and synchronize your support data with the rest of your workflow.
|
||||
|
||||
With Zendesk in Sim, you can:
|
||||
|
||||
- **Manage Tickets:**
|
||||
- Retrieve lists of support tickets with advanced filtering and sorting.
|
||||
- Get detailed information on a single ticket for tracking and resolution.
|
||||
- Create new tickets individually or in bulk to log customer issues programmatically.
|
||||
- Update tickets or apply bulk updates to streamline complex workflows.
|
||||
- Delete or merge tickets as cases are resolved or duplicates arise.
|
||||
|
||||
- **User Management:**
|
||||
- Retrieve lists of users or search users by criteria to keep your customer and agent directories up-to-date.
|
||||
- Get detailed information on individual users or the current logged-in user.
|
||||
- Create new users or onboard them in bulk, automating customer and agent provisioning.
|
||||
- Update or bulk update user details to ensure information accuracy.
|
||||
- Delete users as needed for privacy or account management.
|
||||
|
||||
- **Organization Management:**
|
||||
- List, search, and autocomplete organizations for streamlined support and account management.
|
||||
- Get organization details and keep your database organized.
|
||||
- Create, update, or delete organizations to reflect changes in your customer base.
|
||||
- Perform bulk organization creation for large onboarding efforts.
|
||||
|
||||
- **Advanced Search & Analytics:**
|
||||
- Use versatile search endpoints to quickly locate tickets, users, or organizations by any field.
|
||||
- Retrieve counts of search results to power reporting and analytics.
|
||||
|
||||
By leveraging Zendesk’s Sim integration, your automated workflows can seamlessly handle support ticket triage, user onboarding/offboarding, company management, and keep your support operations running smoothly. Whether you’re integrating support with product, CRM, or automation systems, Zendesk tools in Sim provide robust, programmatic control to power best-in-class support at scale.
|
||||
{/* MANUAL-CONTENT-END */}
|
||||
|
||||
## Usage Instructions
|
||||
|
||||
Integrate Zendesk into the workflow. Can get tickets, get ticket, create ticket, create tickets bulk, update ticket, update tickets bulk, delete ticket, merge tickets, get users, get user, get current user, search users, create user, create users bulk, update user, update users bulk, delete user, get organizations, get organization, autocomplete organizations, create organization, create organizations bulk, update organization, delete organization, search, search count.
|
||||
|
||||
|
||||
|
||||
## Tools
|
||||
|
||||
### `zendesk_get_tickets`
|
||||
|
||||
Retrieve a list of tickets from Zendesk with optional filtering
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `email` | string | Yes | Your Zendesk email address |
|
||||
| `apiToken` | string | Yes | Zendesk API token |
|
||||
| `subdomain` | string | Yes | Your Zendesk subdomain \(e.g., "mycompany" for mycompany.zendesk.com\) |
|
||||
| `status` | string | No | Filter by status \(new, open, pending, hold, solved, closed\) |
|
||||
| `priority` | string | No | Filter by priority \(low, normal, high, urgent\) |
|
||||
| `type` | string | No | Filter by type \(problem, incident, question, task\) |
|
||||
| `assigneeId` | string | No | Filter by assignee user ID |
|
||||
| `organizationId` | string | No | Filter by organization ID |
|
||||
| `sortBy` | string | No | Sort field \(created_at, updated_at, priority, status\) |
|
||||
| `sortOrder` | string | No | Sort order \(asc or desc\) |
|
||||
| `perPage` | string | No | Results per page \(default: 100, max: 100\) |
|
||||
| `page` | string | No | Page number |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Tickets data and metadata |
|
||||
|
||||
### `zendesk_get_ticket`
|
||||
|
||||
Get a single ticket by ID from Zendesk
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `email` | string | Yes | Your Zendesk email address |
|
||||
| `apiToken` | string | Yes | Zendesk API token |
|
||||
| `subdomain` | string | Yes | Your Zendesk subdomain |
|
||||
| `ticketId` | string | Yes | Ticket ID to retrieve |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Ticket data |
|
||||
|
||||
### `zendesk_create_ticket`
|
||||
|
||||
Create a new ticket in Zendesk with support for custom fields
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `email` | string | Yes | Your Zendesk email address |
|
||||
| `apiToken` | string | Yes | Zendesk API token |
|
||||
| `subdomain` | string | Yes | Your Zendesk subdomain |
|
||||
| `subject` | string | No | Ticket subject \(optional - will be auto-generated if not provided\) |
|
||||
| `description` | string | Yes | Ticket description \(first comment\) |
|
||||
| `priority` | string | No | Priority \(low, normal, high, urgent\) |
|
||||
| `status` | string | No | Status \(new, open, pending, hold, solved, closed\) |
|
||||
| `type` | string | No | Type \(problem, incident, question, task\) |
|
||||
| `tags` | string | No | Comma-separated tags |
|
||||
| `assigneeId` | string | No | Assignee user ID |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Created ticket data |
|
||||
|
||||
### `zendesk_create_tickets_bulk`
|
||||
|
||||
Create multiple tickets in Zendesk at once (max 100)
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `email` | string | Yes | Your Zendesk email address |
|
||||
| `apiToken` | string | Yes | Zendesk API token |
|
||||
| `subdomain` | string | Yes | Your Zendesk subdomain |
|
||||
| `tickets` | string | Yes | JSON array of ticket objects to create \(max 100\). Each ticket should have subject and comment properties. |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Bulk create job status |
|
||||
|
||||
### `zendesk_update_ticket`
|
||||
|
||||
Update an existing ticket in Zendesk with support for custom fields
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `email` | string | Yes | Your Zendesk email address |
|
||||
| `apiToken` | string | Yes | Zendesk API token |
|
||||
| `subdomain` | string | Yes | Your Zendesk subdomain |
|
||||
| `ticketId` | string | Yes | Ticket ID to update |
|
||||
| `subject` | string | No | New ticket subject |
|
||||
| `comment` | string | No | Add a comment to the ticket |
|
||||
| `priority` | string | No | Priority \(low, normal, high, urgent\) |
|
||||
| `status` | string | No | Status \(new, open, pending, hold, solved, closed\) |
|
||||
| `type` | string | No | Type \(problem, incident, question, task\) |
|
||||
| `tags` | string | No | Comma-separated tags |
|
||||
| `assigneeId` | string | No | Assignee user ID |
|
||||
| `groupId` | string | No | Group ID |
|
||||
| `customFields` | string | No | Custom fields as JSON object |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Updated ticket data |
|
||||
|
||||
### `zendesk_update_tickets_bulk`
|
||||
|
||||
Update multiple tickets in Zendesk at once (max 100)
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `email` | string | Yes | Your Zendesk email address |
|
||||
| `apiToken` | string | Yes | Zendesk API token |
|
||||
| `subdomain` | string | Yes | Your Zendesk subdomain |
|
||||
| `ticketIds` | string | Yes | Comma-separated ticket IDs to update \(max 100\) |
|
||||
| `status` | string | No | New status for all tickets |
|
||||
| `priority` | string | No | New priority for all tickets |
|
||||
| `assigneeId` | string | No | New assignee ID for all tickets |
|
||||
| `groupId` | string | No | New group ID for all tickets |
|
||||
| `tags` | string | No | Comma-separated tags to add to all tickets |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Bulk update job status |
|
||||
|
||||
### `zendesk_delete_ticket`
|
||||
|
||||
Delete a ticket from Zendesk
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `email` | string | Yes | Your Zendesk email address |
|
||||
| `apiToken` | string | Yes | Zendesk API token |
|
||||
| `subdomain` | string | Yes | Your Zendesk subdomain |
|
||||
| `ticketId` | string | Yes | Ticket ID to delete |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Delete confirmation |
|
||||
|
||||
### `zendesk_merge_tickets`
|
||||
|
||||
Merge multiple tickets into a target ticket
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `email` | string | Yes | Your Zendesk email address |
|
||||
| `apiToken` | string | Yes | Zendesk API token |
|
||||
| `subdomain` | string | Yes | Your Zendesk subdomain |
|
||||
| `targetTicketId` | string | Yes | Target ticket ID \(tickets will be merged into this one\) |
|
||||
| `sourceTicketIds` | string | Yes | Comma-separated source ticket IDs to merge |
|
||||
| `targetComment` | string | No | Comment to add to target ticket after merge |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Merge job status |
|
||||
|
||||
### `zendesk_get_users`
|
||||
|
||||
Retrieve a list of users from Zendesk with optional filtering
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `email` | string | Yes | Your Zendesk email address |
|
||||
| `apiToken` | string | Yes | Zendesk API token |
|
||||
| `subdomain` | string | Yes | Your Zendesk subdomain \(e.g., "mycompany" for mycompany.zendesk.com\) |
|
||||
| `role` | string | No | Filter by role \(end-user, agent, admin\) |
|
||||
| `permissionSet` | string | No | Filter by permission set ID |
|
||||
| `perPage` | string | No | Results per page \(default: 100, max: 100\) |
|
||||
| `page` | string | No | Page number |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Users data and metadata |
|
||||
|
||||
### `zendesk_get_user`
|
||||
|
||||
Get a single user by ID from Zendesk
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `email` | string | Yes | Your Zendesk email address |
|
||||
| `apiToken` | string | Yes | Zendesk API token |
|
||||
| `subdomain` | string | Yes | Your Zendesk subdomain |
|
||||
| `userId` | string | Yes | User ID to retrieve |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | User data |
|
||||
|
||||
### `zendesk_get_current_user`
|
||||
|
||||
Get the currently authenticated user from Zendesk
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `email` | string | Yes | Your Zendesk email address |
|
||||
| `apiToken` | string | Yes | Zendesk API token |
|
||||
| `subdomain` | string | Yes | Your Zendesk subdomain |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Current user data |
|
||||
|
||||
### `zendesk_search_users`
|
||||
|
||||
Search for users in Zendesk using a query string
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `email` | string | Yes | Your Zendesk email address |
|
||||
| `apiToken` | string | Yes | Zendesk API token |
|
||||
| `subdomain` | string | Yes | Your Zendesk subdomain |
|
||||
| `query` | string | No | Search query string |
|
||||
| `externalId` | string | No | External ID to search by |
|
||||
| `perPage` | string | No | Results per page \(default: 100, max: 100\) |
|
||||
| `page` | string | No | Page number |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Users search results |
|
||||
|
||||
### `zendesk_create_user`
|
||||
|
||||
Create a new user in Zendesk
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `email` | string | Yes | Your Zendesk email address |
|
||||
| `apiToken` | string | Yes | Zendesk API token |
|
||||
| `subdomain` | string | Yes | Your Zendesk subdomain |
|
||||
| `name` | string | Yes | User name |
|
||||
| `userEmail` | string | No | User email |
|
||||
| `role` | string | No | User role \(end-user, agent, admin\) |
|
||||
| `phone` | string | No | User phone number |
|
||||
| `organizationId` | string | No | Organization ID |
|
||||
| `verified` | string | No | Set to "true" to skip email verification |
|
||||
| `tags` | string | No | Comma-separated tags |
|
||||
| `customFields` | string | No | Custom fields as JSON object \(e.g., \{"field_id": "value"\}\) |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Created user data |
|
||||
|
||||
### `zendesk_create_users_bulk`
|
||||
|
||||
Create multiple users in Zendesk using bulk import
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `email` | string | Yes | Your Zendesk email address |
|
||||
| `apiToken` | string | Yes | Zendesk API token |
|
||||
| `subdomain` | string | Yes | Your Zendesk subdomain |
|
||||
| `users` | string | Yes | JSON array of user objects to create |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Bulk creation job status |
|
||||
|
||||
### `zendesk_update_user`
|
||||
|
||||
Update an existing user in Zendesk
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `email` | string | Yes | Your Zendesk email address |
|
||||
| `apiToken` | string | Yes | Zendesk API token |
|
||||
| `subdomain` | string | Yes | Your Zendesk subdomain |
|
||||
| `userId` | string | Yes | User ID to update |
|
||||
| `name` | string | No | New user name |
|
||||
| `userEmail` | string | No | New user email |
|
||||
| `role` | string | No | User role \(end-user, agent, admin\) |
|
||||
| `phone` | string | No | User phone number |
|
||||
| `organizationId` | string | No | Organization ID |
|
||||
| `verified` | string | No | Set to "true" to mark user as verified |
|
||||
| `tags` | string | No | Comma-separated tags |
|
||||
| `customFields` | string | No | Custom fields as JSON object |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Updated user data |
|
||||
|
||||
### `zendesk_update_users_bulk`
|
||||
|
||||
Update multiple users in Zendesk using bulk update
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `email` | string | Yes | Your Zendesk email address |
|
||||
| `apiToken` | string | Yes | Zendesk API token |
|
||||
| `subdomain` | string | Yes | Your Zendesk subdomain |
|
||||
| `users` | string | Yes | JSON array of user objects to update \(must include id field\) |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Bulk update job status |
|
||||
|
||||
### `zendesk_delete_user`
|
||||
|
||||
Delete a user from Zendesk
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `email` | string | Yes | Your Zendesk email address |
|
||||
| `apiToken` | string | Yes | Zendesk API token |
|
||||
| `subdomain` | string | Yes | Your Zendesk subdomain |
|
||||
| `userId` | string | Yes | User ID to delete |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Deleted user data |
|
||||
|
||||
### `zendesk_get_organizations`
|
||||
|
||||
Retrieve a list of organizations from Zendesk
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `email` | string | Yes | Your Zendesk email address |
|
||||
| `apiToken` | string | Yes | Zendesk API token |
|
||||
| `subdomain` | string | Yes | Your Zendesk subdomain \(e.g., "mycompany" for mycompany.zendesk.com\) |
|
||||
| `perPage` | string | No | Results per page \(default: 100, max: 100\) |
|
||||
| `page` | string | No | Page number |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Organizations data and metadata |
|
||||
|
||||
### `zendesk_get_organization`
|
||||
|
||||
Get a single organization by ID from Zendesk
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `email` | string | Yes | Your Zendesk email address |
|
||||
| `apiToken` | string | Yes | Zendesk API token |
|
||||
| `subdomain` | string | Yes | Your Zendesk subdomain |
|
||||
| `organizationId` | string | Yes | Organization ID to retrieve |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Organization data |
|
||||
|
||||
### `zendesk_autocomplete_organizations`
|
||||
|
||||
Autocomplete organizations in Zendesk by name prefix (for name matching/autocomplete)
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `email` | string | Yes | Your Zendesk email address |
|
||||
| `apiToken` | string | Yes | Zendesk API token |
|
||||
| `subdomain` | string | Yes | Your Zendesk subdomain |
|
||||
| `name` | string | Yes | Organization name to search for |
|
||||
| `perPage` | string | No | Results per page \(default: 100, max: 100\) |
|
||||
| `page` | string | No | Page number |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Organizations search results |
|
||||
|
||||
### `zendesk_create_organization`
|
||||
|
||||
Create a new organization in Zendesk
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `email` | string | Yes | Your Zendesk email address |
|
||||
| `apiToken` | string | Yes | Zendesk API token |
|
||||
| `subdomain` | string | Yes | Your Zendesk subdomain |
|
||||
| `name` | string | Yes | Organization name |
|
||||
| `domainNames` | string | No | Comma-separated domain names |
|
||||
| `details` | string | No | Organization details |
|
||||
| `notes` | string | No | Organization notes |
|
||||
| `tags` | string | No | Comma-separated tags |
|
||||
| `customFields` | string | No | Custom fields as JSON object \(e.g., \{"field_id": "value"\}\) |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Created organization data |
|
||||
|
||||
### `zendesk_create_organizations_bulk`
|
||||
|
||||
Create multiple organizations in Zendesk using bulk import
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `email` | string | Yes | Your Zendesk email address |
|
||||
| `apiToken` | string | Yes | Zendesk API token |
|
||||
| `subdomain` | string | Yes | Your Zendesk subdomain |
|
||||
| `organizations` | string | Yes | JSON array of organization objects to create |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Bulk creation job status |
|
||||
|
||||
### `zendesk_update_organization`
|
||||
|
||||
Update an existing organization in Zendesk
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `email` | string | Yes | Your Zendesk email address |
|
||||
| `apiToken` | string | Yes | Zendesk API token |
|
||||
| `subdomain` | string | Yes | Your Zendesk subdomain |
|
||||
| `organizationId` | string | Yes | Organization ID to update |
|
||||
| `name` | string | No | New organization name |
|
||||
| `domainNames` | string | No | Comma-separated domain names |
|
||||
| `details` | string | No | Organization details |
|
||||
| `notes` | string | No | Organization notes |
|
||||
| `tags` | string | No | Comma-separated tags |
|
||||
| `customFields` | string | No | Custom fields as JSON object |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Updated organization data |
|
||||
|
||||
### `zendesk_delete_organization`
|
||||
|
||||
Delete an organization from Zendesk
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `email` | string | Yes | Your Zendesk email address |
|
||||
| `apiToken` | string | Yes | Zendesk API token |
|
||||
| `subdomain` | string | Yes | Your Zendesk subdomain |
|
||||
| `organizationId` | string | Yes | Organization ID to delete |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Deleted organization data |
|
||||
|
||||
### `zendesk_search`
|
||||
|
||||
Unified search across tickets, users, and organizations in Zendesk
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `email` | string | Yes | Your Zendesk email address |
|
||||
| `apiToken` | string | Yes | Zendesk API token |
|
||||
| `subdomain` | string | Yes | Your Zendesk subdomain |
|
||||
| `query` | string | Yes | Search query string |
|
||||
| `sortBy` | string | No | Sort field \(relevance, created_at, updated_at, priority, status, ticket_type\) |
|
||||
| `sortOrder` | string | No | Sort order \(asc or desc\) |
|
||||
| `perPage` | string | No | Results per page \(default: 100, max: 100\) |
|
||||
| `page` | string | No | Page number |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Search results |
|
||||
|
||||
### `zendesk_search_count`
|
||||
|
||||
Count the number of search results matching a query in Zendesk
|
||||
|
||||
#### Input
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
| --------- | ---- | -------- | ----------- |
|
||||
| `email` | string | Yes | Your Zendesk email address |
|
||||
| `apiToken` | string | Yes | Zendesk API token |
|
||||
| `subdomain` | string | Yes | Your Zendesk subdomain |
|
||||
| `query` | string | Yes | Search query string |
|
||||
|
||||
#### Output
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --------- | ---- | ----------- |
|
||||
| `success` | boolean | Operation success status |
|
||||
| `output` | object | Search count result |
|
||||
|
||||
|
||||
|
||||
## Notes
|
||||
|
||||
- Category: `tools`
|
||||
- Type: `zendesk`
|
||||
+1
-1
@@ -353,7 +353,7 @@ export function Editor() {
|
||||
blockId={currentBlockId}
|
||||
config={subBlock}
|
||||
isPreview={false}
|
||||
subBlockValues={undefined}
|
||||
subBlockValues={subBlockState}
|
||||
disabled={!userPermissions.canEdit}
|
||||
fieldDiffStatus={undefined}
|
||||
allowExpandInPreview={false}
|
||||
|
||||
@@ -0,0 +1,571 @@
|
||||
import { IntercomIcon } from '@/components/icons'
|
||||
import type { BlockConfig } from '@/blocks/types'
|
||||
import { AuthMode } from '@/blocks/types'
|
||||
|
||||
export const IntercomBlock: BlockConfig = {
|
||||
type: 'intercom',
|
||||
name: 'Intercom',
|
||||
description: 'Manage contacts, companies, conversations, tickets, and messages in Intercom',
|
||||
longDescription:
|
||||
'Integrate Intercom into the workflow. Can create, get, update, list, search, and delete contacts; create, get, and list companies; get, list, reply, and search conversations; create and get tickets; and create messages.',
|
||||
docsLink: 'https://docs.sim.ai/tools/intercom',
|
||||
authMode: AuthMode.ApiKey,
|
||||
category: 'tools',
|
||||
bgColor: '#E0E0E0',
|
||||
icon: IntercomIcon,
|
||||
subBlocks: [
|
||||
{
|
||||
id: 'operation',
|
||||
title: 'Operation',
|
||||
type: 'dropdown',
|
||||
options: [
|
||||
{ label: 'Create Contact', id: 'create_contact' },
|
||||
{ label: 'Get Contact', id: 'get_contact' },
|
||||
{ label: 'Update Contact', id: 'update_contact' },
|
||||
{ label: 'List Contacts', id: 'list_contacts' },
|
||||
{ label: 'Search Contacts', id: 'search_contacts' },
|
||||
{ label: 'Delete Contact', id: 'delete_contact' },
|
||||
{ label: 'Create Company', id: 'create_company' },
|
||||
{ label: 'Get Company', id: 'get_company' },
|
||||
{ label: 'List Companies', id: 'list_companies' },
|
||||
{ label: 'Get Conversation', id: 'get_conversation' },
|
||||
{ label: 'List Conversations', id: 'list_conversations' },
|
||||
{ label: 'Reply to Conversation', id: 'reply_conversation' },
|
||||
{ label: 'Search Conversations', id: 'search_conversations' },
|
||||
{ label: 'Create Ticket', id: 'create_ticket' },
|
||||
{ label: 'Get Ticket', id: 'get_ticket' },
|
||||
{ label: 'Create Message', id: 'create_message' },
|
||||
],
|
||||
value: () => 'create_contact',
|
||||
},
|
||||
{
|
||||
id: 'accessToken',
|
||||
title: 'Access Token',
|
||||
type: 'short-input',
|
||||
password: true,
|
||||
placeholder: 'Enter your Intercom access token',
|
||||
required: true,
|
||||
},
|
||||
// Contact fields
|
||||
{
|
||||
id: 'contactId',
|
||||
title: 'Contact ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'Contact ID',
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['get_contact', 'update_contact', 'delete_contact'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'email',
|
||||
title: 'Email',
|
||||
type: 'short-input',
|
||||
placeholder: 'Contact email',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_contact', 'update_contact'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'external_id',
|
||||
title: 'External ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'External identifier for the contact',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_contact'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'phone',
|
||||
title: 'Phone',
|
||||
type: 'short-input',
|
||||
placeholder: 'Contact phone number',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_contact', 'update_contact'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'name',
|
||||
title: 'Name',
|
||||
type: 'short-input',
|
||||
placeholder: 'Contact name',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_contact', 'update_contact'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'avatar',
|
||||
title: 'Avatar URL',
|
||||
type: 'short-input',
|
||||
placeholder: 'Avatar image URL',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_contact', 'update_contact'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'signed_up_at',
|
||||
title: 'Signed Up At',
|
||||
type: 'short-input',
|
||||
placeholder: 'Unix timestamp',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_contact', 'update_contact'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'last_seen_at',
|
||||
title: 'Last Seen At',
|
||||
type: 'short-input',
|
||||
placeholder: 'Unix timestamp',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_contact', 'update_contact'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'owner_id',
|
||||
title: 'Owner ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'Admin ID',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_contact', 'update_contact'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'unsubscribed_from_emails',
|
||||
title: 'Unsubscribed from Emails',
|
||||
type: 'dropdown',
|
||||
options: [
|
||||
{ label: 'True', id: 'true' },
|
||||
{ label: 'False', id: 'false' },
|
||||
],
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_contact', 'update_contact'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'custom_attributes',
|
||||
title: 'Custom Attributes',
|
||||
type: 'long-input',
|
||||
placeholder: 'JSON object with custom attributes',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_contact', 'update_contact'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'query',
|
||||
title: 'Search Query',
|
||||
type: 'long-input',
|
||||
placeholder: 'JSON search query or text',
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['search_contacts', 'search_conversations'],
|
||||
},
|
||||
},
|
||||
// Company fields
|
||||
{
|
||||
id: 'companyId',
|
||||
title: 'Company ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'Intercom company ID',
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['get_company'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'company_id',
|
||||
title: 'Company ID (External)',
|
||||
type: 'short-input',
|
||||
placeholder: 'Your unique identifier for the company',
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_company'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'company_name',
|
||||
title: 'Company Name',
|
||||
type: 'short-input',
|
||||
placeholder: 'Company name',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_company'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'website',
|
||||
title: 'Website',
|
||||
type: 'short-input',
|
||||
placeholder: 'Company website',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_company'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'plan',
|
||||
title: 'Plan',
|
||||
type: 'short-input',
|
||||
placeholder: 'Subscription plan',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_company'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'size',
|
||||
title: 'Size',
|
||||
type: 'short-input',
|
||||
placeholder: 'Number of employees',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_company'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'industry',
|
||||
title: 'Industry',
|
||||
type: 'short-input',
|
||||
placeholder: 'Company industry',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_company'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'monthly_spend',
|
||||
title: 'Monthly Spend',
|
||||
type: 'short-input',
|
||||
placeholder: 'Revenue amount',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_company'],
|
||||
},
|
||||
},
|
||||
// Conversation fields
|
||||
{
|
||||
id: 'conversationId',
|
||||
title: 'Conversation ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'Conversation ID',
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['get_conversation', 'reply_conversation'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'display_as',
|
||||
title: 'Display As',
|
||||
type: 'dropdown',
|
||||
options: [
|
||||
{ label: 'HTML', id: 'html' },
|
||||
{ label: 'Plain Text', id: 'plaintext' },
|
||||
],
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['get_conversation'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'message_type',
|
||||
title: 'Message Type',
|
||||
type: 'dropdown',
|
||||
options: [
|
||||
{ label: 'Comment', id: 'comment' },
|
||||
{ label: 'Note', id: 'note' },
|
||||
],
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['reply_conversation'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'body',
|
||||
title: 'Message Body',
|
||||
type: 'long-input',
|
||||
placeholder: 'Message text',
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['reply_conversation', 'create_message'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'admin_id',
|
||||
title: 'Admin ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'ID of the admin sending the message',
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['reply_conversation'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'attachment_urls',
|
||||
title: 'Attachment URLs',
|
||||
type: 'short-input',
|
||||
placeholder: 'Comma-separated image URLs (max 10)',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['reply_conversation'],
|
||||
},
|
||||
},
|
||||
// Ticket fields
|
||||
{
|
||||
id: 'ticketId',
|
||||
title: 'Ticket ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'Ticket ID',
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['get_ticket'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'ticket_type_id',
|
||||
title: 'Ticket Type ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'ID of the ticket type',
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_ticket'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'contacts',
|
||||
title: 'Contacts',
|
||||
type: 'long-input',
|
||||
placeholder: 'JSON array of contact identifiers',
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_ticket'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'ticket_attributes',
|
||||
title: 'Ticket Attributes',
|
||||
type: 'long-input',
|
||||
placeholder: 'JSON object with ticket attributes',
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_ticket'],
|
||||
},
|
||||
},
|
||||
// Message fields
|
||||
{
|
||||
id: 'message_type_msg',
|
||||
title: 'Message Type',
|
||||
type: 'dropdown',
|
||||
options: [
|
||||
{ label: 'In-App', id: 'inapp' },
|
||||
{ label: 'Email', id: 'email' },
|
||||
],
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_message'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'subject',
|
||||
title: 'Subject',
|
||||
type: 'short-input',
|
||||
placeholder: 'Email subject (for email type)',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_message'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'from_type',
|
||||
title: 'From Type',
|
||||
type: 'dropdown',
|
||||
options: [{ label: 'Admin', id: 'admin' }],
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_message'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'from_id',
|
||||
title: 'From ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'Admin ID',
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_message'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'to_type',
|
||||
title: 'To Type',
|
||||
type: 'dropdown',
|
||||
options: [{ label: 'Contact', id: 'contact' }],
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_message'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'to_id',
|
||||
title: 'To ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'Contact ID',
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_message'],
|
||||
},
|
||||
},
|
||||
// Pagination fields
|
||||
{
|
||||
id: 'per_page',
|
||||
title: 'Per Page',
|
||||
type: 'short-input',
|
||||
placeholder: 'Results per page (max: 150)',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: [
|
||||
'list_contacts',
|
||||
'search_contacts',
|
||||
'list_companies',
|
||||
'list_conversations',
|
||||
'search_conversations',
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'starting_after',
|
||||
title: 'Starting After',
|
||||
type: 'short-input',
|
||||
placeholder: 'Cursor for pagination',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['list_contacts', 'search_contacts', 'list_conversations', 'search_conversations'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'page',
|
||||
title: 'Page',
|
||||
type: 'short-input',
|
||||
placeholder: 'Page number',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['list_companies'],
|
||||
},
|
||||
},
|
||||
],
|
||||
tools: {
|
||||
access: [
|
||||
'intercom_create_contact',
|
||||
'intercom_get_contact',
|
||||
'intercom_update_contact',
|
||||
'intercom_list_contacts',
|
||||
'intercom_search_contacts',
|
||||
'intercom_delete_contact',
|
||||
'intercom_create_company',
|
||||
'intercom_get_company',
|
||||
'intercom_list_companies',
|
||||
'intercom_get_conversation',
|
||||
'intercom_list_conversations',
|
||||
'intercom_reply_conversation',
|
||||
'intercom_search_conversations',
|
||||
'intercom_create_ticket',
|
||||
'intercom_get_ticket',
|
||||
'intercom_create_message',
|
||||
],
|
||||
config: {
|
||||
tool: (params) => {
|
||||
switch (params.operation) {
|
||||
case 'create_contact':
|
||||
return 'intercom_create_contact'
|
||||
case 'get_contact':
|
||||
return 'intercom_get_contact'
|
||||
case 'update_contact':
|
||||
return 'intercom_update_contact'
|
||||
case 'list_contacts':
|
||||
return 'intercom_list_contacts'
|
||||
case 'search_contacts':
|
||||
return 'intercom_search_contacts'
|
||||
case 'delete_contact':
|
||||
return 'intercom_delete_contact'
|
||||
case 'create_company':
|
||||
return 'intercom_create_company'
|
||||
case 'get_company':
|
||||
return 'intercom_get_company'
|
||||
case 'list_companies':
|
||||
return 'intercom_list_companies'
|
||||
case 'get_conversation':
|
||||
return 'intercom_get_conversation'
|
||||
case 'list_conversations':
|
||||
return 'intercom_list_conversations'
|
||||
case 'reply_conversation':
|
||||
return 'intercom_reply_conversation'
|
||||
case 'search_conversations':
|
||||
return 'intercom_search_conversations'
|
||||
case 'create_ticket':
|
||||
return 'intercom_create_ticket'
|
||||
case 'get_ticket':
|
||||
return 'intercom_get_ticket'
|
||||
case 'create_message':
|
||||
return 'intercom_create_message'
|
||||
default:
|
||||
throw new Error(`Unknown operation: ${params.operation}`)
|
||||
}
|
||||
},
|
||||
params: (params) => {
|
||||
const { operation, message_type_msg, company_name, ...rest } = params
|
||||
const cleanParams: Record<string, any> = {}
|
||||
|
||||
// Special mapping for message_type in create_message
|
||||
if (operation === 'create_message' && message_type_msg) {
|
||||
cleanParams.message_type = message_type_msg
|
||||
}
|
||||
|
||||
// Special mapping for company name
|
||||
if (operation === 'create_company' && company_name) {
|
||||
cleanParams.name = company_name
|
||||
}
|
||||
|
||||
Object.entries(rest).forEach(([key, value]) => {
|
||||
if (value !== undefined && value !== null && value !== '') {
|
||||
cleanParams[key] = value
|
||||
}
|
||||
})
|
||||
|
||||
return cleanParams
|
||||
},
|
||||
},
|
||||
},
|
||||
inputs: {
|
||||
operation: { type: 'string', description: 'Operation to perform' },
|
||||
accessToken: { type: 'string', description: 'Intercom API access token' },
|
||||
},
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: { type: 'json', description: 'Operation result data' },
|
||||
},
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,838 @@
|
||||
import { PylonIcon } from '@/components/icons'
|
||||
import type { BlockConfig } from '@/blocks/types'
|
||||
import { AuthMode } from '@/blocks/types'
|
||||
|
||||
export const PylonBlock: BlockConfig = {
|
||||
type: 'pylon',
|
||||
name: 'Pylon',
|
||||
description:
|
||||
'Manage customer support issues, accounts, contacts, users, teams, and tags in Pylon',
|
||||
longDescription:
|
||||
'Integrate Pylon into the workflow. Manage issues (list, create, get, update, delete, search, snooze, followers, external issues), accounts (list, create, get, update, delete, bulk update, search), contacts (list, create, get, update, delete, search), users (list, get, update, search), teams (list, get, create, update), tags (list, get, create, update, delete), and messages (redact).',
|
||||
docsLink: 'https://docs.usepylon.com/pylon-docs/developer/api',
|
||||
authMode: AuthMode.ApiKey,
|
||||
category: 'tools',
|
||||
bgColor: '#E8F4FA',
|
||||
icon: PylonIcon,
|
||||
subBlocks: [
|
||||
{
|
||||
id: 'operation',
|
||||
title: 'Operation',
|
||||
type: 'dropdown',
|
||||
options: [
|
||||
// Issue operations
|
||||
{ label: 'List Issues', id: 'list_issues' },
|
||||
{ label: 'Create Issue', id: 'create_issue' },
|
||||
{ label: 'Get Issue', id: 'get_issue' },
|
||||
{ label: 'Update Issue', id: 'update_issue' },
|
||||
{ label: 'Delete Issue', id: 'delete_issue' },
|
||||
{ label: 'Search Issues', id: 'search_issues' },
|
||||
{ label: 'Snooze Issue', id: 'snooze_issue' },
|
||||
{ label: 'List Issue Followers', id: 'list_issue_followers' },
|
||||
{ label: 'Manage Issue Followers', id: 'manage_issue_followers' },
|
||||
{ label: 'Link External Issue', id: 'link_external_issue' },
|
||||
// Account operations
|
||||
{ label: 'List Accounts', id: 'list_accounts' },
|
||||
{ label: 'Create Account', id: 'create_account' },
|
||||
{ label: 'Get Account', id: 'get_account' },
|
||||
{ label: 'Update Account', id: 'update_account' },
|
||||
{ label: 'Delete Account', id: 'delete_account' },
|
||||
{ label: 'Bulk Update Accounts', id: 'bulk_update_accounts' },
|
||||
{ label: 'Search Accounts', id: 'search_accounts' },
|
||||
// Contact operations
|
||||
{ label: 'List Contacts', id: 'list_contacts' },
|
||||
{ label: 'Create Contact', id: 'create_contact' },
|
||||
{ label: 'Get Contact', id: 'get_contact' },
|
||||
{ label: 'Update Contact', id: 'update_contact' },
|
||||
{ label: 'Delete Contact', id: 'delete_contact' },
|
||||
{ label: 'Search Contacts', id: 'search_contacts' },
|
||||
// User operations
|
||||
{ label: 'List Users', id: 'list_users' },
|
||||
{ label: 'Get User', id: 'get_user' },
|
||||
{ label: 'Update User', id: 'update_user' },
|
||||
{ label: 'Search Users', id: 'search_users' },
|
||||
// Team operations
|
||||
{ label: 'List Teams', id: 'list_teams' },
|
||||
{ label: 'Get Team', id: 'get_team' },
|
||||
{ label: 'Create Team', id: 'create_team' },
|
||||
{ label: 'Update Team', id: 'update_team' },
|
||||
// Tag operations
|
||||
{ label: 'List Tags', id: 'list_tags' },
|
||||
{ label: 'Get Tag', id: 'get_tag' },
|
||||
{ label: 'Create Tag', id: 'create_tag' },
|
||||
{ label: 'Update Tag', id: 'update_tag' },
|
||||
{ label: 'Delete Tag', id: 'delete_tag' },
|
||||
// Message operations
|
||||
{ label: 'Redact Message', id: 'redact_message' },
|
||||
],
|
||||
value: () => 'list_issues',
|
||||
},
|
||||
{
|
||||
id: 'apiToken',
|
||||
title: 'API Token',
|
||||
type: 'short-input',
|
||||
password: true,
|
||||
placeholder: 'Enter your Pylon API token',
|
||||
required: true,
|
||||
},
|
||||
// Issue fields
|
||||
{
|
||||
id: 'startTime',
|
||||
title: 'Start Time',
|
||||
type: 'short-input',
|
||||
placeholder: 'RFC3339 format (e.g., 2024-01-01T00:00:00Z)',
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['list_issues'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'endTime',
|
||||
title: 'End Time',
|
||||
type: 'short-input',
|
||||
placeholder: 'RFC3339 format (e.g., 2024-01-31T23:59:59Z)',
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['list_issues'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'issueId',
|
||||
title: 'Issue ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'Issue ID',
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: [
|
||||
'get_issue',
|
||||
'update_issue',
|
||||
'delete_issue',
|
||||
'snooze_issue',
|
||||
'list_issue_followers',
|
||||
'manage_issue_followers',
|
||||
'link_external_issue',
|
||||
'redact_message',
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'title',
|
||||
title: 'Title',
|
||||
type: 'short-input',
|
||||
placeholder: 'Issue title',
|
||||
required: {
|
||||
field: 'operation',
|
||||
value: ['create_issue'],
|
||||
},
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_issue'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'bodyHtml',
|
||||
title: 'Body HTML',
|
||||
type: 'long-input',
|
||||
placeholder: 'Issue body in HTML format',
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_issue'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'accountId',
|
||||
title: 'Account ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'Account ID',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_issue', 'update_issue', 'create_contact', 'update_contact'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'assigneeId',
|
||||
title: 'Assignee ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'User ID to assign to',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_issue', 'update_issue'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'teamId',
|
||||
title: 'Team ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'Team ID',
|
||||
required: {
|
||||
field: 'operation',
|
||||
value: ['get_team', 'update_team'],
|
||||
},
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_issue', 'update_issue', 'get_team', 'update_team'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'requesterId',
|
||||
title: 'Requester ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'Requester user ID',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_issue', 'update_issue'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'requesterEmail',
|
||||
title: 'Requester Email',
|
||||
type: 'short-input',
|
||||
placeholder: 'Requester email address',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_issue'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'priority',
|
||||
title: 'Priority',
|
||||
type: 'short-input',
|
||||
placeholder: 'Issue priority',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_issue', 'update_issue'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'state',
|
||||
title: 'State',
|
||||
type: 'short-input',
|
||||
placeholder: 'Issue state',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['update_issue'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'tags',
|
||||
title: 'Tags',
|
||||
type: 'short-input',
|
||||
placeholder: 'Comma-separated tag IDs',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: [
|
||||
'create_issue',
|
||||
'update_issue',
|
||||
'create_account',
|
||||
'update_account',
|
||||
'bulk_update_accounts',
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'customFields',
|
||||
title: 'Custom Fields',
|
||||
type: 'long-input',
|
||||
placeholder: 'JSON object with custom fields',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: [
|
||||
'create_issue',
|
||||
'update_issue',
|
||||
'create_account',
|
||||
'update_account',
|
||||
'bulk_update_accounts',
|
||||
'create_contact',
|
||||
'update_contact',
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'attachmentUrls',
|
||||
title: 'Attachment URLs',
|
||||
type: 'short-input',
|
||||
placeholder: 'Comma-separated attachment URLs',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_issue'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'customerPortalVisible',
|
||||
title: 'Customer Portal Visible',
|
||||
type: 'short-input',
|
||||
placeholder: 'true or false',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['update_issue'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'snoozeUntil',
|
||||
title: 'Snooze Until',
|
||||
type: 'short-input',
|
||||
placeholder: 'RFC3339 timestamp',
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['snooze_issue'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'userIds',
|
||||
title: 'User IDs',
|
||||
type: 'short-input',
|
||||
placeholder: 'Comma-separated user IDs',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['manage_issue_followers', 'create_team', 'update_team'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'contactIds',
|
||||
title: 'Contact IDs',
|
||||
type: 'short-input',
|
||||
placeholder: 'Comma-separated contact IDs',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['manage_issue_followers'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'followerOperation',
|
||||
title: 'Follower Operation',
|
||||
type: 'dropdown',
|
||||
options: [
|
||||
{ label: 'Add', id: 'add' },
|
||||
{ label: 'Remove', id: 'remove' },
|
||||
],
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['manage_issue_followers'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'externalIssueId',
|
||||
title: 'External Issue ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'External issue identifier',
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['link_external_issue'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'source',
|
||||
title: 'Source',
|
||||
type: 'short-input',
|
||||
placeholder: 'Source system (e.g., linear, jira)',
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['link_external_issue'],
|
||||
},
|
||||
},
|
||||
// Account fields
|
||||
{
|
||||
id: 'name',
|
||||
title: 'Name',
|
||||
type: 'short-input',
|
||||
placeholder: 'Name',
|
||||
required: {
|
||||
field: 'operation',
|
||||
value: ['create_account', 'create_contact'],
|
||||
},
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: [
|
||||
'create_account',
|
||||
'update_account',
|
||||
'create_contact',
|
||||
'update_contact',
|
||||
'create_team',
|
||||
'update_team',
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'accountIdField',
|
||||
title: 'Account ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'Account ID',
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['get_account', 'update_account', 'delete_account'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'accountIds',
|
||||
title: 'Account IDs',
|
||||
type: 'short-input',
|
||||
placeholder: 'Comma-separated account IDs',
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['bulk_update_accounts'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'domains',
|
||||
title: 'Domains',
|
||||
type: 'short-input',
|
||||
placeholder: 'Comma-separated domain names',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_account', 'update_account'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'primaryDomain',
|
||||
title: 'Primary Domain',
|
||||
type: 'short-input',
|
||||
placeholder: 'Primary domain name',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_account', 'update_account'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'channels',
|
||||
title: 'Channels',
|
||||
type: 'short-input',
|
||||
placeholder: 'Channels',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_account', 'update_account'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'externalIds',
|
||||
title: 'External IDs',
|
||||
type: 'short-input',
|
||||
placeholder: 'External IDs',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_account', 'update_account'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'ownerId',
|
||||
title: 'Owner ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'Owner user ID',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_account', 'update_account', 'bulk_update_accounts'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'logoUrl',
|
||||
title: 'Logo URL',
|
||||
type: 'short-input',
|
||||
placeholder: 'Account logo URL',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_account', 'update_account'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'subaccountIds',
|
||||
title: 'Subaccount IDs',
|
||||
type: 'short-input',
|
||||
placeholder: 'Comma-separated subaccount IDs',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_account', 'update_account'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'tagsApplyMode',
|
||||
title: 'Tags Apply Mode',
|
||||
type: 'dropdown',
|
||||
options: [
|
||||
{ label: 'Append Only', id: 'append_only' },
|
||||
{ label: 'Remove Only', id: 'remove_only' },
|
||||
{ label: 'Replace', id: 'replace' },
|
||||
],
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['bulk_update_accounts'],
|
||||
},
|
||||
},
|
||||
// Contact fields
|
||||
{
|
||||
id: 'contactId',
|
||||
title: 'Contact ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'Contact ID',
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['get_contact', 'update_contact', 'delete_contact'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'email',
|
||||
title: 'Email',
|
||||
type: 'short-input',
|
||||
placeholder: 'Email address',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_contact', 'update_contact'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'accountExternalId',
|
||||
title: 'Account External ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'External account ID',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_contact', 'update_contact'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'avatarUrl',
|
||||
title: 'Avatar URL',
|
||||
type: 'short-input',
|
||||
placeholder: 'Square PNG/JPG image URL',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_contact', 'update_contact'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'portalRole',
|
||||
title: 'Portal Role',
|
||||
type: 'dropdown',
|
||||
options: [
|
||||
{ label: 'No Access', id: 'no_access' },
|
||||
{ label: 'Member', id: 'member' },
|
||||
{ label: 'Admin', id: 'admin' },
|
||||
],
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_contact', 'update_contact'],
|
||||
},
|
||||
},
|
||||
// User fields
|
||||
{
|
||||
id: 'userId',
|
||||
title: 'User ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'User ID',
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['get_user', 'update_user'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'roleId',
|
||||
title: 'Role ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'Role ID',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['update_user'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'status',
|
||||
title: 'Status',
|
||||
type: 'dropdown',
|
||||
options: [
|
||||
{ label: 'Active', id: 'active' },
|
||||
{ label: 'Away', id: 'away' },
|
||||
{ label: 'Out of Office', id: 'out_of_office' },
|
||||
],
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['update_user'],
|
||||
},
|
||||
},
|
||||
// Tag fields
|
||||
{
|
||||
id: 'tagId',
|
||||
title: 'Tag ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'Tag ID',
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['get_tag', 'update_tag', 'delete_tag'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'objectType',
|
||||
title: 'Object Type',
|
||||
type: 'dropdown',
|
||||
options: [
|
||||
{ label: 'Account', id: 'account' },
|
||||
{ label: 'Issue', id: 'issue' },
|
||||
{ label: 'Contact', id: 'contact' },
|
||||
],
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_tag'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'value',
|
||||
title: 'Value',
|
||||
type: 'short-input',
|
||||
placeholder: 'Tag value/name',
|
||||
required: {
|
||||
field: 'operation',
|
||||
value: ['create_tag'],
|
||||
},
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_tag', 'update_tag'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'hexColor',
|
||||
title: 'Hex Color',
|
||||
type: 'short-input',
|
||||
placeholder: 'Hex color code (e.g., #3a89ce)',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_tag', 'update_tag'],
|
||||
},
|
||||
},
|
||||
// Message fields
|
||||
{
|
||||
id: 'messageId',
|
||||
title: 'Message ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'Message ID',
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['redact_message'],
|
||||
},
|
||||
},
|
||||
// Search and pagination fields
|
||||
{
|
||||
id: 'filter',
|
||||
title: 'Filter',
|
||||
type: 'long-input',
|
||||
placeholder: 'JSON filter object',
|
||||
required: {
|
||||
field: 'operation',
|
||||
value: ['search_accounts', 'search_contacts', 'search_users'],
|
||||
},
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['search_issues', 'search_accounts', 'search_contacts', 'search_users'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'limit',
|
||||
title: 'Limit',
|
||||
type: 'short-input',
|
||||
placeholder: 'Results per page (1-1000, default: 100)',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: [
|
||||
'list_accounts',
|
||||
'list_contacts',
|
||||
'get_contact',
|
||||
'search_issues',
|
||||
'search_accounts',
|
||||
'search_contacts',
|
||||
'search_users',
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'cursor',
|
||||
title: 'Cursor',
|
||||
type: 'short-input',
|
||||
placeholder: 'Pagination cursor',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: [
|
||||
'list_issues',
|
||||
'list_accounts',
|
||||
'list_contacts',
|
||||
'get_contact',
|
||||
'search_issues',
|
||||
'search_accounts',
|
||||
'search_contacts',
|
||||
'search_users',
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
tools: {
|
||||
access: [
|
||||
'pylon_list_issues',
|
||||
'pylon_create_issue',
|
||||
'pylon_get_issue',
|
||||
'pylon_update_issue',
|
||||
'pylon_delete_issue',
|
||||
'pylon_search_issues',
|
||||
'pylon_snooze_issue',
|
||||
'pylon_list_issue_followers',
|
||||
'pylon_manage_issue_followers',
|
||||
'pylon_link_external_issue',
|
||||
'pylon_list_accounts',
|
||||
'pylon_create_account',
|
||||
'pylon_get_account',
|
||||
'pylon_update_account',
|
||||
'pylon_delete_account',
|
||||
'pylon_bulk_update_accounts',
|
||||
'pylon_search_accounts',
|
||||
'pylon_list_contacts',
|
||||
'pylon_create_contact',
|
||||
'pylon_get_contact',
|
||||
'pylon_update_contact',
|
||||
'pylon_delete_contact',
|
||||
'pylon_search_contacts',
|
||||
'pylon_list_users',
|
||||
'pylon_get_user',
|
||||
'pylon_update_user',
|
||||
'pylon_search_users',
|
||||
'pylon_list_teams',
|
||||
'pylon_get_team',
|
||||
'pylon_create_team',
|
||||
'pylon_update_team',
|
||||
'pylon_list_tags',
|
||||
'pylon_get_tag',
|
||||
'pylon_create_tag',
|
||||
'pylon_update_tag',
|
||||
'pylon_delete_tag',
|
||||
'pylon_redact_message',
|
||||
],
|
||||
config: {
|
||||
tool: (params) => {
|
||||
switch (params.operation) {
|
||||
// Issue operations
|
||||
case 'list_issues':
|
||||
return 'pylon_list_issues'
|
||||
case 'create_issue':
|
||||
return 'pylon_create_issue'
|
||||
case 'get_issue':
|
||||
return 'pylon_get_issue'
|
||||
case 'update_issue':
|
||||
return 'pylon_update_issue'
|
||||
case 'delete_issue':
|
||||
return 'pylon_delete_issue'
|
||||
case 'search_issues':
|
||||
return 'pylon_search_issues'
|
||||
case 'snooze_issue':
|
||||
return 'pylon_snooze_issue'
|
||||
case 'list_issue_followers':
|
||||
return 'pylon_list_issue_followers'
|
||||
case 'manage_issue_followers':
|
||||
return 'pylon_manage_issue_followers'
|
||||
case 'link_external_issue':
|
||||
return 'pylon_link_external_issue'
|
||||
// Account operations
|
||||
case 'list_accounts':
|
||||
return 'pylon_list_accounts'
|
||||
case 'create_account':
|
||||
return 'pylon_create_account'
|
||||
case 'get_account':
|
||||
return 'pylon_get_account'
|
||||
case 'update_account':
|
||||
return 'pylon_update_account'
|
||||
case 'delete_account':
|
||||
return 'pylon_delete_account'
|
||||
case 'bulk_update_accounts':
|
||||
return 'pylon_bulk_update_accounts'
|
||||
case 'search_accounts':
|
||||
return 'pylon_search_accounts'
|
||||
// Contact operations
|
||||
case 'list_contacts':
|
||||
return 'pylon_list_contacts'
|
||||
case 'create_contact':
|
||||
return 'pylon_create_contact'
|
||||
case 'get_contact':
|
||||
return 'pylon_get_contact'
|
||||
case 'update_contact':
|
||||
return 'pylon_update_contact'
|
||||
case 'delete_contact':
|
||||
return 'pylon_delete_contact'
|
||||
case 'search_contacts':
|
||||
return 'pylon_search_contacts'
|
||||
// User operations
|
||||
case 'list_users':
|
||||
return 'pylon_list_users'
|
||||
case 'get_user':
|
||||
return 'pylon_get_user'
|
||||
case 'update_user':
|
||||
return 'pylon_update_user'
|
||||
case 'search_users':
|
||||
return 'pylon_search_users'
|
||||
// Team operations
|
||||
case 'list_teams':
|
||||
return 'pylon_list_teams'
|
||||
case 'get_team':
|
||||
return 'pylon_get_team'
|
||||
case 'create_team':
|
||||
return 'pylon_create_team'
|
||||
case 'update_team':
|
||||
return 'pylon_update_team'
|
||||
// Tag operations
|
||||
case 'list_tags':
|
||||
return 'pylon_list_tags'
|
||||
case 'get_tag':
|
||||
return 'pylon_get_tag'
|
||||
case 'create_tag':
|
||||
return 'pylon_create_tag'
|
||||
case 'update_tag':
|
||||
return 'pylon_update_tag'
|
||||
case 'delete_tag':
|
||||
return 'pylon_delete_tag'
|
||||
// Message operations
|
||||
case 'redact_message':
|
||||
return 'pylon_redact_message'
|
||||
default:
|
||||
throw new Error(`Unknown operation: ${params.operation}`)
|
||||
}
|
||||
},
|
||||
params: (params) => {
|
||||
const { apiToken, operation, ...rest } = params
|
||||
const cleanParams: Record<string, any> = { apiToken }
|
||||
|
||||
// Handle parameter mapping
|
||||
if (params.accountIdField) {
|
||||
cleanParams.accountId = params.accountIdField
|
||||
}
|
||||
if (params.followerOperation) {
|
||||
cleanParams.operation = params.followerOperation
|
||||
}
|
||||
|
||||
Object.entries(rest).forEach(([key, value]) => {
|
||||
if (value !== undefined && value !== null && value !== '') {
|
||||
// Skip mapped fields
|
||||
if (key === 'accountIdField' || key === 'followerOperation') {
|
||||
return
|
||||
}
|
||||
cleanParams[key] = value
|
||||
}
|
||||
})
|
||||
|
||||
return cleanParams
|
||||
},
|
||||
},
|
||||
},
|
||||
inputs: {
|
||||
operation: { type: 'string', description: 'Operation to perform' },
|
||||
apiToken: { type: 'string', description: 'Pylon API token' },
|
||||
},
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: { type: 'json', description: 'Operation result data' },
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,510 @@
|
||||
import { ZendeskIcon } from '@/components/icons'
|
||||
import type { BlockConfig } from '@/blocks/types'
|
||||
import { AuthMode } from '@/blocks/types'
|
||||
|
||||
export const ZendeskBlock: BlockConfig = {
|
||||
type: 'zendesk',
|
||||
name: 'Zendesk',
|
||||
description: 'Manage support tickets, users, and organizations in Zendesk',
|
||||
longDescription:
|
||||
'Integrate Zendesk into the workflow. Can get tickets, get ticket, create ticket, create tickets bulk, update ticket, update tickets bulk, delete ticket, merge tickets, get users, get user, get current user, search users, create user, create users bulk, update user, update users bulk, delete user, get organizations, get organization, autocomplete organizations, create organization, create organizations bulk, update organization, delete organization, search, search count.',
|
||||
docsLink: 'https://docs.sim.ai/tools/zendesk',
|
||||
authMode: AuthMode.ApiKey,
|
||||
category: 'tools',
|
||||
bgColor: '#E0E0E0',
|
||||
icon: ZendeskIcon,
|
||||
subBlocks: [
|
||||
{
|
||||
id: 'operation',
|
||||
title: 'Operation',
|
||||
type: 'dropdown',
|
||||
options: [
|
||||
{ label: 'Get Tickets', id: 'get_tickets' },
|
||||
{ label: 'Get Ticket', id: 'get_ticket' },
|
||||
{ label: 'Create Ticket', id: 'create_ticket' },
|
||||
{ label: 'Create Tickets Bulk', id: 'create_tickets_bulk' },
|
||||
{ label: 'Update Ticket', id: 'update_ticket' },
|
||||
{ label: 'Update Tickets Bulk', id: 'update_tickets_bulk' },
|
||||
{ label: 'Delete Ticket', id: 'delete_ticket' },
|
||||
{ label: 'Merge Tickets', id: 'merge_tickets' },
|
||||
{ label: 'Get Users', id: 'get_users' },
|
||||
{ label: 'Get User', id: 'get_user' },
|
||||
{ label: 'Get Current User', id: 'get_current_user' },
|
||||
{ label: 'Search Users', id: 'search_users' },
|
||||
{ label: 'Create User', id: 'create_user' },
|
||||
{ label: 'Create Users Bulk', id: 'create_users_bulk' },
|
||||
{ label: 'Update User', id: 'update_user' },
|
||||
{ label: 'Update Users Bulk', id: 'update_users_bulk' },
|
||||
{ label: 'Delete User', id: 'delete_user' },
|
||||
{ label: 'Get Organizations', id: 'get_organizations' },
|
||||
{ label: 'Get Organization', id: 'get_organization' },
|
||||
{ label: 'Autocomplete Organizations', id: 'autocomplete_organizations' },
|
||||
{ label: 'Create Organization', id: 'create_organization' },
|
||||
{ label: 'Create Organizations Bulk', id: 'create_organizations_bulk' },
|
||||
{ label: 'Update Organization', id: 'update_organization' },
|
||||
{ label: 'Delete Organization', id: 'delete_organization' },
|
||||
{ label: 'Search', id: 'search' },
|
||||
{ label: 'Search Count', id: 'search_count' },
|
||||
],
|
||||
value: () => 'get_tickets',
|
||||
},
|
||||
{
|
||||
id: 'email',
|
||||
title: 'Email',
|
||||
type: 'short-input',
|
||||
placeholder: 'Your Zendesk email address',
|
||||
required: true,
|
||||
description: 'The email address associated with your Zendesk account',
|
||||
},
|
||||
{
|
||||
id: 'apiToken',
|
||||
title: 'API Token',
|
||||
type: 'short-input',
|
||||
password: true,
|
||||
placeholder: 'Enter your Zendesk API token',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
id: 'subdomain',
|
||||
title: 'Subdomain',
|
||||
type: 'short-input',
|
||||
placeholder: 'Your Zendesk subdomain (e.g., "mycompany")',
|
||||
required: true,
|
||||
description: 'The subdomain from your Zendesk URL (mycompany.zendesk.com)',
|
||||
},
|
||||
// Ticket fields
|
||||
{
|
||||
id: 'ticketId',
|
||||
title: 'Ticket ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'Ticket ID',
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['get_ticket', 'update_ticket', 'delete_ticket'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'subject',
|
||||
title: 'Subject',
|
||||
type: 'short-input',
|
||||
placeholder: 'Ticket subject',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_ticket', 'update_ticket'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'description',
|
||||
title: 'Description',
|
||||
type: 'long-input',
|
||||
placeholder: 'Ticket description',
|
||||
required: {
|
||||
field: 'operation',
|
||||
value: ['create_ticket'],
|
||||
},
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_ticket', 'update_ticket'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'status',
|
||||
title: 'Status',
|
||||
type: 'short-input',
|
||||
placeholder: 'Status (new, open, pending, hold, solved, closed)',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['get_tickets', 'create_ticket', 'update_ticket'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'priority',
|
||||
title: 'Priority',
|
||||
type: 'short-input',
|
||||
placeholder: 'Priority (low, normal, high, urgent)',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['get_tickets', 'create_ticket', 'update_ticket'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'type',
|
||||
title: 'Type',
|
||||
type: 'short-input',
|
||||
placeholder: 'Type (problem, incident, question, task)',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['get_tickets', 'create_ticket', 'update_ticket'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'tags',
|
||||
title: 'Tags',
|
||||
type: 'short-input',
|
||||
placeholder: 'Comma-separated tags',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_ticket', 'update_ticket'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'assigneeId',
|
||||
title: 'Assignee ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'User ID to assign ticket to',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['get_tickets', 'create_ticket', 'update_ticket'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'groupId',
|
||||
title: 'Group ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'Group ID',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_ticket', 'update_ticket'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'customFields',
|
||||
title: 'Custom Fields',
|
||||
type: 'long-input',
|
||||
placeholder: 'JSON object with custom fields',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_ticket', 'update_ticket'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'tickets',
|
||||
title: 'Tickets',
|
||||
type: 'long-input',
|
||||
placeholder: 'JSON array of ticket objects',
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_tickets_bulk', 'update_tickets_bulk'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'targetTicketId',
|
||||
title: 'Target Ticket ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'Ticket ID to merge into',
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['merge_tickets'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'sourceTicketIds',
|
||||
title: 'Source Ticket IDs',
|
||||
type: 'short-input',
|
||||
placeholder: 'Comma-separated ticket IDs to merge',
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['merge_tickets'],
|
||||
},
|
||||
},
|
||||
// User fields
|
||||
{
|
||||
id: 'userId',
|
||||
title: 'User ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'User ID',
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['get_user', 'update_user', 'delete_user'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'name',
|
||||
title: 'Name',
|
||||
type: 'short-input',
|
||||
placeholder: 'User name',
|
||||
required: {
|
||||
field: 'operation',
|
||||
value: ['create_user'],
|
||||
},
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_user', 'update_user'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'userEmail',
|
||||
title: 'Email',
|
||||
type: 'short-input',
|
||||
placeholder: 'User email',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_user', 'update_user'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'users',
|
||||
title: 'Users',
|
||||
type: 'long-input',
|
||||
placeholder: 'JSON array of user objects',
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_users_bulk', 'update_users_bulk'],
|
||||
},
|
||||
},
|
||||
// Organization fields
|
||||
{
|
||||
id: 'organizationId',
|
||||
title: 'Organization ID',
|
||||
type: 'short-input',
|
||||
placeholder: 'Organization ID',
|
||||
required: {
|
||||
field: 'operation',
|
||||
value: ['get_organization', 'delete_organization'],
|
||||
},
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: [
|
||||
'get_tickets',
|
||||
'create_ticket',
|
||||
'get_organization',
|
||||
'delete_organization',
|
||||
'update_organization',
|
||||
'create_user',
|
||||
'update_user',
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'organizationName',
|
||||
title: 'Organization Name',
|
||||
type: 'short-input',
|
||||
placeholder: 'Organization name',
|
||||
required: {
|
||||
field: 'operation',
|
||||
value: ['autocomplete_organizations'],
|
||||
},
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['autocomplete_organizations', 'create_organization', 'update_organization'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'organizations',
|
||||
title: 'Organizations',
|
||||
type: 'long-input',
|
||||
placeholder: 'JSON array of organization objects',
|
||||
required: true,
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['create_organizations_bulk'],
|
||||
},
|
||||
},
|
||||
// Search fields
|
||||
{
|
||||
id: 'query',
|
||||
title: 'Query',
|
||||
type: 'short-input',
|
||||
placeholder: 'Search query',
|
||||
required: {
|
||||
field: 'operation',
|
||||
value: ['search', 'search_count'],
|
||||
},
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['search_users', 'search', 'search_count'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'sortBy',
|
||||
title: 'Sort By',
|
||||
type: 'dropdown',
|
||||
options: [
|
||||
{ label: 'Relevance', id: 'relevance' },
|
||||
{ label: 'Created At', id: 'created_at' },
|
||||
{ label: 'Updated At', id: 'updated_at' },
|
||||
{ label: 'Priority', id: 'priority' },
|
||||
{ label: 'Status', id: 'status' },
|
||||
{ label: 'Ticket Type', id: 'ticket_type' },
|
||||
],
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['search'],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'sortOrder',
|
||||
title: 'Sort Order',
|
||||
type: 'dropdown',
|
||||
options: [
|
||||
{ label: 'Ascending', id: 'asc' },
|
||||
{ label: 'Descending', id: 'desc' },
|
||||
],
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: ['search'],
|
||||
},
|
||||
},
|
||||
// Pagination fields
|
||||
{
|
||||
id: 'perPage',
|
||||
title: 'Per Page',
|
||||
type: 'short-input',
|
||||
placeholder: 'Results per page (default: 100, max: 100)',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: [
|
||||
'get_tickets',
|
||||
'get_users',
|
||||
'get_organizations',
|
||||
'search_users',
|
||||
'autocomplete_organizations',
|
||||
'search',
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'page',
|
||||
title: 'Page',
|
||||
type: 'short-input',
|
||||
placeholder: 'Page number',
|
||||
condition: {
|
||||
field: 'operation',
|
||||
value: [
|
||||
'get_tickets',
|
||||
'get_users',
|
||||
'get_organizations',
|
||||
'search_users',
|
||||
'autocomplete_organizations',
|
||||
'search',
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
tools: {
|
||||
access: [
|
||||
'zendesk_get_tickets',
|
||||
'zendesk_get_ticket',
|
||||
'zendesk_create_ticket',
|
||||
'zendesk_create_tickets_bulk',
|
||||
'zendesk_update_ticket',
|
||||
'zendesk_update_tickets_bulk',
|
||||
'zendesk_delete_ticket',
|
||||
'zendesk_merge_tickets',
|
||||
'zendesk_get_users',
|
||||
'zendesk_get_user',
|
||||
'zendesk_get_current_user',
|
||||
'zendesk_search_users',
|
||||
'zendesk_create_user',
|
||||
'zendesk_create_users_bulk',
|
||||
'zendesk_update_user',
|
||||
'zendesk_update_users_bulk',
|
||||
'zendesk_delete_user',
|
||||
'zendesk_get_organizations',
|
||||
'zendesk_get_organization',
|
||||
'zendesk_autocomplete_organizations',
|
||||
'zendesk_create_organization',
|
||||
'zendesk_create_organizations_bulk',
|
||||
'zendesk_update_organization',
|
||||
'zendesk_delete_organization',
|
||||
'zendesk_search',
|
||||
'zendesk_search_count',
|
||||
],
|
||||
config: {
|
||||
tool: (params) => {
|
||||
switch (params.operation) {
|
||||
case 'get_tickets':
|
||||
return 'zendesk_get_tickets'
|
||||
case 'get_ticket':
|
||||
return 'zendesk_get_ticket'
|
||||
case 'create_ticket':
|
||||
return 'zendesk_create_ticket'
|
||||
case 'create_tickets_bulk':
|
||||
return 'zendesk_create_tickets_bulk'
|
||||
case 'update_ticket':
|
||||
return 'zendesk_update_ticket'
|
||||
case 'update_tickets_bulk':
|
||||
return 'zendesk_update_tickets_bulk'
|
||||
case 'delete_ticket':
|
||||
return 'zendesk_delete_ticket'
|
||||
case 'merge_tickets':
|
||||
return 'zendesk_merge_tickets'
|
||||
case 'get_users':
|
||||
return 'zendesk_get_users'
|
||||
case 'get_user':
|
||||
return 'zendesk_get_user'
|
||||
case 'get_current_user':
|
||||
return 'zendesk_get_current_user'
|
||||
case 'search_users':
|
||||
return 'zendesk_search_users'
|
||||
case 'create_user':
|
||||
return 'zendesk_create_user'
|
||||
case 'create_users_bulk':
|
||||
return 'zendesk_create_users_bulk'
|
||||
case 'update_user':
|
||||
return 'zendesk_update_user'
|
||||
case 'update_users_bulk':
|
||||
return 'zendesk_update_users_bulk'
|
||||
case 'delete_user':
|
||||
return 'zendesk_delete_user'
|
||||
case 'get_organizations':
|
||||
return 'zendesk_get_organizations'
|
||||
case 'get_organization':
|
||||
return 'zendesk_get_organization'
|
||||
case 'autocomplete_organizations':
|
||||
return 'zendesk_autocomplete_organizations'
|
||||
case 'create_organization':
|
||||
return 'zendesk_create_organization'
|
||||
case 'create_organizations_bulk':
|
||||
return 'zendesk_create_organizations_bulk'
|
||||
case 'update_organization':
|
||||
return 'zendesk_update_organization'
|
||||
case 'delete_organization':
|
||||
return 'zendesk_delete_organization'
|
||||
case 'search':
|
||||
return 'zendesk_search'
|
||||
case 'search_count':
|
||||
return 'zendesk_search_count'
|
||||
default:
|
||||
throw new Error(`Unknown operation: ${params.operation}`)
|
||||
}
|
||||
},
|
||||
params: (params) => {
|
||||
const { apiToken, operation, ...rest } = params
|
||||
const cleanParams: Record<string, any> = { apiToken }
|
||||
|
||||
// Special mapping for autocomplete_organizations
|
||||
if (operation === 'autocomplete_organizations' && params.organizationName) {
|
||||
cleanParams.name = params.organizationName
|
||||
}
|
||||
|
||||
Object.entries(rest).forEach(([key, value]) => {
|
||||
if (value !== undefined && value !== null && value !== '') {
|
||||
// Skip organizationName for autocomplete_organizations as it's mapped to 'name'
|
||||
if (operation === 'autocomplete_organizations' && key === 'organizationName') {
|
||||
return
|
||||
}
|
||||
cleanParams[key] = value
|
||||
}
|
||||
})
|
||||
return cleanParams
|
||||
},
|
||||
},
|
||||
},
|
||||
inputs: {
|
||||
operation: { type: 'string', description: 'Operation to perform' },
|
||||
email: { type: 'string', description: 'Zendesk email address' },
|
||||
apiToken: { type: 'string', description: 'Zendesk API token' },
|
||||
subdomain: { type: 'string', description: 'Zendesk subdomain' },
|
||||
},
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: { type: 'json', description: 'Operation result data' },
|
||||
},
|
||||
}
|
||||
@@ -36,11 +36,13 @@ import { HunterBlock } from '@/blocks/blocks/hunter'
|
||||
import { ImageGeneratorBlock } from '@/blocks/blocks/image_generator'
|
||||
import { IncidentioBlock } from '@/blocks/blocks/incidentio'
|
||||
import { InputTriggerBlock } from '@/blocks/blocks/input_trigger'
|
||||
import { IntercomBlock } from '@/blocks/blocks/intercom'
|
||||
import { JinaBlock } from '@/blocks/blocks/jina'
|
||||
import { JiraBlock } from '@/blocks/blocks/jira'
|
||||
import { KnowledgeBlock } from '@/blocks/blocks/knowledge'
|
||||
import { LinearBlock } from '@/blocks/blocks/linear'
|
||||
import { LinkupBlock } from '@/blocks/blocks/linkup'
|
||||
import { MailchimpBlock } from '@/blocks/blocks/mailchimp'
|
||||
import { ManualTriggerBlock } from '@/blocks/blocks/manual_trigger'
|
||||
import { McpBlock } from '@/blocks/blocks/mcp'
|
||||
import { Mem0Block } from '@/blocks/blocks/mem0'
|
||||
@@ -63,6 +65,7 @@ import { PineconeBlock } from '@/blocks/blocks/pinecone'
|
||||
import { PipedriveBlock } from '@/blocks/blocks/pipedrive'
|
||||
import { PostgreSQLBlock } from '@/blocks/blocks/postgresql'
|
||||
import { PostHogBlock } from '@/blocks/blocks/posthog'
|
||||
import { PylonBlock } from '@/blocks/blocks/pylon'
|
||||
import { QdrantBlock } from '@/blocks/blocks/qdrant'
|
||||
import { RedditBlock } from '@/blocks/blocks/reddit'
|
||||
import { ResendBlock } from '@/blocks/blocks/resend'
|
||||
@@ -104,6 +107,7 @@ import { WorkflowBlock } from '@/blocks/blocks/workflow'
|
||||
import { WorkflowInputBlock } from '@/blocks/blocks/workflow_input'
|
||||
import { XBlock } from '@/blocks/blocks/x'
|
||||
import { YouTubeBlock } from '@/blocks/blocks/youtube'
|
||||
import { ZendeskBlock } from '@/blocks/blocks/zendesk'
|
||||
import { ZepBlock } from '@/blocks/blocks/zep'
|
||||
import type { BlockConfig } from '@/blocks/types'
|
||||
|
||||
@@ -149,6 +153,7 @@ export const registry: Record<string, BlockConfig> = {
|
||||
knowledge: KnowledgeBlock,
|
||||
linear: LinearBlock,
|
||||
linkup: LinkupBlock,
|
||||
mailchimp: MailchimpBlock,
|
||||
mcp: McpBlock,
|
||||
mem0: Mem0Block,
|
||||
zep: ZepBlock,
|
||||
@@ -170,6 +175,7 @@ export const registry: Record<string, BlockConfig> = {
|
||||
pinecone: PineconeBlock,
|
||||
pipedrive: PipedriveBlock,
|
||||
postgresql: PostgreSQLBlock,
|
||||
pylon: PylonBlock,
|
||||
qdrant: QdrantBlock,
|
||||
resend: ResendBlock,
|
||||
memory: MemoryBlock,
|
||||
@@ -180,6 +186,8 @@ export const registry: Record<string, BlockConfig> = {
|
||||
s3: S3Block,
|
||||
salesforce: SalesforceBlock,
|
||||
sentry: SentryBlock,
|
||||
intercom: IntercomBlock,
|
||||
zendesk: ZendeskBlock,
|
||||
serper: SerperBlock,
|
||||
sharepoint: SharepointBlock,
|
||||
stagehand: StagehandBlock,
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,163 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildIntercomUrl, handleIntercomError } from './types'
|
||||
|
||||
const logger = createLogger('IntercomCreateCompany')
|
||||
|
||||
export interface IntercomCreateCompanyParams {
|
||||
accessToken: string
|
||||
company_id: string
|
||||
name?: string
|
||||
website?: string
|
||||
plan?: string
|
||||
size?: number
|
||||
industry?: string
|
||||
monthly_spend?: number
|
||||
custom_attributes?: string
|
||||
}
|
||||
|
||||
export interface IntercomCreateCompanyResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
company: any
|
||||
metadata: {
|
||||
operation: 'create_company'
|
||||
companyId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const intercomCreateCompanyTool: ToolConfig<
|
||||
IntercomCreateCompanyParams,
|
||||
IntercomCreateCompanyResponse
|
||||
> = {
|
||||
id: 'intercom_create_company',
|
||||
name: 'Create Company in Intercom',
|
||||
description: 'Create or update a company in Intercom',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Intercom API access token',
|
||||
},
|
||||
company_id: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Your unique identifier for the company',
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'The name of the company',
|
||||
},
|
||||
website: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'The company website',
|
||||
},
|
||||
plan: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'The company plan name',
|
||||
},
|
||||
size: {
|
||||
type: 'number',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'The number of employees in the company',
|
||||
},
|
||||
industry: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'The industry the company operates in',
|
||||
},
|
||||
monthly_spend: {
|
||||
type: 'number',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'How much revenue the company generates for your business',
|
||||
},
|
||||
custom_attributes: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Custom attributes as JSON object',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: () => buildIntercomUrl('/companies'),
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
'Intercom-Version': '2.14',
|
||||
}),
|
||||
body: (params) => {
|
||||
const company: any = {
|
||||
company_id: params.company_id,
|
||||
}
|
||||
|
||||
if (params.name) company.name = params.name
|
||||
if (params.website) company.website = params.website
|
||||
if (params.plan) company.plan = params.plan
|
||||
if (params.size) company.size = params.size
|
||||
if (params.industry) company.industry = params.industry
|
||||
if (params.monthly_spend) company.monthly_spend = params.monthly_spend
|
||||
|
||||
if (params.custom_attributes) {
|
||||
try {
|
||||
company.custom_attributes = JSON.parse(params.custom_attributes)
|
||||
} catch (error) {
|
||||
logger.warn('Failed to parse custom attributes', { error })
|
||||
}
|
||||
}
|
||||
|
||||
return company
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleIntercomError(data, response.status, 'create_company')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
company: data,
|
||||
metadata: {
|
||||
operation: 'create_company' as const,
|
||||
companyId: data.id,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Created or updated company data',
|
||||
properties: {
|
||||
company: { type: 'object', description: 'Company object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildIntercomUrl, handleIntercomError } from './types'
|
||||
|
||||
const logger = createLogger('IntercomCreateContact')
|
||||
|
||||
export interface IntercomCreateContactParams {
|
||||
accessToken: string
|
||||
email?: string
|
||||
external_id?: string
|
||||
phone?: string
|
||||
name?: string
|
||||
avatar?: string
|
||||
signed_up_at?: number
|
||||
last_seen_at?: number
|
||||
owner_id?: string
|
||||
unsubscribed_from_emails?: boolean
|
||||
custom_attributes?: string
|
||||
}
|
||||
|
||||
export interface IntercomCreateContactResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
contact: any
|
||||
metadata: {
|
||||
operation: 'create_contact'
|
||||
contactId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const intercomCreateContactTool: ToolConfig<
|
||||
IntercomCreateContactParams,
|
||||
IntercomCreateContactResponse
|
||||
> = {
|
||||
id: 'intercom_create_contact',
|
||||
name: 'Create Contact in Intercom',
|
||||
description: 'Create a new contact in Intercom with email, external_id, or role',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Intercom API access token',
|
||||
},
|
||||
email: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: "The contact's email address",
|
||||
},
|
||||
external_id: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'A unique identifier for the contact provided by the client',
|
||||
},
|
||||
phone: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: "The contact's phone number",
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: "The contact's name",
|
||||
},
|
||||
avatar: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'An avatar image URL for the contact',
|
||||
},
|
||||
signed_up_at: {
|
||||
type: 'number',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'The time the user signed up as a Unix timestamp',
|
||||
},
|
||||
last_seen_at: {
|
||||
type: 'number',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'The time the user was last seen as a Unix timestamp',
|
||||
},
|
||||
owner_id: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'The id of an admin that has been assigned account ownership of the contact',
|
||||
},
|
||||
unsubscribed_from_emails: {
|
||||
type: 'boolean',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Whether the contact is unsubscribed from emails',
|
||||
},
|
||||
custom_attributes: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Custom attributes as JSON object (e.g., {"attribute_name": "value"})',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: () => buildIntercomUrl('/contacts'),
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
'Content-Type': 'application/json',
|
||||
'Intercom-Version': '2.14',
|
||||
}),
|
||||
body: (params) => {
|
||||
const contact: any = {}
|
||||
|
||||
if (params.email) contact.email = params.email
|
||||
if (params.external_id) contact.external_id = params.external_id
|
||||
if (params.phone) contact.phone = params.phone
|
||||
if (params.name) contact.name = params.name
|
||||
if (params.avatar) contact.avatar = params.avatar
|
||||
if (params.signed_up_at) contact.signed_up_at = params.signed_up_at
|
||||
if (params.last_seen_at) contact.last_seen_at = params.last_seen_at
|
||||
if (params.owner_id) contact.owner_id = params.owner_id
|
||||
if (params.unsubscribed_from_emails !== undefined)
|
||||
contact.unsubscribed_from_emails = params.unsubscribed_from_emails
|
||||
|
||||
if (params.custom_attributes) {
|
||||
try {
|
||||
contact.custom_attributes = JSON.parse(params.custom_attributes)
|
||||
} catch (error) {
|
||||
logger.warn('Failed to parse custom attributes', { error })
|
||||
}
|
||||
}
|
||||
|
||||
return contact
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleIntercomError(data, response.status, 'create_contact')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
contact: data,
|
||||
metadata: {
|
||||
operation: 'create_contact' as const,
|
||||
contactId: data.id,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Created contact data',
|
||||
properties: {
|
||||
contact: { type: 'object', description: 'Created contact object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildIntercomUrl, handleIntercomError } from './types'
|
||||
|
||||
const logger = createLogger('IntercomCreateMessage')
|
||||
|
||||
export interface IntercomCreateMessageParams {
|
||||
accessToken: string
|
||||
message_type: string
|
||||
subject?: string
|
||||
body: string
|
||||
from_type: string
|
||||
from_id: string
|
||||
to_type: string
|
||||
to_id: string
|
||||
}
|
||||
|
||||
export interface IntercomCreateMessageResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
message: any
|
||||
metadata: {
|
||||
operation: 'create_message'
|
||||
messageId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const intercomCreateMessageTool: ToolConfig<
|
||||
IntercomCreateMessageParams,
|
||||
IntercomCreateMessageResponse
|
||||
> = {
|
||||
id: 'intercom_create_message',
|
||||
name: 'Create Message in Intercom',
|
||||
description: 'Create and send a new admin-initiated message in Intercom',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Intercom API access token',
|
||||
},
|
||||
message_type: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Message type: "inapp" or "email"',
|
||||
},
|
||||
subject: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'The subject of the message (for email type)',
|
||||
},
|
||||
body: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The body of the message',
|
||||
},
|
||||
from_type: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Sender type: "admin"',
|
||||
},
|
||||
from_id: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The ID of the admin sending the message',
|
||||
},
|
||||
to_type: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Recipient type: "contact"',
|
||||
},
|
||||
to_id: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The ID of the contact receiving the message',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: () => buildIntercomUrl('/messages'),
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
'Content-Type': 'application/json',
|
||||
'Intercom-Version': '2.14',
|
||||
}),
|
||||
body: (params) => {
|
||||
const message: any = {
|
||||
message_type: params.message_type,
|
||||
body: params.body,
|
||||
from: {
|
||||
type: params.from_type,
|
||||
id: params.from_id,
|
||||
},
|
||||
to: {
|
||||
type: params.to_type,
|
||||
id: params.to_id,
|
||||
},
|
||||
}
|
||||
|
||||
if (params.subject && params.message_type === 'email') {
|
||||
message.subject = params.subject
|
||||
}
|
||||
|
||||
return message
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleIntercomError(data, response.status, 'create_message')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
message: data,
|
||||
metadata: {
|
||||
operation: 'create_message' as const,
|
||||
messageId: data.id,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Created message data',
|
||||
properties: {
|
||||
message: { type: 'object', description: 'Created message object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildIntercomUrl, handleIntercomError } from './types'
|
||||
|
||||
const logger = createLogger('IntercomCreateTicket')
|
||||
|
||||
export interface IntercomCreateTicketParams {
|
||||
accessToken: string
|
||||
ticket_type_id: string
|
||||
contacts: string
|
||||
ticket_attributes: string
|
||||
}
|
||||
|
||||
export interface IntercomCreateTicketResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
ticket: any
|
||||
metadata: {
|
||||
operation: 'create_ticket'
|
||||
ticketId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const intercomCreateTicketTool: ToolConfig<
|
||||
IntercomCreateTicketParams,
|
||||
IntercomCreateTicketResponse
|
||||
> = {
|
||||
id: 'intercom_create_ticket',
|
||||
name: 'Create Ticket in Intercom',
|
||||
description: 'Create a new ticket in Intercom',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Intercom API access token',
|
||||
},
|
||||
ticket_type_id: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The ID of the ticket type',
|
||||
},
|
||||
contacts: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'JSON array of contact identifiers (e.g., [{"id": "contact_id"}])',
|
||||
},
|
||||
ticket_attributes: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description:
|
||||
'JSON object with ticket attributes including _default_title_ and _default_description_',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: () => buildIntercomUrl('/tickets'),
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
'Content-Type': 'application/json',
|
||||
'Intercom-Version': '2.14',
|
||||
}),
|
||||
body: (params) => {
|
||||
const ticket: any = {
|
||||
ticket_type_id: params.ticket_type_id,
|
||||
}
|
||||
|
||||
try {
|
||||
ticket.contacts = JSON.parse(params.contacts)
|
||||
} catch (error) {
|
||||
logger.warn('Failed to parse contacts, using as single contact ID', { error })
|
||||
ticket.contacts = [{ id: params.contacts }]
|
||||
}
|
||||
|
||||
try {
|
||||
ticket.ticket_attributes = JSON.parse(params.ticket_attributes)
|
||||
} catch (error) {
|
||||
logger.error('Failed to parse ticket attributes', { error })
|
||||
throw new Error('ticket_attributes must be a valid JSON object')
|
||||
}
|
||||
|
||||
return ticket
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleIntercomError(data, response.status, 'create_ticket')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
ticket: data,
|
||||
metadata: {
|
||||
operation: 'create_ticket' as const,
|
||||
ticketId: data.id,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Created ticket data',
|
||||
properties: {
|
||||
ticket: { type: 'object', description: 'Created ticket object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildIntercomUrl, handleIntercomError } from './types'
|
||||
|
||||
const logger = createLogger('IntercomDeleteContact')
|
||||
|
||||
export interface IntercomDeleteContactParams {
|
||||
accessToken: string
|
||||
contactId: string
|
||||
}
|
||||
|
||||
export interface IntercomDeleteContactResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
id: string
|
||||
deleted: boolean
|
||||
metadata: {
|
||||
operation: 'delete_contact'
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const intercomDeleteContactTool: ToolConfig<
|
||||
IntercomDeleteContactParams,
|
||||
IntercomDeleteContactResponse
|
||||
> = {
|
||||
id: 'intercom_delete_contact',
|
||||
name: 'Delete Contact from Intercom',
|
||||
description: 'Delete a contact from Intercom by ID',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Intercom API access token',
|
||||
},
|
||||
contactId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Contact ID to delete',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => buildIntercomUrl(`/contacts/${params.contactId}`),
|
||||
method: 'DELETE',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
'Content-Type': 'application/json',
|
||||
'Intercom-Version': '2.14',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleIntercomError(data, response.status, 'delete_contact')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
id: data.id,
|
||||
deleted: true,
|
||||
metadata: {
|
||||
operation: 'delete_contact' as const,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Deletion result',
|
||||
properties: {
|
||||
id: { type: 'string', description: 'ID of deleted contact' },
|
||||
deleted: { type: 'boolean', description: 'Deletion status' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildIntercomUrl, handleIntercomError } from './types'
|
||||
|
||||
const logger = createLogger('IntercomGetCompany')
|
||||
|
||||
export interface IntercomGetCompanyParams {
|
||||
accessToken: string
|
||||
companyId: string
|
||||
}
|
||||
|
||||
export interface IntercomGetCompanyResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
company: any
|
||||
metadata: {
|
||||
operation: 'get_company'
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const intercomGetCompanyTool: ToolConfig<
|
||||
IntercomGetCompanyParams,
|
||||
IntercomGetCompanyResponse
|
||||
> = {
|
||||
id: 'intercom_get_company',
|
||||
name: 'Get Company from Intercom',
|
||||
description: 'Retrieve a single company by ID from Intercom',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Intercom API access token',
|
||||
},
|
||||
companyId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Company ID to retrieve',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => buildIntercomUrl(`/companies/${params.companyId}`),
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
'Intercom-Version': '2.14',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleIntercomError(data, response.status, 'get_company')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
company: data,
|
||||
metadata: {
|
||||
operation: 'get_company' as const,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Company data',
|
||||
properties: {
|
||||
company: { type: 'object', description: 'Company object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildIntercomUrl, handleIntercomError } from './types'
|
||||
|
||||
const logger = createLogger('IntercomGetContact')
|
||||
|
||||
export interface IntercomGetContactParams {
|
||||
accessToken: string
|
||||
contactId: string
|
||||
}
|
||||
|
||||
export interface IntercomGetContactResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
contact: any
|
||||
metadata: {
|
||||
operation: 'get_contact'
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const intercomGetContactTool: ToolConfig<
|
||||
IntercomGetContactParams,
|
||||
IntercomGetContactResponse
|
||||
> = {
|
||||
id: 'intercom_get_contact',
|
||||
name: 'Get Single Contact from Intercom',
|
||||
description: 'Get a single contact by ID from Intercom',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Intercom API access token',
|
||||
},
|
||||
contactId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Contact ID to retrieve',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => buildIntercomUrl(`/contacts/${params.contactId}`),
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
'Intercom-Version': '2.14',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleIntercomError(data, response.status, 'get_contact')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
contact: data,
|
||||
metadata: {
|
||||
operation: 'get_contact' as const,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Contact data',
|
||||
properties: {
|
||||
contact: { type: 'object', description: 'Contact object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildIntercomUrl, handleIntercomError } from './types'
|
||||
|
||||
const logger = createLogger('IntercomGetConversation')
|
||||
|
||||
export interface IntercomGetConversationParams {
|
||||
accessToken: string
|
||||
conversationId: string
|
||||
display_as?: string
|
||||
}
|
||||
|
||||
export interface IntercomGetConversationResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
conversation: any
|
||||
metadata: {
|
||||
operation: 'get_conversation'
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const intercomGetConversationTool: ToolConfig<
|
||||
IntercomGetConversationParams,
|
||||
IntercomGetConversationResponse
|
||||
> = {
|
||||
id: 'intercom_get_conversation',
|
||||
name: 'Get Conversation from Intercom',
|
||||
description: 'Retrieve a single conversation by ID from Intercom',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Intercom API access token',
|
||||
},
|
||||
conversationId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Conversation ID to retrieve',
|
||||
},
|
||||
display_as: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Set to "plaintext" to retrieve messages in plain text',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const url = buildIntercomUrl(`/conversations/${params.conversationId}`)
|
||||
if (params.display_as) {
|
||||
return `${url}?display_as=${params.display_as}`
|
||||
}
|
||||
return url
|
||||
},
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
'Intercom-Version': '2.14',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleIntercomError(data, response.status, 'get_conversation')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
conversation: data,
|
||||
metadata: {
|
||||
operation: 'get_conversation' as const,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Conversation data',
|
||||
properties: {
|
||||
conversation: { type: 'object', description: 'Conversation object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildIntercomUrl, handleIntercomError } from './types'
|
||||
|
||||
const logger = createLogger('IntercomGetTicket')
|
||||
|
||||
export interface IntercomGetTicketParams {
|
||||
accessToken: string
|
||||
ticketId: string
|
||||
}
|
||||
|
||||
export interface IntercomGetTicketResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
ticket: any
|
||||
metadata: {
|
||||
operation: 'get_ticket'
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const intercomGetTicketTool: ToolConfig<IntercomGetTicketParams, IntercomGetTicketResponse> =
|
||||
{
|
||||
id: 'intercom_get_ticket',
|
||||
name: 'Get Ticket from Intercom',
|
||||
description: 'Retrieve a single ticket by ID from Intercom',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Intercom API access token',
|
||||
},
|
||||
ticketId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Ticket ID to retrieve',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => buildIntercomUrl(`/tickets/${params.ticketId}`),
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
'Intercom-Version': '2.14',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleIntercomError(data, response.status, 'get_ticket')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
ticket: data,
|
||||
metadata: {
|
||||
operation: 'get_ticket' as const,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Ticket data',
|
||||
properties: {
|
||||
ticket: { type: 'object', description: 'Ticket object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// Contact tools
|
||||
|
||||
// Company tools
|
||||
export { intercomCreateCompanyTool } from './create_company'
|
||||
export { intercomCreateContactTool } from './create_contact'
|
||||
// Message tools
|
||||
export { intercomCreateMessageTool } from './create_message'
|
||||
// Ticket tools
|
||||
export { intercomCreateTicketTool } from './create_ticket'
|
||||
export { intercomDeleteContactTool } from './delete_contact'
|
||||
export { intercomGetCompanyTool } from './get_company'
|
||||
export { intercomGetContactTool } from './get_contact'
|
||||
// Conversation tools
|
||||
export { intercomGetConversationTool } from './get_conversation'
|
||||
export { intercomGetTicketTool } from './get_ticket'
|
||||
export { intercomListCompaniesTool } from './list_companies'
|
||||
export { intercomListContactsTool } from './list_contacts'
|
||||
export { intercomListConversationsTool } from './list_conversations'
|
||||
export { intercomReplyConversationTool } from './reply_conversation'
|
||||
export { intercomSearchContactsTool } from './search_contacts'
|
||||
export { intercomSearchConversationsTool } from './search_conversations'
|
||||
export { intercomUpdateContactTool } from './update_contact'
|
||||
@@ -0,0 +1,111 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildIntercomUrl, handleIntercomError } from './types'
|
||||
|
||||
const logger = createLogger('IntercomListCompanies')
|
||||
|
||||
export interface IntercomListCompaniesParams {
|
||||
accessToken: string
|
||||
per_page?: number
|
||||
page?: number
|
||||
}
|
||||
|
||||
export interface IntercomListCompaniesResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
companies: any[]
|
||||
pages?: any
|
||||
metadata: {
|
||||
operation: 'list_companies'
|
||||
total_count?: number
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const intercomListCompaniesTool: ToolConfig<
|
||||
IntercomListCompaniesParams,
|
||||
IntercomListCompaniesResponse
|
||||
> = {
|
||||
id: 'intercom_list_companies',
|
||||
name: 'List Companies from Intercom',
|
||||
description: 'List all companies from Intercom with pagination support',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Intercom API access token',
|
||||
},
|
||||
per_page: {
|
||||
type: 'number',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Number of results per page',
|
||||
},
|
||||
page: {
|
||||
type: 'number',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Page number',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const url = buildIntercomUrl('/companies/list')
|
||||
const queryParams = new URLSearchParams()
|
||||
|
||||
if (params.per_page) queryParams.append('per_page', params.per_page.toString())
|
||||
if (params.page) queryParams.append('page', params.page.toString())
|
||||
|
||||
const queryString = queryParams.toString()
|
||||
return queryString ? `${url}?${queryString}` : url
|
||||
},
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
'Intercom-Version': '2.14',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleIntercomError(data, response.status, 'list_companies')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
companies: data.data || data.companies || [],
|
||||
pages: data.pages,
|
||||
metadata: {
|
||||
operation: 'list_companies' as const,
|
||||
total_count: data.total_count,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'List of companies',
|
||||
properties: {
|
||||
companies: { type: 'array', description: 'Array of company objects' },
|
||||
pages: { type: 'object', description: 'Pagination information' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildIntercomUrl, handleIntercomError } from './types'
|
||||
|
||||
const logger = createLogger('IntercomListContacts')
|
||||
|
||||
export interface IntercomListContactsParams {
|
||||
accessToken: string
|
||||
per_page?: number
|
||||
starting_after?: string
|
||||
}
|
||||
|
||||
export interface IntercomListContactsResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
contacts: any[]
|
||||
pages?: any
|
||||
metadata: {
|
||||
operation: 'list_contacts'
|
||||
total_count?: number
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const intercomListContactsTool: ToolConfig<
|
||||
IntercomListContactsParams,
|
||||
IntercomListContactsResponse
|
||||
> = {
|
||||
id: 'intercom_list_contacts',
|
||||
name: 'List Contacts from Intercom',
|
||||
description: 'List all contacts from Intercom with pagination support',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Intercom API access token',
|
||||
},
|
||||
per_page: {
|
||||
type: 'number',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Number of results per page (max: 150)',
|
||||
},
|
||||
starting_after: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Cursor for pagination - ID to start after',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const url = buildIntercomUrl('/contacts')
|
||||
const queryParams = new URLSearchParams()
|
||||
|
||||
if (params.per_page) queryParams.append('per_page', params.per_page.toString())
|
||||
if (params.starting_after) queryParams.append('starting_after', params.starting_after)
|
||||
|
||||
const queryString = queryParams.toString()
|
||||
return queryString ? `${url}?${queryString}` : url
|
||||
},
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
'Intercom-Version': '2.14',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleIntercomError(data, response.status, 'list_contacts')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
contacts: data.data || [],
|
||||
pages: data.pages,
|
||||
metadata: {
|
||||
operation: 'list_contacts' as const,
|
||||
total_count: data.total_count,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'List of contacts',
|
||||
properties: {
|
||||
contacts: { type: 'array', description: 'Array of contact objects' },
|
||||
pages: { type: 'object', description: 'Pagination information' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildIntercomUrl, handleIntercomError } from './types'
|
||||
|
||||
const logger = createLogger('IntercomListConversations')
|
||||
|
||||
export interface IntercomListConversationsParams {
|
||||
accessToken: string
|
||||
per_page?: number
|
||||
starting_after?: string
|
||||
}
|
||||
|
||||
export interface IntercomListConversationsResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
conversations: any[]
|
||||
pages?: any
|
||||
metadata: {
|
||||
operation: 'list_conversations'
|
||||
total_count?: number
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const intercomListConversationsTool: ToolConfig<
|
||||
IntercomListConversationsParams,
|
||||
IntercomListConversationsResponse
|
||||
> = {
|
||||
id: 'intercom_list_conversations',
|
||||
name: 'List Conversations from Intercom',
|
||||
description: 'List all conversations from Intercom with pagination support',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Intercom API access token',
|
||||
},
|
||||
per_page: {
|
||||
type: 'number',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Number of results per page (max: 150)',
|
||||
},
|
||||
starting_after: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Cursor for pagination',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const url = buildIntercomUrl('/conversations')
|
||||
const queryParams = new URLSearchParams()
|
||||
|
||||
if (params.per_page) queryParams.append('per_page', params.per_page.toString())
|
||||
if (params.starting_after) queryParams.append('starting_after', params.starting_after)
|
||||
|
||||
const queryString = queryParams.toString()
|
||||
return queryString ? `${url}?${queryString}` : url
|
||||
},
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
'Intercom-Version': '2.14',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleIntercomError(data, response.status, 'list_conversations')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
conversations: data.conversations || [],
|
||||
pages: data.pages,
|
||||
metadata: {
|
||||
operation: 'list_conversations' as const,
|
||||
total_count: data.total_count,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'List of conversations',
|
||||
properties: {
|
||||
conversations: { type: 'array', description: 'Array of conversation objects' },
|
||||
pages: { type: 'object', description: 'Pagination information' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildIntercomUrl, handleIntercomError } from './types'
|
||||
|
||||
const logger = createLogger('IntercomReplyConversation')
|
||||
|
||||
export interface IntercomReplyConversationParams {
|
||||
accessToken: string
|
||||
conversationId: string
|
||||
message_type: string
|
||||
body: string
|
||||
admin_id?: string
|
||||
attachment_urls?: string
|
||||
}
|
||||
|
||||
export interface IntercomReplyConversationResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
conversation: any
|
||||
metadata: {
|
||||
operation: 'reply_conversation'
|
||||
conversationId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const intercomReplyConversationTool: ToolConfig<
|
||||
IntercomReplyConversationParams,
|
||||
IntercomReplyConversationResponse
|
||||
> = {
|
||||
id: 'intercom_reply_conversation',
|
||||
name: 'Reply to Conversation in Intercom',
|
||||
description: 'Reply to a conversation as an admin in Intercom',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Intercom API access token',
|
||||
},
|
||||
conversationId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Conversation ID to reply to',
|
||||
},
|
||||
message_type: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Message type: "comment" or "note"',
|
||||
},
|
||||
body: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The text body of the reply',
|
||||
},
|
||||
admin_id: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The ID of the admin authoring the reply',
|
||||
},
|
||||
attachment_urls: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Comma-separated list of image URLs (max 10)',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => buildIntercomUrl(`/conversations/${params.conversationId}/reply`),
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
'Content-Type': 'application/json',
|
||||
'Intercom-Version': '2.14',
|
||||
}),
|
||||
body: (params) => {
|
||||
const reply: any = {
|
||||
message_type: params.message_type,
|
||||
type: 'admin',
|
||||
body: params.body,
|
||||
}
|
||||
|
||||
if (params.admin_id) reply.admin_id = params.admin_id
|
||||
|
||||
if (params.attachment_urls) {
|
||||
reply.attachment_urls = params.attachment_urls
|
||||
.split(',')
|
||||
.map((url) => url.trim())
|
||||
.slice(0, 10)
|
||||
}
|
||||
|
||||
return reply
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleIntercomError(data, response.status, 'reply_conversation')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
conversation: data,
|
||||
metadata: {
|
||||
operation: 'reply_conversation' as const,
|
||||
conversationId: data.id,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Updated conversation with reply',
|
||||
properties: {
|
||||
conversation: { type: 'object', description: 'Updated conversation object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildIntercomUrl, handleIntercomError } from './types'
|
||||
|
||||
const logger = createLogger('IntercomSearchContacts')
|
||||
|
||||
export interface IntercomSearchContactsParams {
|
||||
accessToken: string
|
||||
query: string
|
||||
per_page?: number
|
||||
starting_after?: string
|
||||
}
|
||||
|
||||
export interface IntercomSearchContactsResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
contacts: any[]
|
||||
pages?: any
|
||||
metadata: {
|
||||
operation: 'search_contacts'
|
||||
total_count?: number
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const intercomSearchContactsTool: ToolConfig<
|
||||
IntercomSearchContactsParams,
|
||||
IntercomSearchContactsResponse
|
||||
> = {
|
||||
id: 'intercom_search_contacts',
|
||||
name: 'Search Contacts in Intercom',
|
||||
description: 'Search for contacts in Intercom using a query',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Intercom API access token',
|
||||
},
|
||||
query: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description:
|
||||
'Search query (e.g., {"field":"email","operator":"=","value":"user@example.com"})',
|
||||
},
|
||||
per_page: {
|
||||
type: 'number',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Number of results per page (max: 150)',
|
||||
},
|
||||
starting_after: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Cursor for pagination',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: () => buildIntercomUrl('/contacts/search'),
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
'Intercom-Version': '2.14',
|
||||
}),
|
||||
body: (params) => {
|
||||
let query
|
||||
try {
|
||||
query = JSON.parse(params.query)
|
||||
} catch (error) {
|
||||
// If not JSON, treat as simple text search
|
||||
query = {
|
||||
field: 'name',
|
||||
operator: '~',
|
||||
value: params.query,
|
||||
}
|
||||
}
|
||||
|
||||
const body: any = { query }
|
||||
|
||||
if (params.per_page) body.pagination = { per_page: params.per_page }
|
||||
if (params.starting_after)
|
||||
body.pagination = { ...body.pagination, starting_after: params.starting_after }
|
||||
|
||||
return body
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleIntercomError(data, response.status, 'search_contacts')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
contacts: data.data || [],
|
||||
pages: data.pages,
|
||||
metadata: {
|
||||
operation: 'search_contacts' as const,
|
||||
total_count: data.total_count,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Search results',
|
||||
properties: {
|
||||
contacts: { type: 'array', description: 'Array of matching contact objects' },
|
||||
pages: { type: 'object', description: 'Pagination information' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildIntercomUrl, handleIntercomError } from './types'
|
||||
|
||||
const logger = createLogger('IntercomSearchConversations')
|
||||
|
||||
export interface IntercomSearchConversationsParams {
|
||||
accessToken: string
|
||||
query: string
|
||||
per_page?: number
|
||||
starting_after?: string
|
||||
}
|
||||
|
||||
export interface IntercomSearchConversationsResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
conversations: any[]
|
||||
pages?: any
|
||||
metadata: {
|
||||
operation: 'search_conversations'
|
||||
total_count?: number
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const intercomSearchConversationsTool: ToolConfig<
|
||||
IntercomSearchConversationsParams,
|
||||
IntercomSearchConversationsResponse
|
||||
> = {
|
||||
id: 'intercom_search_conversations',
|
||||
name: 'Search Conversations in Intercom',
|
||||
description: 'Search for conversations in Intercom using a query',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Intercom API access token',
|
||||
},
|
||||
query: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Search query as JSON object',
|
||||
},
|
||||
per_page: {
|
||||
type: 'number',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Number of results per page (max: 150)',
|
||||
},
|
||||
starting_after: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Cursor for pagination',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: () => buildIntercomUrl('/conversations/search'),
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
'Intercom-Version': '2.14',
|
||||
}),
|
||||
body: (params) => {
|
||||
let query
|
||||
try {
|
||||
query = JSON.parse(params.query)
|
||||
} catch (error) {
|
||||
logger.warn('Failed to parse search query, using default', { error })
|
||||
query = {
|
||||
field: 'updated_at',
|
||||
operator: '>',
|
||||
value: Math.floor(Date.now() / 1000) - 86400, // Last 24 hours
|
||||
}
|
||||
}
|
||||
|
||||
const body: any = { query }
|
||||
|
||||
if (params.per_page) body.pagination = { per_page: params.per_page }
|
||||
if (params.starting_after)
|
||||
body.pagination = { ...body.pagination, starting_after: params.starting_after }
|
||||
|
||||
return body
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleIntercomError(data, response.status, 'search_conversations')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
conversations: data.conversations || [],
|
||||
pages: data.pages,
|
||||
metadata: {
|
||||
operation: 'search_conversations' as const,
|
||||
total_count: data.total_count,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Search results',
|
||||
properties: {
|
||||
conversations: { type: 'array', description: 'Array of matching conversation objects' },
|
||||
pages: { type: 'object', description: 'Pagination information' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
|
||||
const logger = createLogger('Intercom')
|
||||
|
||||
// Base params for Intercom API
|
||||
export interface IntercomBaseParams {
|
||||
accessToken: string // OAuth token or API token (hidden)
|
||||
}
|
||||
|
||||
export interface IntercomPaginationParams {
|
||||
per_page?: number
|
||||
starting_after?: string // Cursor for pagination
|
||||
}
|
||||
|
||||
export interface IntercomPagingInfo {
|
||||
next?: {
|
||||
page: number
|
||||
starting_after: string
|
||||
} | null
|
||||
total_count?: number
|
||||
}
|
||||
|
||||
export interface IntercomResponse<T> {
|
||||
success: boolean
|
||||
output: {
|
||||
data?: T
|
||||
pages?: IntercomPagingInfo
|
||||
metadata: {
|
||||
operation: string
|
||||
[key: string]: any
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function to build Intercom API URLs
|
||||
export function buildIntercomUrl(path: string): string {
|
||||
return `https://api.intercom.io${path}`
|
||||
}
|
||||
|
||||
// Helper function for consistent error handling
|
||||
export function handleIntercomError(data: any, status: number, operation: string): never {
|
||||
logger.error(`Intercom API request failed for ${operation}`, { data, status })
|
||||
|
||||
const errorMessage = data.errors?.[0]?.message || data.error || data.message || 'Unknown error'
|
||||
throw new Error(`Intercom ${operation} failed: ${errorMessage}`)
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildIntercomUrl, handleIntercomError } from './types'
|
||||
|
||||
const logger = createLogger('IntercomUpdateContact')
|
||||
|
||||
export interface IntercomUpdateContactParams {
|
||||
accessToken: string
|
||||
contactId: string
|
||||
email?: string
|
||||
phone?: string
|
||||
name?: string
|
||||
avatar?: string
|
||||
signed_up_at?: number
|
||||
last_seen_at?: number
|
||||
owner_id?: string
|
||||
unsubscribed_from_emails?: boolean
|
||||
custom_attributes?: string
|
||||
}
|
||||
|
||||
export interface IntercomUpdateContactResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
contact: any
|
||||
metadata: {
|
||||
operation: 'update_contact'
|
||||
contactId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const intercomUpdateContactTool: ToolConfig<
|
||||
IntercomUpdateContactParams,
|
||||
IntercomUpdateContactResponse
|
||||
> = {
|
||||
id: 'intercom_update_contact',
|
||||
name: 'Update Contact in Intercom',
|
||||
description: 'Update an existing contact in Intercom',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
accessToken: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Intercom API access token',
|
||||
},
|
||||
contactId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Contact ID to update',
|
||||
},
|
||||
email: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: "The contact's email address",
|
||||
},
|
||||
phone: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: "The contact's phone number",
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: "The contact's name",
|
||||
},
|
||||
avatar: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'An avatar image URL for the contact',
|
||||
},
|
||||
signed_up_at: {
|
||||
type: 'number',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'The time the user signed up as a Unix timestamp',
|
||||
},
|
||||
last_seen_at: {
|
||||
type: 'number',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'The time the user was last seen as a Unix timestamp',
|
||||
},
|
||||
owner_id: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'The id of an admin that has been assigned account ownership of the contact',
|
||||
},
|
||||
unsubscribed_from_emails: {
|
||||
type: 'boolean',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Whether the contact is unsubscribed from emails',
|
||||
},
|
||||
custom_attributes: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Custom attributes as JSON object (e.g., {"attribute_name": "value"})',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => buildIntercomUrl(`/contacts/${params.contactId}`),
|
||||
method: 'PUT',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.accessToken}`,
|
||||
'Content-Type': 'application/json',
|
||||
'Intercom-Version': '2.14',
|
||||
}),
|
||||
body: (params) => {
|
||||
const contact: any = {}
|
||||
|
||||
if (params.email) contact.email = params.email
|
||||
if (params.phone) contact.phone = params.phone
|
||||
if (params.name) contact.name = params.name
|
||||
if (params.avatar) contact.avatar = params.avatar
|
||||
if (params.signed_up_at) contact.signed_up_at = params.signed_up_at
|
||||
if (params.last_seen_at) contact.last_seen_at = params.last_seen_at
|
||||
if (params.owner_id) contact.owner_id = params.owner_id
|
||||
if (params.unsubscribed_from_emails !== undefined)
|
||||
contact.unsubscribed_from_emails = params.unsubscribed_from_emails
|
||||
|
||||
if (params.custom_attributes) {
|
||||
try {
|
||||
contact.custom_attributes = JSON.parse(params.custom_attributes)
|
||||
} catch (error) {
|
||||
logger.warn('Failed to parse custom attributes', { error })
|
||||
}
|
||||
}
|
||||
|
||||
return contact
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleIntercomError(data, response.status, 'update_contact')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
contact: data,
|
||||
metadata: {
|
||||
operation: 'update_contact' as const,
|
||||
contactId: data.id,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Updated contact data',
|
||||
properties: {
|
||||
contact: { type: 'object', description: 'Updated contact object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpAddMember')
|
||||
|
||||
export interface MailchimpAddMemberParams {
|
||||
apiKey: string
|
||||
listId: string
|
||||
emailAddress: string
|
||||
status: string
|
||||
mergeFields?: string
|
||||
interests?: string
|
||||
}
|
||||
|
||||
export interface MailchimpAddMemberResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
member: any
|
||||
metadata: {
|
||||
operation: 'add_member'
|
||||
subscriberHash: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpAddMemberTool: ToolConfig<
|
||||
MailchimpAddMemberParams,
|
||||
MailchimpAddMemberResponse
|
||||
> = {
|
||||
id: 'mailchimp_add_member',
|
||||
name: 'Add Member to Mailchimp Audience',
|
||||
description: 'Add a new member to a Mailchimp audience',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
listId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the list',
|
||||
},
|
||||
emailAddress: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Member email address',
|
||||
},
|
||||
status: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Subscriber status',
|
||||
},
|
||||
mergeFields: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'JSON object of merge fields',
|
||||
},
|
||||
interests: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'JSON object of interests',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/members`),
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
body: (params) => {
|
||||
const body: any = {
|
||||
email_address: params.emailAddress,
|
||||
status: params.status,
|
||||
}
|
||||
|
||||
if (params.mergeFields) {
|
||||
try {
|
||||
body.merge_fields = JSON.parse(params.mergeFields)
|
||||
} catch (error) {
|
||||
logger.warn('Failed to parse merge fields', { error })
|
||||
}
|
||||
}
|
||||
|
||||
if (params.interests) {
|
||||
try {
|
||||
body.interests = JSON.parse(params.interests)
|
||||
} catch (error) {
|
||||
logger.warn('Failed to parse interests', { error })
|
||||
}
|
||||
}
|
||||
|
||||
return body
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'add_member')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
member: data,
|
||||
metadata: {
|
||||
operation: 'add_member' as const,
|
||||
subscriberHash: data.id,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Added member data',
|
||||
properties: {
|
||||
member: { type: 'object', description: 'Added member object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpAddMemberTags')
|
||||
|
||||
export interface MailchimpAddMemberTagsParams {
|
||||
apiKey: string
|
||||
listId: string
|
||||
subscriberEmail: string
|
||||
tags: string
|
||||
}
|
||||
|
||||
export interface MailchimpAddMemberTagsResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'add_member_tags'
|
||||
subscriberHash: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpAddMemberTagsTool: ToolConfig<
|
||||
MailchimpAddMemberTagsParams,
|
||||
MailchimpAddMemberTagsResponse
|
||||
> = {
|
||||
id: 'mailchimp_add_member_tags',
|
||||
name: 'Add Tags to Member in Mailchimp',
|
||||
description: 'Add tags to a member in a Mailchimp audience',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
listId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the list',
|
||||
},
|
||||
subscriberEmail: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Member email address or MD5 hash',
|
||||
},
|
||||
tags: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'JSON array of tags',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) =>
|
||||
buildMailchimpUrl(
|
||||
params.apiKey,
|
||||
`/lists/${params.listId}/members/${params.subscriberEmail}/tags`
|
||||
),
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
body: (params) => {
|
||||
let tags = []
|
||||
try {
|
||||
tags = JSON.parse(params.tags)
|
||||
} catch (error) {
|
||||
logger.warn('Failed to parse tags', { error })
|
||||
}
|
||||
|
||||
return { tags }
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'add_member_tags')
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'add_member_tags' as const,
|
||||
subscriberHash: '',
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Tag addition confirmation',
|
||||
properties: {
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpAddOrUpdateMember')
|
||||
|
||||
export interface MailchimpAddOrUpdateMemberParams {
|
||||
apiKey: string
|
||||
listId: string
|
||||
subscriberEmail: string
|
||||
emailAddress: string
|
||||
statusIfNew: string
|
||||
mergeFields?: string
|
||||
interests?: string
|
||||
}
|
||||
|
||||
export interface MailchimpAddOrUpdateMemberResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
member: any
|
||||
metadata: {
|
||||
operation: 'add_or_update_member'
|
||||
subscriberHash: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpAddOrUpdateMemberTool: ToolConfig<
|
||||
MailchimpAddOrUpdateMemberParams,
|
||||
MailchimpAddOrUpdateMemberResponse
|
||||
> = {
|
||||
id: 'mailchimp_add_or_update_member',
|
||||
name: 'Add or Update Member in Mailchimp Audience',
|
||||
description: 'Add a new member or update an existing member in a Mailchimp audience (upsert)',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
listId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the list',
|
||||
},
|
||||
subscriberEmail: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Member email address or MD5 hash',
|
||||
},
|
||||
emailAddress: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Member email address',
|
||||
},
|
||||
statusIfNew: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Subscriber status if new member',
|
||||
},
|
||||
mergeFields: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'JSON object of merge fields',
|
||||
},
|
||||
interests: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'JSON object of interests',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) =>
|
||||
buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/members/${params.subscriberEmail}`),
|
||||
method: 'PUT',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
body: (params) => {
|
||||
const body: any = {
|
||||
email_address: params.emailAddress,
|
||||
status_if_new: params.statusIfNew,
|
||||
}
|
||||
|
||||
if (params.mergeFields) {
|
||||
try {
|
||||
body.merge_fields = JSON.parse(params.mergeFields)
|
||||
} catch (error) {
|
||||
logger.warn('Failed to parse merge fields', { error })
|
||||
}
|
||||
}
|
||||
|
||||
if (params.interests) {
|
||||
try {
|
||||
body.interests = JSON.parse(params.interests)
|
||||
} catch (error) {
|
||||
logger.warn('Failed to parse interests', { error })
|
||||
}
|
||||
}
|
||||
|
||||
return body
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'add_or_update_member')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
member: data,
|
||||
metadata: {
|
||||
operation: 'add_or_update_member' as const,
|
||||
subscriberHash: data.id,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Member data',
|
||||
properties: {
|
||||
member: { type: 'object', description: 'Member object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpAddSegmentMember')
|
||||
|
||||
export interface MailchimpAddSegmentMemberParams {
|
||||
apiKey: string
|
||||
listId: string
|
||||
segmentId: string
|
||||
emailAddress: string
|
||||
}
|
||||
|
||||
export interface MailchimpAddSegmentMemberResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
member: any
|
||||
metadata: {
|
||||
operation: 'add_segment_member'
|
||||
segmentId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpAddSegmentMemberTool: ToolConfig<
|
||||
MailchimpAddSegmentMemberParams,
|
||||
MailchimpAddSegmentMemberResponse
|
||||
> = {
|
||||
id: 'mailchimp_add_segment_member',
|
||||
name: 'Add Member to Segment in Mailchimp',
|
||||
description: 'Add a member to a specific segment in a Mailchimp audience',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
listId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the list',
|
||||
},
|
||||
segmentId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the segment',
|
||||
},
|
||||
emailAddress: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Email address of the member',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) =>
|
||||
buildMailchimpUrl(
|
||||
params.apiKey,
|
||||
`/lists/${params.listId}/segments/${params.segmentId}/members`
|
||||
),
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
body: (params) => ({
|
||||
email_address: params.emailAddress,
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'add_segment_member')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
member: data,
|
||||
metadata: {
|
||||
operation: 'add_segment_member' as const,
|
||||
segmentId: '',
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Added member data',
|
||||
properties: {
|
||||
member: { type: 'object', description: 'Added member object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpAddSubscriberToAutomation')
|
||||
|
||||
export interface MailchimpAddSubscriberToAutomationParams {
|
||||
apiKey: string
|
||||
workflowId: string
|
||||
workflowEmailId: string
|
||||
emailAddress: string
|
||||
}
|
||||
|
||||
export interface MailchimpAddSubscriberToAutomationResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
subscriber: any
|
||||
metadata: {
|
||||
operation: 'add_subscriber_to_automation'
|
||||
workflowId: string
|
||||
workflowEmailId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpAddSubscriberToAutomationTool: ToolConfig<
|
||||
MailchimpAddSubscriberToAutomationParams,
|
||||
MailchimpAddSubscriberToAutomationResponse
|
||||
> = {
|
||||
id: 'mailchimp_add_subscriber_to_automation',
|
||||
name: 'Add Subscriber to Automation in Mailchimp',
|
||||
description: 'Manually add a subscriber to a workflow email queue',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
workflowId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the automation workflow',
|
||||
},
|
||||
workflowEmailId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the workflow email',
|
||||
},
|
||||
emailAddress: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Email address of the subscriber',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) =>
|
||||
buildMailchimpUrl(
|
||||
params.apiKey,
|
||||
`/automations/${params.workflowId}/emails/${params.workflowEmailId}/queue`
|
||||
),
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
body: (params) => ({
|
||||
email_address: params.emailAddress,
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'add_subscriber_to_automation')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
subscriber: data,
|
||||
metadata: {
|
||||
operation: 'add_subscriber_to_automation' as const,
|
||||
workflowId: '',
|
||||
workflowEmailId: '',
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Subscriber queue data',
|
||||
properties: {
|
||||
subscriber: { type: 'object', description: 'Subscriber object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpArchiveMember')
|
||||
|
||||
export interface MailchimpArchiveMemberParams {
|
||||
apiKey: string
|
||||
listId: string
|
||||
subscriberEmail: string
|
||||
}
|
||||
|
||||
export interface MailchimpArchiveMemberResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'archive_member'
|
||||
subscriberHash: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpArchiveMemberTool: ToolConfig<
|
||||
MailchimpArchiveMemberParams,
|
||||
MailchimpArchiveMemberResponse
|
||||
> = {
|
||||
id: 'mailchimp_archive_member',
|
||||
name: 'Archive Member from Mailchimp Audience',
|
||||
description: 'Permanently archive (delete) a member from a Mailchimp audience',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
listId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the list',
|
||||
},
|
||||
subscriberEmail: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Member email address or MD5 hash',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) =>
|
||||
buildMailchimpUrl(
|
||||
params.apiKey,
|
||||
`/lists/${params.listId}/members/${params.subscriberEmail}/actions/delete-permanent`
|
||||
),
|
||||
method: 'DELETE',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'archive_member')
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'archive_member' as const,
|
||||
subscriberHash: '',
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Archive confirmation',
|
||||
properties: {
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpCreateAudience')
|
||||
|
||||
export interface MailchimpCreateAudienceParams {
|
||||
apiKey: string
|
||||
audienceName: string
|
||||
contact: string
|
||||
permissionReminder: string
|
||||
campaignDefaults: string
|
||||
emailTypeOption: string
|
||||
}
|
||||
|
||||
export interface MailchimpCreateAudienceResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
list: any
|
||||
metadata: {
|
||||
operation: 'create_audience'
|
||||
listId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpCreateAudienceTool: ToolConfig<
|
||||
MailchimpCreateAudienceParams,
|
||||
MailchimpCreateAudienceResponse
|
||||
> = {
|
||||
id: 'mailchimp_create_audience',
|
||||
name: 'Create Audience in Mailchimp',
|
||||
description: 'Create a new audience (list) in Mailchimp',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
audienceName: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The name of the list',
|
||||
},
|
||||
contact: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'JSON object of contact information',
|
||||
},
|
||||
permissionReminder: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Permission reminder text',
|
||||
},
|
||||
campaignDefaults: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'JSON object of default campaign settings',
|
||||
},
|
||||
emailTypeOption: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Support multiple email formats',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => buildMailchimpUrl(params.apiKey, '/lists'),
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
body: (params) => {
|
||||
const body: any = {
|
||||
name: params.audienceName,
|
||||
permission_reminder: params.permissionReminder,
|
||||
email_type_option: params.emailTypeOption === 'true',
|
||||
}
|
||||
|
||||
if (params.contact) {
|
||||
try {
|
||||
body.contact = JSON.parse(params.contact)
|
||||
} catch (error) {
|
||||
logger.warn('Failed to parse contact', { error })
|
||||
}
|
||||
}
|
||||
|
||||
if (params.campaignDefaults) {
|
||||
try {
|
||||
body.campaign_defaults = JSON.parse(params.campaignDefaults)
|
||||
} catch (error) {
|
||||
logger.warn('Failed to parse campaign defaults', { error })
|
||||
}
|
||||
}
|
||||
|
||||
return body
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'create_audience')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
list: data,
|
||||
metadata: {
|
||||
operation: 'create_audience' as const,
|
||||
listId: data.id,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Created audience data',
|
||||
properties: {
|
||||
list: { type: 'object', description: 'Created audience/list object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpCreateBatchOperation')
|
||||
|
||||
export interface MailchimpCreateBatchOperationParams {
|
||||
apiKey: string
|
||||
operations: string
|
||||
}
|
||||
|
||||
export interface MailchimpCreateBatchOperationResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
batch: any
|
||||
metadata: {
|
||||
operation: 'create_batch_operation'
|
||||
batchId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpCreateBatchOperationTool: ToolConfig<
|
||||
MailchimpCreateBatchOperationParams,
|
||||
MailchimpCreateBatchOperationResponse
|
||||
> = {
|
||||
id: 'mailchimp_create_batch_operation',
|
||||
name: 'Create Batch Operation in Mailchimp',
|
||||
description: 'Create a new batch operation in Mailchimp',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
operations: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'JSON array of operations',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => buildMailchimpUrl(params.apiKey, '/batches'),
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
body: (params) => {
|
||||
let operations = []
|
||||
try {
|
||||
operations = JSON.parse(params.operations)
|
||||
} catch (error) {
|
||||
logger.warn('Failed to parse operations', { error })
|
||||
}
|
||||
|
||||
return { operations }
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'create_batch_operation')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
batch: data,
|
||||
metadata: {
|
||||
operation: 'create_batch_operation' as const,
|
||||
batchId: data.id,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Created batch operation data',
|
||||
properties: {
|
||||
batch: { type: 'object', description: 'Created batch operation object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpCreateCampaign')
|
||||
|
||||
export interface MailchimpCreateCampaignParams {
|
||||
apiKey: string
|
||||
campaignType: string
|
||||
campaignSettings: string
|
||||
recipients?: string
|
||||
}
|
||||
|
||||
export interface MailchimpCreateCampaignResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
campaign: any
|
||||
metadata: {
|
||||
operation: 'create_campaign'
|
||||
campaignId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpCreateCampaignTool: ToolConfig<
|
||||
MailchimpCreateCampaignParams,
|
||||
MailchimpCreateCampaignResponse
|
||||
> = {
|
||||
id: 'mailchimp_create_campaign',
|
||||
name: 'Create Campaign in Mailchimp',
|
||||
description: 'Create a new campaign in Mailchimp',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
campaignType: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Campaign type',
|
||||
},
|
||||
campaignSettings: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'JSON object of campaign settings',
|
||||
},
|
||||
recipients: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'JSON object of recipients',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => buildMailchimpUrl(params.apiKey, '/campaigns'),
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
body: (params) => {
|
||||
const body: any = {
|
||||
type: params.campaignType,
|
||||
}
|
||||
|
||||
if (params.campaignSettings) {
|
||||
try {
|
||||
body.settings = JSON.parse(params.campaignSettings)
|
||||
} catch (error) {
|
||||
logger.warn('Failed to parse campaign settings', { error })
|
||||
}
|
||||
}
|
||||
|
||||
if (params.recipients) {
|
||||
try {
|
||||
body.recipients = JSON.parse(params.recipients)
|
||||
} catch (error) {
|
||||
logger.warn('Failed to parse recipients', { error })
|
||||
}
|
||||
}
|
||||
|
||||
return body
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'create_campaign')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
campaign: data,
|
||||
metadata: {
|
||||
operation: 'create_campaign' as const,
|
||||
campaignId: data.id,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Created campaign data',
|
||||
properties: {
|
||||
campaign: { type: 'object', description: 'Created campaign object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpCreateInterest')
|
||||
|
||||
export interface MailchimpCreateInterestParams {
|
||||
apiKey: string
|
||||
listId: string
|
||||
interestCategoryId: string
|
||||
interestName: string
|
||||
}
|
||||
|
||||
export interface MailchimpCreateInterestResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
interest: any
|
||||
metadata: {
|
||||
operation: 'create_interest'
|
||||
interestId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpCreateInterestTool: ToolConfig<
|
||||
MailchimpCreateInterestParams,
|
||||
MailchimpCreateInterestResponse
|
||||
> = {
|
||||
id: 'mailchimp_create_interest',
|
||||
name: 'Create Interest in Mailchimp Interest Category',
|
||||
description: 'Create a new interest in an interest category in a Mailchimp audience',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
listId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the list',
|
||||
},
|
||||
interestCategoryId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the interest category',
|
||||
},
|
||||
interestName: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The name of the interest',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) =>
|
||||
buildMailchimpUrl(
|
||||
params.apiKey,
|
||||
`/lists/${params.listId}/interest-categories/${params.interestCategoryId}/interests`
|
||||
),
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
body: (params) => ({
|
||||
name: params.interestName,
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'create_interest')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
interest: data,
|
||||
metadata: {
|
||||
operation: 'create_interest' as const,
|
||||
interestId: data.id,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Created interest data',
|
||||
properties: {
|
||||
interest: { type: 'object', description: 'Created interest object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpCreateInterestCategory')
|
||||
|
||||
export interface MailchimpCreateInterestCategoryParams {
|
||||
apiKey: string
|
||||
listId: string
|
||||
interestCategoryTitle: string
|
||||
interestCategoryType: string
|
||||
}
|
||||
|
||||
export interface MailchimpCreateInterestCategoryResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
category: any
|
||||
metadata: {
|
||||
operation: 'create_interest_category'
|
||||
interestCategoryId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpCreateInterestCategoryTool: ToolConfig<
|
||||
MailchimpCreateInterestCategoryParams,
|
||||
MailchimpCreateInterestCategoryResponse
|
||||
> = {
|
||||
id: 'mailchimp_create_interest_category',
|
||||
name: 'Create Interest Category in Mailchimp Audience',
|
||||
description: 'Create a new interest category in a Mailchimp audience',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
listId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the list',
|
||||
},
|
||||
interestCategoryTitle: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The title of the interest category',
|
||||
},
|
||||
interestCategoryType: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The type of interest category (checkboxes, dropdown, radio, hidden)',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) =>
|
||||
buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/interest-categories`),
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
body: (params) => ({
|
||||
title: params.interestCategoryTitle,
|
||||
type: params.interestCategoryType,
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'create_interest_category')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
category: data,
|
||||
metadata: {
|
||||
operation: 'create_interest_category' as const,
|
||||
interestCategoryId: data.id,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Created interest category data',
|
||||
properties: {
|
||||
category: { type: 'object', description: 'Created interest category object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpCreateLandingPage')
|
||||
|
||||
export interface MailchimpCreateLandingPageParams {
|
||||
apiKey: string
|
||||
landingPageType: string
|
||||
landingPageTitle?: string
|
||||
}
|
||||
|
||||
export interface MailchimpCreateLandingPageResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
landingPage: any
|
||||
metadata: {
|
||||
operation: 'create_landing_page'
|
||||
pageId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpCreateLandingPageTool: ToolConfig<
|
||||
MailchimpCreateLandingPageParams,
|
||||
MailchimpCreateLandingPageResponse
|
||||
> = {
|
||||
id: 'mailchimp_create_landing_page',
|
||||
name: 'Create Landing Page in Mailchimp',
|
||||
description: 'Create a new landing page in Mailchimp',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
landingPageType: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The type of landing page (signup)',
|
||||
},
|
||||
landingPageTitle: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'The title of the landing page',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => buildMailchimpUrl(params.apiKey, '/landing-pages'),
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
body: (params) => {
|
||||
const body: any = {
|
||||
type: params.landingPageType,
|
||||
}
|
||||
|
||||
if (params.landingPageTitle) body.title = params.landingPageTitle
|
||||
|
||||
return body
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'create_landing_page')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
landingPage: data,
|
||||
metadata: {
|
||||
operation: 'create_landing_page' as const,
|
||||
pageId: data.id,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Created landing page data',
|
||||
properties: {
|
||||
landingPage: { type: 'object', description: 'Created landing page object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpCreateMergeField')
|
||||
|
||||
export interface MailchimpCreateMergeFieldParams {
|
||||
apiKey: string
|
||||
listId: string
|
||||
mergeName: string
|
||||
mergeType: string
|
||||
}
|
||||
|
||||
export interface MailchimpCreateMergeFieldResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
mergeField: any
|
||||
metadata: {
|
||||
operation: 'create_merge_field'
|
||||
mergeId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpCreateMergeFieldTool: ToolConfig<
|
||||
MailchimpCreateMergeFieldParams,
|
||||
MailchimpCreateMergeFieldResponse
|
||||
> = {
|
||||
id: 'mailchimp_create_merge_field',
|
||||
name: 'Create Merge Field in Mailchimp Audience',
|
||||
description: 'Create a new merge field in a Mailchimp audience',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
listId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the list',
|
||||
},
|
||||
mergeName: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The name of the merge field',
|
||||
},
|
||||
mergeType: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description:
|
||||
'The type of the merge field (text, number, address, phone, date, url, imageurl, radio, dropdown, birthday, zip)',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/merge-fields`),
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
body: (params) => ({
|
||||
name: params.mergeName,
|
||||
type: params.mergeType,
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'create_merge_field')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
mergeField: data,
|
||||
metadata: {
|
||||
operation: 'create_merge_field' as const,
|
||||
mergeId: data.merge_id,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Created merge field data',
|
||||
properties: {
|
||||
mergeField: { type: 'object', description: 'Created merge field object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpCreateSegment')
|
||||
|
||||
export interface MailchimpCreateSegmentParams {
|
||||
apiKey: string
|
||||
listId: string
|
||||
segmentName: string
|
||||
segmentOptions?: string
|
||||
}
|
||||
|
||||
export interface MailchimpCreateSegmentResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
segment: any
|
||||
metadata: {
|
||||
operation: 'create_segment'
|
||||
segmentId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpCreateSegmentTool: ToolConfig<
|
||||
MailchimpCreateSegmentParams,
|
||||
MailchimpCreateSegmentResponse
|
||||
> = {
|
||||
id: 'mailchimp_create_segment',
|
||||
name: 'Create Segment in Mailchimp Audience',
|
||||
description: 'Create a new segment in a Mailchimp audience',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
listId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the list',
|
||||
},
|
||||
segmentName: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The name of the segment',
|
||||
},
|
||||
segmentOptions: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'JSON object of segment options',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/segments`),
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
body: (params) => {
|
||||
const body: any = {
|
||||
name: params.segmentName,
|
||||
}
|
||||
|
||||
if (params.segmentOptions) {
|
||||
try {
|
||||
const options = JSON.parse(params.segmentOptions)
|
||||
body.options = options
|
||||
} catch (error) {
|
||||
logger.warn('Failed to parse segment options', { error })
|
||||
}
|
||||
}
|
||||
|
||||
return body
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'create_segment')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
segment: data,
|
||||
metadata: {
|
||||
operation: 'create_segment' as const,
|
||||
segmentId: data.id,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Created segment data',
|
||||
properties: {
|
||||
segment: { type: 'object', description: 'Created segment object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpCreateTemplate')
|
||||
|
||||
export interface MailchimpCreateTemplateParams {
|
||||
apiKey: string
|
||||
templateName: string
|
||||
templateHtml: string
|
||||
}
|
||||
|
||||
export interface MailchimpCreateTemplateResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
template: any
|
||||
metadata: {
|
||||
operation: 'create_template'
|
||||
templateId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpCreateTemplateTool: ToolConfig<
|
||||
MailchimpCreateTemplateParams,
|
||||
MailchimpCreateTemplateResponse
|
||||
> = {
|
||||
id: 'mailchimp_create_template',
|
||||
name: 'Create Template in Mailchimp',
|
||||
description: 'Create a new template in Mailchimp',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
templateName: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The name of the template',
|
||||
},
|
||||
templateHtml: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The HTML content for the template',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => buildMailchimpUrl(params.apiKey, '/templates'),
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
body: (params) => ({
|
||||
name: params.templateName,
|
||||
html: params.templateHtml,
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'create_template')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
template: data,
|
||||
metadata: {
|
||||
operation: 'create_template' as const,
|
||||
templateId: data.id,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Created template data',
|
||||
properties: {
|
||||
template: { type: 'object', description: 'Created template object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpDeleteAudience')
|
||||
|
||||
export interface MailchimpDeleteAudienceParams {
|
||||
apiKey: string
|
||||
listId: string
|
||||
}
|
||||
|
||||
export interface MailchimpDeleteAudienceResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'delete_audience'
|
||||
listId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpDeleteAudienceTool: ToolConfig<
|
||||
MailchimpDeleteAudienceParams,
|
||||
MailchimpDeleteAudienceResponse
|
||||
> = {
|
||||
id: 'mailchimp_delete_audience',
|
||||
name: 'Delete Audience from Mailchimp',
|
||||
description: 'Delete an audience (list) from Mailchimp',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
listId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the list to delete',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => buildMailchimpUrl(params.apiKey, `/lists/${params.listId}`),
|
||||
method: 'DELETE',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'delete_audience')
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'delete_audience' as const,
|
||||
listId: '',
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Deletion confirmation',
|
||||
properties: {
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpDeleteBatchOperation')
|
||||
|
||||
export interface MailchimpDeleteBatchOperationParams {
|
||||
apiKey: string
|
||||
batchId: string
|
||||
}
|
||||
|
||||
export interface MailchimpDeleteBatchOperationResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'delete_batch_operation'
|
||||
batchId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpDeleteBatchOperationTool: ToolConfig<
|
||||
MailchimpDeleteBatchOperationParams,
|
||||
MailchimpDeleteBatchOperationResponse
|
||||
> = {
|
||||
id: 'mailchimp_delete_batch_operation',
|
||||
name: 'Delete Batch Operation from Mailchimp',
|
||||
description: 'Delete a batch operation from Mailchimp',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
batchId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the batch operation to delete',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => buildMailchimpUrl(params.apiKey, `/batches/${params.batchId}`),
|
||||
method: 'DELETE',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'delete_batch_operation')
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'delete_batch_operation' as const,
|
||||
batchId: '',
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Deletion confirmation',
|
||||
properties: {
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpDeleteCampaign')
|
||||
|
||||
export interface MailchimpDeleteCampaignParams {
|
||||
apiKey: string
|
||||
campaignId: string
|
||||
}
|
||||
|
||||
export interface MailchimpDeleteCampaignResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'delete_campaign'
|
||||
campaignId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpDeleteCampaignTool: ToolConfig<
|
||||
MailchimpDeleteCampaignParams,
|
||||
MailchimpDeleteCampaignResponse
|
||||
> = {
|
||||
id: 'mailchimp_delete_campaign',
|
||||
name: 'Delete Campaign from Mailchimp',
|
||||
description: 'Delete a campaign from Mailchimp',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
campaignId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the campaign to delete',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => buildMailchimpUrl(params.apiKey, `/campaigns/${params.campaignId}`),
|
||||
method: 'DELETE',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'delete_campaign')
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'delete_campaign' as const,
|
||||
campaignId: '',
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Deletion confirmation',
|
||||
properties: {
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpDeleteInterest')
|
||||
|
||||
export interface MailchimpDeleteInterestParams {
|
||||
apiKey: string
|
||||
listId: string
|
||||
interestCategoryId: string
|
||||
interestId: string
|
||||
}
|
||||
|
||||
export interface MailchimpDeleteInterestResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'delete_interest'
|
||||
interestId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpDeleteInterestTool: ToolConfig<
|
||||
MailchimpDeleteInterestParams,
|
||||
MailchimpDeleteInterestResponse
|
||||
> = {
|
||||
id: 'mailchimp_delete_interest',
|
||||
name: 'Delete Interest from Mailchimp Interest Category',
|
||||
description: 'Delete an interest from an interest category in a Mailchimp audience',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
listId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the list',
|
||||
},
|
||||
interestCategoryId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the interest category',
|
||||
},
|
||||
interestId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the interest to delete',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) =>
|
||||
buildMailchimpUrl(
|
||||
params.apiKey,
|
||||
`/lists/${params.listId}/interest-categories/${params.interestCategoryId}/interests/${params.interestId}`
|
||||
),
|
||||
method: 'DELETE',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'delete_interest')
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'delete_interest' as const,
|
||||
interestId: '',
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Deletion confirmation',
|
||||
properties: {
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpDeleteInterestCategory')
|
||||
|
||||
export interface MailchimpDeleteInterestCategoryParams {
|
||||
apiKey: string
|
||||
listId: string
|
||||
interestCategoryId: string
|
||||
}
|
||||
|
||||
export interface MailchimpDeleteInterestCategoryResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'delete_interest_category'
|
||||
interestCategoryId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpDeleteInterestCategoryTool: ToolConfig<
|
||||
MailchimpDeleteInterestCategoryParams,
|
||||
MailchimpDeleteInterestCategoryResponse
|
||||
> = {
|
||||
id: 'mailchimp_delete_interest_category',
|
||||
name: 'Delete Interest Category from Mailchimp Audience',
|
||||
description: 'Delete an interest category from a Mailchimp audience',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
listId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the list',
|
||||
},
|
||||
interestCategoryId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the interest category to delete',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) =>
|
||||
buildMailchimpUrl(
|
||||
params.apiKey,
|
||||
`/lists/${params.listId}/interest-categories/${params.interestCategoryId}`
|
||||
),
|
||||
method: 'DELETE',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'delete_interest_category')
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'delete_interest_category' as const,
|
||||
interestCategoryId: '',
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Deletion confirmation',
|
||||
properties: {
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpDeleteLandingPage')
|
||||
|
||||
export interface MailchimpDeleteLandingPageParams {
|
||||
apiKey: string
|
||||
pageId: string
|
||||
}
|
||||
|
||||
export interface MailchimpDeleteLandingPageResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'delete_landing_page'
|
||||
pageId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpDeleteLandingPageTool: ToolConfig<
|
||||
MailchimpDeleteLandingPageParams,
|
||||
MailchimpDeleteLandingPageResponse
|
||||
> = {
|
||||
id: 'mailchimp_delete_landing_page',
|
||||
name: 'Delete Landing Page from Mailchimp',
|
||||
description: 'Delete a landing page from Mailchimp',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
pageId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the landing page to delete',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => buildMailchimpUrl(params.apiKey, `/landing-pages/${params.pageId}`),
|
||||
method: 'DELETE',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'delete_landing_page')
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'delete_landing_page' as const,
|
||||
pageId: '',
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Deletion confirmation',
|
||||
properties: {
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpDeleteMember')
|
||||
|
||||
export interface MailchimpDeleteMemberParams {
|
||||
apiKey: string
|
||||
listId: string
|
||||
subscriberEmail: string
|
||||
}
|
||||
|
||||
export interface MailchimpDeleteMemberResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'delete_member'
|
||||
subscriberHash: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpDeleteMemberTool: ToolConfig<
|
||||
MailchimpDeleteMemberParams,
|
||||
MailchimpDeleteMemberResponse
|
||||
> = {
|
||||
id: 'mailchimp_delete_member',
|
||||
name: 'Delete Member from Mailchimp Audience',
|
||||
description: 'Delete a member from a Mailchimp audience',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
listId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the list',
|
||||
},
|
||||
subscriberEmail: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Member email address or MD5 hash',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) =>
|
||||
buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/members/${params.subscriberEmail}`),
|
||||
method: 'DELETE',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'delete_member')
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'delete_member' as const,
|
||||
subscriberHash: '',
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Deletion confirmation',
|
||||
properties: {
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpDeleteMergeField')
|
||||
|
||||
export interface MailchimpDeleteMergeFieldParams {
|
||||
apiKey: string
|
||||
listId: string
|
||||
mergeId: string
|
||||
}
|
||||
|
||||
export interface MailchimpDeleteMergeFieldResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'delete_merge_field'
|
||||
mergeId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpDeleteMergeFieldTool: ToolConfig<
|
||||
MailchimpDeleteMergeFieldParams,
|
||||
MailchimpDeleteMergeFieldResponse
|
||||
> = {
|
||||
id: 'mailchimp_delete_merge_field',
|
||||
name: 'Delete Merge Field from Mailchimp Audience',
|
||||
description: 'Delete a merge field from a Mailchimp audience',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
listId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the list',
|
||||
},
|
||||
mergeId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the merge field to delete',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) =>
|
||||
buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/merge-fields/${params.mergeId}`),
|
||||
method: 'DELETE',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'delete_merge_field')
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'delete_merge_field' as const,
|
||||
mergeId: '',
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Deletion confirmation',
|
||||
properties: {
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpDeleteSegment')
|
||||
|
||||
export interface MailchimpDeleteSegmentParams {
|
||||
apiKey: string
|
||||
listId: string
|
||||
segmentId: string
|
||||
}
|
||||
|
||||
export interface MailchimpDeleteSegmentResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'delete_segment'
|
||||
segmentId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpDeleteSegmentTool: ToolConfig<
|
||||
MailchimpDeleteSegmentParams,
|
||||
MailchimpDeleteSegmentResponse
|
||||
> = {
|
||||
id: 'mailchimp_delete_segment',
|
||||
name: 'Delete Segment from Mailchimp Audience',
|
||||
description: 'Delete a segment from a Mailchimp audience',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
listId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the list',
|
||||
},
|
||||
segmentId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the segment to delete',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) =>
|
||||
buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/segments/${params.segmentId}`),
|
||||
method: 'DELETE',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'delete_segment')
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'delete_segment' as const,
|
||||
segmentId: '',
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Deletion confirmation',
|
||||
properties: {
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpDeleteTemplate')
|
||||
|
||||
export interface MailchimpDeleteTemplateParams {
|
||||
apiKey: string
|
||||
templateId: string
|
||||
}
|
||||
|
||||
export interface MailchimpDeleteTemplateResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'delete_template'
|
||||
templateId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpDeleteTemplateTool: ToolConfig<
|
||||
MailchimpDeleteTemplateParams,
|
||||
MailchimpDeleteTemplateResponse
|
||||
> = {
|
||||
id: 'mailchimp_delete_template',
|
||||
name: 'Delete Template from Mailchimp',
|
||||
description: 'Delete a template from Mailchimp',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
templateId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the template to delete',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => buildMailchimpUrl(params.apiKey, `/templates/${params.templateId}`),
|
||||
method: 'DELETE',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'delete_template')
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'delete_template' as const,
|
||||
templateId: '',
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Deletion confirmation',
|
||||
properties: {
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpGetAudience')
|
||||
|
||||
export interface MailchimpGetAudienceParams {
|
||||
apiKey: string
|
||||
listId: string
|
||||
}
|
||||
|
||||
export interface MailchimpGetAudienceResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
list: any
|
||||
metadata: {
|
||||
operation: 'get_audience'
|
||||
listId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpGetAudienceTool: ToolConfig<
|
||||
MailchimpGetAudienceParams,
|
||||
MailchimpGetAudienceResponse
|
||||
> = {
|
||||
id: 'mailchimp_get_audience',
|
||||
name: 'Get Audience from Mailchimp',
|
||||
description: 'Retrieve details of a specific audience (list) from Mailchimp',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
listId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the list',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => buildMailchimpUrl(params.apiKey, `/lists/${params.listId}`),
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'get_audience')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
list: data,
|
||||
metadata: {
|
||||
operation: 'get_audience' as const,
|
||||
listId: data.id,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Audience data and metadata',
|
||||
properties: {
|
||||
list: { type: 'object', description: 'Audience/list object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpGetAudiences')
|
||||
|
||||
export interface MailchimpGetAudiencesParams {
|
||||
apiKey: string
|
||||
count?: string
|
||||
offset?: string
|
||||
}
|
||||
|
||||
export interface MailchimpGetAudiencesResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
lists: any[]
|
||||
totalItems: number
|
||||
metadata: {
|
||||
operation: 'get_audiences'
|
||||
totalReturned: number
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpGetAudiencesTool: ToolConfig<
|
||||
MailchimpGetAudiencesParams,
|
||||
MailchimpGetAudiencesResponse
|
||||
> = {
|
||||
id: 'mailchimp_get_audiences',
|
||||
name: 'Get Audiences from Mailchimp',
|
||||
description: 'Retrieve a list of audiences (lists) from Mailchimp',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
count: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Number of results (default: 10, max: 1000)',
|
||||
},
|
||||
offset: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Number of results to skip',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const queryParams = new URLSearchParams()
|
||||
if (params.count) queryParams.append('count', params.count)
|
||||
if (params.offset) queryParams.append('offset', params.offset)
|
||||
|
||||
const query = queryParams.toString()
|
||||
const url = buildMailchimpUrl(params.apiKey, '/lists')
|
||||
return query ? `${url}?${query}` : url
|
||||
},
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'get_audiences')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
const lists = data.lists || []
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
lists,
|
||||
totalItems: data.total_items || lists.length,
|
||||
metadata: {
|
||||
operation: 'get_audiences' as const,
|
||||
totalReturned: lists.length,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Audiences data and metadata',
|
||||
properties: {
|
||||
lists: { type: 'array', description: 'Array of audience/list objects' },
|
||||
totalItems: { type: 'number', description: 'Total number of lists' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpGetAutomation')
|
||||
|
||||
export interface MailchimpGetAutomationParams {
|
||||
apiKey: string
|
||||
workflowId: string
|
||||
}
|
||||
|
||||
export interface MailchimpGetAutomationResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
automation: any
|
||||
metadata: {
|
||||
operation: 'get_automation'
|
||||
workflowId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpGetAutomationTool: ToolConfig<
|
||||
MailchimpGetAutomationParams,
|
||||
MailchimpGetAutomationResponse
|
||||
> = {
|
||||
id: 'mailchimp_get_automation',
|
||||
name: 'Get Automation from Mailchimp',
|
||||
description: 'Retrieve details of a specific automation from Mailchimp',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
workflowId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the automation workflow',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => buildMailchimpUrl(params.apiKey, `/automations/${params.workflowId}`),
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'get_automation')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
automation: data,
|
||||
metadata: {
|
||||
operation: 'get_automation' as const,
|
||||
workflowId: data.id,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Automation data and metadata',
|
||||
properties: {
|
||||
automation: { type: 'object', description: 'Automation object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpGetAutomations')
|
||||
|
||||
export interface MailchimpGetAutomationsParams {
|
||||
apiKey: string
|
||||
count?: string
|
||||
offset?: string
|
||||
}
|
||||
|
||||
export interface MailchimpGetAutomationsResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
automations: any[]
|
||||
totalItems: number
|
||||
metadata: {
|
||||
operation: 'get_automations'
|
||||
totalReturned: number
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpGetAutomationsTool: ToolConfig<
|
||||
MailchimpGetAutomationsParams,
|
||||
MailchimpGetAutomationsResponse
|
||||
> = {
|
||||
id: 'mailchimp_get_automations',
|
||||
name: 'Get Automations from Mailchimp',
|
||||
description: 'Retrieve a list of automations from Mailchimp',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
count: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Number of results (default: 10, max: 1000)',
|
||||
},
|
||||
offset: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Number of results to skip',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const queryParams = new URLSearchParams()
|
||||
if (params.count) queryParams.append('count', params.count)
|
||||
if (params.offset) queryParams.append('offset', params.offset)
|
||||
|
||||
const query = queryParams.toString()
|
||||
const url = buildMailchimpUrl(params.apiKey, '/automations')
|
||||
return query ? `${url}?${query}` : url
|
||||
},
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'get_automations')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
const automations = data.automations || []
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
automations,
|
||||
totalItems: data.total_items || automations.length,
|
||||
metadata: {
|
||||
operation: 'get_automations' as const,
|
||||
totalReturned: automations.length,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Automations data and metadata',
|
||||
properties: {
|
||||
automations: { type: 'array', description: 'Array of automation objects' },
|
||||
totalItems: { type: 'number', description: 'Total number of automations' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpGetBatchOperation')
|
||||
|
||||
export interface MailchimpGetBatchOperationParams {
|
||||
apiKey: string
|
||||
batchId: string
|
||||
}
|
||||
|
||||
export interface MailchimpGetBatchOperationResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
batch: any
|
||||
metadata: {
|
||||
operation: 'get_batch_operation'
|
||||
batchId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpGetBatchOperationTool: ToolConfig<
|
||||
MailchimpGetBatchOperationParams,
|
||||
MailchimpGetBatchOperationResponse
|
||||
> = {
|
||||
id: 'mailchimp_get_batch_operation',
|
||||
name: 'Get Batch Operation from Mailchimp',
|
||||
description: 'Retrieve details of a specific batch operation from Mailchimp',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
batchId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the batch operation',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => buildMailchimpUrl(params.apiKey, `/batches/${params.batchId}`),
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'get_batch_operation')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
batch: data,
|
||||
metadata: {
|
||||
operation: 'get_batch_operation' as const,
|
||||
batchId: data.id,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Batch operation data and metadata',
|
||||
properties: {
|
||||
batch: { type: 'object', description: 'Batch operation object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpGetBatchOperations')
|
||||
|
||||
export interface MailchimpGetBatchOperationsParams {
|
||||
apiKey: string
|
||||
count?: string
|
||||
offset?: string
|
||||
}
|
||||
|
||||
export interface MailchimpGetBatchOperationsResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
batches: any[]
|
||||
totalItems: number
|
||||
metadata: {
|
||||
operation: 'get_batch_operations'
|
||||
totalReturned: number
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpGetBatchOperationsTool: ToolConfig<
|
||||
MailchimpGetBatchOperationsParams,
|
||||
MailchimpGetBatchOperationsResponse
|
||||
> = {
|
||||
id: 'mailchimp_get_batch_operations',
|
||||
name: 'Get Batch Operations from Mailchimp',
|
||||
description: 'Retrieve a list of batch operations from Mailchimp',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
count: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Number of results (default: 10, max: 1000)',
|
||||
},
|
||||
offset: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Number of results to skip',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const queryParams = new URLSearchParams()
|
||||
if (params.count) queryParams.append('count', params.count)
|
||||
if (params.offset) queryParams.append('offset', params.offset)
|
||||
|
||||
const query = queryParams.toString()
|
||||
const url = buildMailchimpUrl(params.apiKey, '/batches')
|
||||
return query ? `${url}?${query}` : url
|
||||
},
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'get_batch_operations')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
const batches = data.batches || []
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
batches,
|
||||
totalItems: data.total_items || batches.length,
|
||||
metadata: {
|
||||
operation: 'get_batch_operations' as const,
|
||||
totalReturned: batches.length,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Batch operations data and metadata',
|
||||
properties: {
|
||||
batches: { type: 'array', description: 'Array of batch operation objects' },
|
||||
totalItems: { type: 'number', description: 'Total number of batch operations' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpGetCampaign')
|
||||
|
||||
export interface MailchimpGetCampaignParams {
|
||||
apiKey: string
|
||||
campaignId: string
|
||||
}
|
||||
|
||||
export interface MailchimpGetCampaignResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
campaign: any
|
||||
metadata: {
|
||||
operation: 'get_campaign'
|
||||
campaignId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpGetCampaignTool: ToolConfig<
|
||||
MailchimpGetCampaignParams,
|
||||
MailchimpGetCampaignResponse
|
||||
> = {
|
||||
id: 'mailchimp_get_campaign',
|
||||
name: 'Get Campaign from Mailchimp',
|
||||
description: 'Retrieve details of a specific campaign from Mailchimp',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
campaignId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the campaign',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => buildMailchimpUrl(params.apiKey, `/campaigns/${params.campaignId}`),
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'get_campaign')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
campaign: data,
|
||||
metadata: {
|
||||
operation: 'get_campaign' as const,
|
||||
campaignId: data.id,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Campaign data and metadata',
|
||||
properties: {
|
||||
campaign: { type: 'object', description: 'Campaign object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpGetCampaignContent')
|
||||
|
||||
export interface MailchimpGetCampaignContentParams {
|
||||
apiKey: string
|
||||
campaignId: string
|
||||
}
|
||||
|
||||
export interface MailchimpGetCampaignContentResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
content: any
|
||||
metadata: {
|
||||
operation: 'get_campaign_content'
|
||||
campaignId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpGetCampaignContentTool: ToolConfig<
|
||||
MailchimpGetCampaignContentParams,
|
||||
MailchimpGetCampaignContentResponse
|
||||
> = {
|
||||
id: 'mailchimp_get_campaign_content',
|
||||
name: 'Get Campaign Content from Mailchimp',
|
||||
description: 'Retrieve the HTML and plain-text content for a Mailchimp campaign',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
campaignId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the campaign',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => buildMailchimpUrl(params.apiKey, `/campaigns/${params.campaignId}/content`),
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'get_campaign_content')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
content: data,
|
||||
metadata: {
|
||||
operation: 'get_campaign_content' as const,
|
||||
campaignId: '',
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Campaign content data',
|
||||
properties: {
|
||||
content: { type: 'object', description: 'Campaign content object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpGetCampaignReport')
|
||||
|
||||
export interface MailchimpGetCampaignReportParams {
|
||||
apiKey: string
|
||||
campaignId: string
|
||||
}
|
||||
|
||||
export interface MailchimpGetCampaignReportResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
report: any
|
||||
metadata: {
|
||||
operation: 'get_campaign_report'
|
||||
campaignId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpGetCampaignReportTool: ToolConfig<
|
||||
MailchimpGetCampaignReportParams,
|
||||
MailchimpGetCampaignReportResponse
|
||||
> = {
|
||||
id: 'mailchimp_get_campaign_report',
|
||||
name: 'Get Campaign Report from Mailchimp',
|
||||
description: 'Retrieve the report for a specific campaign from Mailchimp',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
campaignId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the campaign',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => buildMailchimpUrl(params.apiKey, `/reports/${params.campaignId}`),
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'get_campaign_report')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
report: data,
|
||||
metadata: {
|
||||
operation: 'get_campaign_report' as const,
|
||||
campaignId: data.campaign_id,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Campaign report data and metadata',
|
||||
properties: {
|
||||
report: { type: 'object', description: 'Campaign report object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpGetCampaignReports')
|
||||
|
||||
export interface MailchimpGetCampaignReportsParams {
|
||||
apiKey: string
|
||||
count?: string
|
||||
offset?: string
|
||||
}
|
||||
|
||||
export interface MailchimpGetCampaignReportsResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
reports: any[]
|
||||
totalItems: number
|
||||
metadata: {
|
||||
operation: 'get_campaign_reports'
|
||||
totalReturned: number
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpGetCampaignReportsTool: ToolConfig<
|
||||
MailchimpGetCampaignReportsParams,
|
||||
MailchimpGetCampaignReportsResponse
|
||||
> = {
|
||||
id: 'mailchimp_get_campaign_reports',
|
||||
name: 'Get Campaign Reports from Mailchimp',
|
||||
description: 'Retrieve a list of campaign reports from Mailchimp',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
count: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Number of results (default: 10, max: 1000)',
|
||||
},
|
||||
offset: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Number of results to skip',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const queryParams = new URLSearchParams()
|
||||
if (params.count) queryParams.append('count', params.count)
|
||||
if (params.offset) queryParams.append('offset', params.offset)
|
||||
|
||||
const query = queryParams.toString()
|
||||
const url = buildMailchimpUrl(params.apiKey, '/reports')
|
||||
return query ? `${url}?${query}` : url
|
||||
},
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'get_campaign_reports')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
const reports = data.reports || []
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
reports,
|
||||
totalItems: data.total_items || reports.length,
|
||||
metadata: {
|
||||
operation: 'get_campaign_reports' as const,
|
||||
totalReturned: reports.length,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Campaign reports data and metadata',
|
||||
properties: {
|
||||
reports: { type: 'array', description: 'Array of campaign report objects' },
|
||||
totalItems: { type: 'number', description: 'Total number of reports' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpGetCampaigns')
|
||||
|
||||
export interface MailchimpGetCampaignsParams {
|
||||
apiKey: string
|
||||
campaignType?: string
|
||||
status?: string
|
||||
count?: string
|
||||
offset?: string
|
||||
}
|
||||
|
||||
export interface MailchimpGetCampaignsResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
campaigns: any[]
|
||||
totalItems: number
|
||||
metadata: {
|
||||
operation: 'get_campaigns'
|
||||
totalReturned: number
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpGetCampaignsTool: ToolConfig<
|
||||
MailchimpGetCampaignsParams,
|
||||
MailchimpGetCampaignsResponse
|
||||
> = {
|
||||
id: 'mailchimp_get_campaigns',
|
||||
name: 'Get Campaigns from Mailchimp',
|
||||
description: 'Retrieve a list of campaigns from Mailchimp',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
campaignType: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Filter by campaign type (regular, plaintext, absplit, rss, variate)',
|
||||
},
|
||||
status: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Filter by status (save, paused, schedule, sending, sent)',
|
||||
},
|
||||
count: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Number of results (default: 10, max: 1000)',
|
||||
},
|
||||
offset: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Number of results to skip',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const queryParams = new URLSearchParams()
|
||||
if (params.campaignType) queryParams.append('type', params.campaignType)
|
||||
if (params.status) queryParams.append('status', params.status)
|
||||
if (params.count) queryParams.append('count', params.count)
|
||||
if (params.offset) queryParams.append('offset', params.offset)
|
||||
|
||||
const query = queryParams.toString()
|
||||
const url = buildMailchimpUrl(params.apiKey, '/campaigns')
|
||||
return query ? `${url}?${query}` : url
|
||||
},
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'get_campaigns')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
const campaigns = data.campaigns || []
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
campaigns,
|
||||
totalItems: data.total_items || campaigns.length,
|
||||
metadata: {
|
||||
operation: 'get_campaigns' as const,
|
||||
totalReturned: campaigns.length,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Campaigns data and metadata',
|
||||
properties: {
|
||||
campaigns: { type: 'array', description: 'Array of campaign objects' },
|
||||
totalItems: { type: 'number', description: 'Total number of campaigns' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpGetInterest')
|
||||
|
||||
export interface MailchimpGetInterestParams {
|
||||
apiKey: string
|
||||
listId: string
|
||||
interestCategoryId: string
|
||||
interestId: string
|
||||
}
|
||||
|
||||
export interface MailchimpGetInterestResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
interest: any
|
||||
metadata: {
|
||||
operation: 'get_interest'
|
||||
interestId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpGetInterestTool: ToolConfig<
|
||||
MailchimpGetInterestParams,
|
||||
MailchimpGetInterestResponse
|
||||
> = {
|
||||
id: 'mailchimp_get_interest',
|
||||
name: 'Get Interest from Mailchimp Interest Category',
|
||||
description:
|
||||
'Retrieve details of a specific interest from an interest category in a Mailchimp audience',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
listId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the list',
|
||||
},
|
||||
interestCategoryId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the interest category',
|
||||
},
|
||||
interestId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the interest',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) =>
|
||||
buildMailchimpUrl(
|
||||
params.apiKey,
|
||||
`/lists/${params.listId}/interest-categories/${params.interestCategoryId}/interests/${params.interestId}`
|
||||
),
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'get_interest')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
interest: data,
|
||||
metadata: {
|
||||
operation: 'get_interest' as const,
|
||||
interestId: data.id,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Interest data and metadata',
|
||||
properties: {
|
||||
interest: { type: 'object', description: 'Interest object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpGetInterestCategories')
|
||||
|
||||
export interface MailchimpGetInterestCategoriesParams {
|
||||
apiKey: string
|
||||
listId: string
|
||||
count?: string
|
||||
offset?: string
|
||||
}
|
||||
|
||||
export interface MailchimpGetInterestCategoriesResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
categories: any[]
|
||||
totalItems: number
|
||||
metadata: {
|
||||
operation: 'get_interest_categories'
|
||||
totalReturned: number
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpGetInterestCategoriesTool: ToolConfig<
|
||||
MailchimpGetInterestCategoriesParams,
|
||||
MailchimpGetInterestCategoriesResponse
|
||||
> = {
|
||||
id: 'mailchimp_get_interest_categories',
|
||||
name: 'Get Interest Categories from Mailchimp Audience',
|
||||
description: 'Retrieve a list of interest categories from a Mailchimp audience',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
listId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the list',
|
||||
},
|
||||
count: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Number of results (default: 10, max: 1000)',
|
||||
},
|
||||
offset: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Number of results to skip',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const queryParams = new URLSearchParams()
|
||||
if (params.count) queryParams.append('count', params.count)
|
||||
if (params.offset) queryParams.append('offset', params.offset)
|
||||
|
||||
const query = queryParams.toString()
|
||||
const url = buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/interest-categories`)
|
||||
return query ? `${url}?${query}` : url
|
||||
},
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'get_interest_categories')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
const categories = data.categories || []
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
categories,
|
||||
totalItems: data.total_items || categories.length,
|
||||
metadata: {
|
||||
operation: 'get_interest_categories' as const,
|
||||
totalReturned: categories.length,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Interest categories data and metadata',
|
||||
properties: {
|
||||
categories: { type: 'array', description: 'Array of interest category objects' },
|
||||
totalItems: { type: 'number', description: 'Total number of categories' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpGetInterestCategory')
|
||||
|
||||
export interface MailchimpGetInterestCategoryParams {
|
||||
apiKey: string
|
||||
listId: string
|
||||
interestCategoryId: string
|
||||
}
|
||||
|
||||
export interface MailchimpGetInterestCategoryResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
category: any
|
||||
metadata: {
|
||||
operation: 'get_interest_category'
|
||||
interestCategoryId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpGetInterestCategoryTool: ToolConfig<
|
||||
MailchimpGetInterestCategoryParams,
|
||||
MailchimpGetInterestCategoryResponse
|
||||
> = {
|
||||
id: 'mailchimp_get_interest_category',
|
||||
name: 'Get Interest Category from Mailchimp Audience',
|
||||
description: 'Retrieve details of a specific interest category from a Mailchimp audience',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
listId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the list',
|
||||
},
|
||||
interestCategoryId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the interest category',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) =>
|
||||
buildMailchimpUrl(
|
||||
params.apiKey,
|
||||
`/lists/${params.listId}/interest-categories/${params.interestCategoryId}`
|
||||
),
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'get_interest_category')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
category: data,
|
||||
metadata: {
|
||||
operation: 'get_interest_category' as const,
|
||||
interestCategoryId: data.id,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Interest category data and metadata',
|
||||
properties: {
|
||||
category: { type: 'object', description: 'Interest category object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpGetInterests')
|
||||
|
||||
export interface MailchimpGetInterestsParams {
|
||||
apiKey: string
|
||||
listId: string
|
||||
interestCategoryId: string
|
||||
count?: string
|
||||
offset?: string
|
||||
}
|
||||
|
||||
export interface MailchimpGetInterestsResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
interests: any[]
|
||||
totalItems: number
|
||||
metadata: {
|
||||
operation: 'get_interests'
|
||||
totalReturned: number
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpGetInterestsTool: ToolConfig<
|
||||
MailchimpGetInterestsParams,
|
||||
MailchimpGetInterestsResponse
|
||||
> = {
|
||||
id: 'mailchimp_get_interests',
|
||||
name: 'Get Interests from Mailchimp Interest Category',
|
||||
description: 'Retrieve a list of interests from an interest category in a Mailchimp audience',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
listId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the list',
|
||||
},
|
||||
interestCategoryId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the interest category',
|
||||
},
|
||||
count: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Number of results (default: 10, max: 1000)',
|
||||
},
|
||||
offset: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Number of results to skip',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const queryParams = new URLSearchParams()
|
||||
if (params.count) queryParams.append('count', params.count)
|
||||
if (params.offset) queryParams.append('offset', params.offset)
|
||||
|
||||
const query = queryParams.toString()
|
||||
const url = buildMailchimpUrl(
|
||||
params.apiKey,
|
||||
`/lists/${params.listId}/interest-categories/${params.interestCategoryId}/interests`
|
||||
)
|
||||
return query ? `${url}?${query}` : url
|
||||
},
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'get_interests')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
const interests = data.interests || []
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
interests,
|
||||
totalItems: data.total_items || interests.length,
|
||||
metadata: {
|
||||
operation: 'get_interests' as const,
|
||||
totalReturned: interests.length,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Interests data and metadata',
|
||||
properties: {
|
||||
interests: { type: 'array', description: 'Array of interest objects' },
|
||||
totalItems: { type: 'number', description: 'Total number of interests' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpGetLandingPage')
|
||||
|
||||
export interface MailchimpGetLandingPageParams {
|
||||
apiKey: string
|
||||
pageId: string
|
||||
}
|
||||
|
||||
export interface MailchimpGetLandingPageResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
landingPage: any
|
||||
metadata: {
|
||||
operation: 'get_landing_page'
|
||||
pageId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpGetLandingPageTool: ToolConfig<
|
||||
MailchimpGetLandingPageParams,
|
||||
MailchimpGetLandingPageResponse
|
||||
> = {
|
||||
id: 'mailchimp_get_landing_page',
|
||||
name: 'Get Landing Page from Mailchimp',
|
||||
description: 'Retrieve details of a specific landing page from Mailchimp',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
pageId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the landing page',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => buildMailchimpUrl(params.apiKey, `/landing-pages/${params.pageId}`),
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'get_landing_page')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
landingPage: data,
|
||||
metadata: {
|
||||
operation: 'get_landing_page' as const,
|
||||
pageId: data.id,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Landing page data and metadata',
|
||||
properties: {
|
||||
landingPage: { type: 'object', description: 'Landing page object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpGetLandingPages')
|
||||
|
||||
export interface MailchimpGetLandingPagesParams {
|
||||
apiKey: string
|
||||
count?: string
|
||||
offset?: string
|
||||
}
|
||||
|
||||
export interface MailchimpGetLandingPagesResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
landingPages: any[]
|
||||
totalItems: number
|
||||
metadata: {
|
||||
operation: 'get_landing_pages'
|
||||
totalReturned: number
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpGetLandingPagesTool: ToolConfig<
|
||||
MailchimpGetLandingPagesParams,
|
||||
MailchimpGetLandingPagesResponse
|
||||
> = {
|
||||
id: 'mailchimp_get_landing_pages',
|
||||
name: 'Get Landing Pages from Mailchimp',
|
||||
description: 'Retrieve a list of landing pages from Mailchimp',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
count: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Number of results (default: 10, max: 1000)',
|
||||
},
|
||||
offset: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Number of results to skip',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const queryParams = new URLSearchParams()
|
||||
if (params.count) queryParams.append('count', params.count)
|
||||
if (params.offset) queryParams.append('offset', params.offset)
|
||||
|
||||
const query = queryParams.toString()
|
||||
const url = buildMailchimpUrl(params.apiKey, '/landing-pages')
|
||||
return query ? `${url}?${query}` : url
|
||||
},
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'get_landing_pages')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
const landingPages = data.landing_pages || []
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
landingPages,
|
||||
totalItems: data.total_items || landingPages.length,
|
||||
metadata: {
|
||||
operation: 'get_landing_pages' as const,
|
||||
totalReturned: landingPages.length,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Landing pages data and metadata',
|
||||
properties: {
|
||||
landingPages: { type: 'array', description: 'Array of landing page objects' },
|
||||
totalItems: { type: 'number', description: 'Total number of landing pages' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpGetMember')
|
||||
|
||||
export interface MailchimpGetMemberParams {
|
||||
apiKey: string
|
||||
listId: string
|
||||
subscriberEmail: string
|
||||
}
|
||||
|
||||
export interface MailchimpGetMemberResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
member: any
|
||||
metadata: {
|
||||
operation: 'get_member'
|
||||
subscriberHash: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpGetMemberTool: ToolConfig<
|
||||
MailchimpGetMemberParams,
|
||||
MailchimpGetMemberResponse
|
||||
> = {
|
||||
id: 'mailchimp_get_member',
|
||||
name: 'Get Member from Mailchimp Audience',
|
||||
description: 'Retrieve details of a specific member from a Mailchimp audience',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
listId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the list',
|
||||
},
|
||||
subscriberEmail: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Member email address or MD5 hash',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) =>
|
||||
buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/members/${params.subscriberEmail}`),
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'get_member')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
member: data,
|
||||
metadata: {
|
||||
operation: 'get_member' as const,
|
||||
subscriberHash: data.id,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Member data and metadata',
|
||||
properties: {
|
||||
member: { type: 'object', description: 'Member object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpGetMemberTags')
|
||||
|
||||
export interface MailchimpGetMemberTagsParams {
|
||||
apiKey: string
|
||||
listId: string
|
||||
subscriberEmail: string
|
||||
}
|
||||
|
||||
export interface MailchimpGetMemberTagsResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
tags: any[]
|
||||
totalItems: number
|
||||
metadata: {
|
||||
operation: 'get_member_tags'
|
||||
totalReturned: number
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpGetMemberTagsTool: ToolConfig<
|
||||
MailchimpGetMemberTagsParams,
|
||||
MailchimpGetMemberTagsResponse
|
||||
> = {
|
||||
id: 'mailchimp_get_member_tags',
|
||||
name: 'Get Member Tags from Mailchimp',
|
||||
description: 'Retrieve tags associated with a member in a Mailchimp audience',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
listId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the list',
|
||||
},
|
||||
subscriberEmail: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Member email address or MD5 hash',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) =>
|
||||
buildMailchimpUrl(
|
||||
params.apiKey,
|
||||
`/lists/${params.listId}/members/${params.subscriberEmail}/tags`
|
||||
),
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'get_member_tags')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
const tags = data.tags || []
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
tags,
|
||||
totalItems: data.total_items || tags.length,
|
||||
metadata: {
|
||||
operation: 'get_member_tags' as const,
|
||||
totalReturned: tags.length,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Member tags data and metadata',
|
||||
properties: {
|
||||
tags: { type: 'array', description: 'Array of tag objects' },
|
||||
totalItems: { type: 'number', description: 'Total number of tags' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpGetMembers')
|
||||
|
||||
export interface MailchimpGetMembersParams {
|
||||
apiKey: string
|
||||
listId: string
|
||||
status?: string
|
||||
count?: string
|
||||
offset?: string
|
||||
}
|
||||
|
||||
export interface MailchimpGetMembersResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
members: any[]
|
||||
totalItems: number
|
||||
metadata: {
|
||||
operation: 'get_members'
|
||||
totalReturned: number
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpGetMembersTool: ToolConfig<
|
||||
MailchimpGetMembersParams,
|
||||
MailchimpGetMembersResponse
|
||||
> = {
|
||||
id: 'mailchimp_get_members',
|
||||
name: 'Get Members from Mailchimp Audience',
|
||||
description: 'Retrieve a list of members from a Mailchimp audience',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
listId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the list',
|
||||
},
|
||||
status: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Filter by status (subscribed, unsubscribed, cleaned, pending)',
|
||||
},
|
||||
count: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Number of results (default: 10, max: 1000)',
|
||||
},
|
||||
offset: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Number of results to skip',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const queryParams = new URLSearchParams()
|
||||
if (params.status) queryParams.append('status', params.status)
|
||||
if (params.count) queryParams.append('count', params.count)
|
||||
if (params.offset) queryParams.append('offset', params.offset)
|
||||
|
||||
const query = queryParams.toString()
|
||||
const url = buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/members`)
|
||||
return query ? `${url}?${query}` : url
|
||||
},
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'get_members')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
const members = data.members || []
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
members,
|
||||
totalItems: data.total_items || members.length,
|
||||
metadata: {
|
||||
operation: 'get_members' as const,
|
||||
totalReturned: members.length,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Members data and metadata',
|
||||
properties: {
|
||||
members: { type: 'array', description: 'Array of member objects' },
|
||||
totalItems: { type: 'number', description: 'Total number of members' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpGetMergeField')
|
||||
|
||||
export interface MailchimpGetMergeFieldParams {
|
||||
apiKey: string
|
||||
listId: string
|
||||
mergeId: string
|
||||
}
|
||||
|
||||
export interface MailchimpGetMergeFieldResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
mergeField: any
|
||||
metadata: {
|
||||
operation: 'get_merge_field'
|
||||
mergeId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpGetMergeFieldTool: ToolConfig<
|
||||
MailchimpGetMergeFieldParams,
|
||||
MailchimpGetMergeFieldResponse
|
||||
> = {
|
||||
id: 'mailchimp_get_merge_field',
|
||||
name: 'Get Merge Field from Mailchimp Audience',
|
||||
description: 'Retrieve details of a specific merge field from a Mailchimp audience',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
listId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the list',
|
||||
},
|
||||
mergeId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the merge field',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) =>
|
||||
buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/merge-fields/${params.mergeId}`),
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'get_merge_field')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
mergeField: data,
|
||||
metadata: {
|
||||
operation: 'get_merge_field' as const,
|
||||
mergeId: data.merge_id,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Merge field data and metadata',
|
||||
properties: {
|
||||
mergeField: { type: 'object', description: 'Merge field object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpGetMergeFields')
|
||||
|
||||
export interface MailchimpGetMergeFieldsParams {
|
||||
apiKey: string
|
||||
listId: string
|
||||
count?: string
|
||||
offset?: string
|
||||
}
|
||||
|
||||
export interface MailchimpGetMergeFieldsResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
mergeFields: any[]
|
||||
totalItems: number
|
||||
metadata: {
|
||||
operation: 'get_merge_fields'
|
||||
totalReturned: number
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpGetMergeFieldsTool: ToolConfig<
|
||||
MailchimpGetMergeFieldsParams,
|
||||
MailchimpGetMergeFieldsResponse
|
||||
> = {
|
||||
id: 'mailchimp_get_merge_fields',
|
||||
name: 'Get Merge Fields from Mailchimp Audience',
|
||||
description: 'Retrieve a list of merge fields from a Mailchimp audience',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
listId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the list',
|
||||
},
|
||||
count: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Number of results (default: 10, max: 1000)',
|
||||
},
|
||||
offset: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Number of results to skip',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const queryParams = new URLSearchParams()
|
||||
if (params.count) queryParams.append('count', params.count)
|
||||
if (params.offset) queryParams.append('offset', params.offset)
|
||||
|
||||
const query = queryParams.toString()
|
||||
const url = buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/merge-fields`)
|
||||
return query ? `${url}?${query}` : url
|
||||
},
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'get_merge_fields')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
const mergeFields = data.merge_fields || []
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
mergeFields,
|
||||
totalItems: data.total_items || mergeFields.length,
|
||||
metadata: {
|
||||
operation: 'get_merge_fields' as const,
|
||||
totalReturned: mergeFields.length,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Merge fields data and metadata',
|
||||
properties: {
|
||||
mergeFields: { type: 'array', description: 'Array of merge field objects' },
|
||||
totalItems: { type: 'number', description: 'Total number of merge fields' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpGetSegment')
|
||||
|
||||
export interface MailchimpGetSegmentParams {
|
||||
apiKey: string
|
||||
listId: string
|
||||
segmentId: string
|
||||
}
|
||||
|
||||
export interface MailchimpGetSegmentResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
segment: any
|
||||
metadata: {
|
||||
operation: 'get_segment'
|
||||
segmentId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpGetSegmentTool: ToolConfig<
|
||||
MailchimpGetSegmentParams,
|
||||
MailchimpGetSegmentResponse
|
||||
> = {
|
||||
id: 'mailchimp_get_segment',
|
||||
name: 'Get Segment from Mailchimp Audience',
|
||||
description: 'Retrieve details of a specific segment from a Mailchimp audience',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
listId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the list',
|
||||
},
|
||||
segmentId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the segment',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) =>
|
||||
buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/segments/${params.segmentId}`),
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'get_segment')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
segment: data,
|
||||
metadata: {
|
||||
operation: 'get_segment' as const,
|
||||
segmentId: data.id,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Segment data and metadata',
|
||||
properties: {
|
||||
segment: { type: 'object', description: 'Segment object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpGetSegmentMembers')
|
||||
|
||||
export interface MailchimpGetSegmentMembersParams {
|
||||
apiKey: string
|
||||
listId: string
|
||||
segmentId: string
|
||||
count?: string
|
||||
offset?: string
|
||||
}
|
||||
|
||||
export interface MailchimpGetSegmentMembersResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
members: any[]
|
||||
totalItems: number
|
||||
metadata: {
|
||||
operation: 'get_segment_members'
|
||||
totalReturned: number
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpGetSegmentMembersTool: ToolConfig<
|
||||
MailchimpGetSegmentMembersParams,
|
||||
MailchimpGetSegmentMembersResponse
|
||||
> = {
|
||||
id: 'mailchimp_get_segment_members',
|
||||
name: 'Get Segment Members from Mailchimp',
|
||||
description: 'Retrieve members of a specific segment from a Mailchimp audience',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
listId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the list',
|
||||
},
|
||||
segmentId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the segment',
|
||||
},
|
||||
count: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Number of results (default: 10, max: 1000)',
|
||||
},
|
||||
offset: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Number of results to skip',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const queryParams = new URLSearchParams()
|
||||
if (params.count) queryParams.append('count', params.count)
|
||||
if (params.offset) queryParams.append('offset', params.offset)
|
||||
|
||||
const query = queryParams.toString()
|
||||
const url = buildMailchimpUrl(
|
||||
params.apiKey,
|
||||
`/lists/${params.listId}/segments/${params.segmentId}/members`
|
||||
)
|
||||
return query ? `${url}?${query}` : url
|
||||
},
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'get_segment_members')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
const members = data.members || []
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
members,
|
||||
totalItems: data.total_items || members.length,
|
||||
metadata: {
|
||||
operation: 'get_segment_members' as const,
|
||||
totalReturned: members.length,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Segment members data and metadata',
|
||||
properties: {
|
||||
members: { type: 'array', description: 'Array of member objects' },
|
||||
totalItems: { type: 'number', description: 'Total number of members' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpGetSegments')
|
||||
|
||||
export interface MailchimpGetSegmentsParams {
|
||||
apiKey: string
|
||||
listId: string
|
||||
count?: string
|
||||
offset?: string
|
||||
}
|
||||
|
||||
export interface MailchimpGetSegmentsResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
segments: any[]
|
||||
totalItems: number
|
||||
metadata: {
|
||||
operation: 'get_segments'
|
||||
totalReturned: number
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpGetSegmentsTool: ToolConfig<
|
||||
MailchimpGetSegmentsParams,
|
||||
MailchimpGetSegmentsResponse
|
||||
> = {
|
||||
id: 'mailchimp_get_segments',
|
||||
name: 'Get Segments from Mailchimp Audience',
|
||||
description: 'Retrieve a list of segments from a Mailchimp audience',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
listId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the list',
|
||||
},
|
||||
count: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Number of results (default: 10, max: 1000)',
|
||||
},
|
||||
offset: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Number of results to skip',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const queryParams = new URLSearchParams()
|
||||
if (params.count) queryParams.append('count', params.count)
|
||||
if (params.offset) queryParams.append('offset', params.offset)
|
||||
|
||||
const query = queryParams.toString()
|
||||
const url = buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/segments`)
|
||||
return query ? `${url}?${query}` : url
|
||||
},
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'get_segments')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
const segments = data.segments || []
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
segments,
|
||||
totalItems: data.total_items || segments.length,
|
||||
metadata: {
|
||||
operation: 'get_segments' as const,
|
||||
totalReturned: segments.length,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Segments data and metadata',
|
||||
properties: {
|
||||
segments: { type: 'array', description: 'Array of segment objects' },
|
||||
totalItems: { type: 'number', description: 'Total number of segments' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpGetTemplate')
|
||||
|
||||
export interface MailchimpGetTemplateParams {
|
||||
apiKey: string
|
||||
templateId: string
|
||||
}
|
||||
|
||||
export interface MailchimpGetTemplateResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
template: any
|
||||
metadata: {
|
||||
operation: 'get_template'
|
||||
templateId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpGetTemplateTool: ToolConfig<
|
||||
MailchimpGetTemplateParams,
|
||||
MailchimpGetTemplateResponse
|
||||
> = {
|
||||
id: 'mailchimp_get_template',
|
||||
name: 'Get Template from Mailchimp',
|
||||
description: 'Retrieve details of a specific template from Mailchimp',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
templateId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the template',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => buildMailchimpUrl(params.apiKey, `/templates/${params.templateId}`),
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'get_template')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
template: data,
|
||||
metadata: {
|
||||
operation: 'get_template' as const,
|
||||
templateId: data.id,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Template data and metadata',
|
||||
properties: {
|
||||
template: { type: 'object', description: 'Template object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpGetTemplates')
|
||||
|
||||
export interface MailchimpGetTemplatesParams {
|
||||
apiKey: string
|
||||
count?: string
|
||||
offset?: string
|
||||
}
|
||||
|
||||
export interface MailchimpGetTemplatesResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
templates: any[]
|
||||
totalItems: number
|
||||
metadata: {
|
||||
operation: 'get_templates'
|
||||
totalReturned: number
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpGetTemplatesTool: ToolConfig<
|
||||
MailchimpGetTemplatesParams,
|
||||
MailchimpGetTemplatesResponse
|
||||
> = {
|
||||
id: 'mailchimp_get_templates',
|
||||
name: 'Get Templates from Mailchimp',
|
||||
description: 'Retrieve a list of templates from Mailchimp',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
count: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Number of results (default: 10, max: 1000)',
|
||||
},
|
||||
offset: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Number of results to skip',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const queryParams = new URLSearchParams()
|
||||
if (params.count) queryParams.append('count', params.count)
|
||||
if (params.offset) queryParams.append('offset', params.offset)
|
||||
|
||||
const query = queryParams.toString()
|
||||
const url = buildMailchimpUrl(params.apiKey, '/templates')
|
||||
return query ? `${url}?${query}` : url
|
||||
},
|
||||
method: 'GET',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'get_templates')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
const templates = data.templates || []
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
templates,
|
||||
totalItems: data.total_items || templates.length,
|
||||
metadata: {
|
||||
operation: 'get_templates' as const,
|
||||
totalReturned: templates.length,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Templates data and metadata',
|
||||
properties: {
|
||||
templates: { type: 'array', description: 'Array of template objects' },
|
||||
totalItems: { type: 'number', description: 'Total number of templates' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
// Audience/List tools
|
||||
|
||||
export { mailchimpAddMemberTool } from './add_member'
|
||||
export { mailchimpAddMemberTagsTool } from './add_member_tags'
|
||||
export { mailchimpAddOrUpdateMemberTool } from './add_or_update_member'
|
||||
export { mailchimpAddSegmentMemberTool } from './add_segment_member'
|
||||
export { mailchimpAddSubscriberToAutomationTool } from './add_subscriber_to_automation'
|
||||
export { mailchimpArchiveMemberTool } from './archive_member'
|
||||
export { mailchimpCreateAudienceTool } from './create_audience'
|
||||
export { mailchimpCreateBatchOperationTool } from './create_batch_operation'
|
||||
export { mailchimpCreateCampaignTool } from './create_campaign'
|
||||
export { mailchimpCreateInterestTool } from './create_interest'
|
||||
export { mailchimpCreateInterestCategoryTool } from './create_interest_category'
|
||||
export { mailchimpCreateLandingPageTool } from './create_landing_page'
|
||||
export { mailchimpCreateMergeFieldTool } from './create_merge_field'
|
||||
export { mailchimpCreateSegmentTool } from './create_segment'
|
||||
export { mailchimpCreateTemplateTool } from './create_template'
|
||||
export { mailchimpDeleteAudienceTool } from './delete_audience'
|
||||
export { mailchimpDeleteBatchOperationTool } from './delete_batch_operation'
|
||||
export { mailchimpDeleteCampaignTool } from './delete_campaign'
|
||||
export { mailchimpDeleteInterestTool } from './delete_interest'
|
||||
export { mailchimpDeleteInterestCategoryTool } from './delete_interest_category'
|
||||
export { mailchimpDeleteLandingPageTool } from './delete_landing_page'
|
||||
export { mailchimpDeleteMemberTool } from './delete_member'
|
||||
export { mailchimpDeleteMergeFieldTool } from './delete_merge_field'
|
||||
export { mailchimpDeleteSegmentTool } from './delete_segment'
|
||||
export { mailchimpDeleteTemplateTool } from './delete_template'
|
||||
export { mailchimpGetAudienceTool } from './get_audience'
|
||||
export { mailchimpGetAudiencesTool } from './get_audiences'
|
||||
export { mailchimpGetAutomationTool } from './get_automation'
|
||||
// Automation tools
|
||||
export { mailchimpGetAutomationsTool } from './get_automations'
|
||||
export { mailchimpGetBatchOperationTool } from './get_batch_operation'
|
||||
// Batch operation tools
|
||||
export { mailchimpGetBatchOperationsTool } from './get_batch_operations'
|
||||
export { mailchimpGetCampaignTool } from './get_campaign'
|
||||
// Campaign content tools
|
||||
export { mailchimpGetCampaignContentTool } from './get_campaign_content'
|
||||
export { mailchimpGetCampaignReportTool } from './get_campaign_report'
|
||||
// Report tools
|
||||
export { mailchimpGetCampaignReportsTool } from './get_campaign_reports'
|
||||
// Campaign tools
|
||||
export { mailchimpGetCampaignsTool } from './get_campaigns'
|
||||
export { mailchimpGetInterestTool } from './get_interest'
|
||||
// Interest category tools
|
||||
export { mailchimpGetInterestCategoriesTool } from './get_interest_categories'
|
||||
export { mailchimpGetInterestCategoryTool } from './get_interest_category'
|
||||
// Interest tools
|
||||
export { mailchimpGetInterestsTool } from './get_interests'
|
||||
export { mailchimpGetLandingPageTool } from './get_landing_page'
|
||||
// Landing page tools
|
||||
export { mailchimpGetLandingPagesTool } from './get_landing_pages'
|
||||
export { mailchimpGetMemberTool } from './get_member'
|
||||
// Tag tools
|
||||
export { mailchimpGetMemberTagsTool } from './get_member_tags'
|
||||
// Member tools
|
||||
export { mailchimpGetMembersTool } from './get_members'
|
||||
export { mailchimpGetMergeFieldTool } from './get_merge_field'
|
||||
// Merge field tools
|
||||
export { mailchimpGetMergeFieldsTool } from './get_merge_fields'
|
||||
export { mailchimpGetSegmentTool } from './get_segment'
|
||||
export { mailchimpGetSegmentMembersTool } from './get_segment_members'
|
||||
// Segment tools
|
||||
export { mailchimpGetSegmentsTool } from './get_segments'
|
||||
export { mailchimpGetTemplateTool } from './get_template'
|
||||
// Template tools
|
||||
export { mailchimpGetTemplatesTool } from './get_templates'
|
||||
export { mailchimpPauseAutomationTool } from './pause_automation'
|
||||
export { mailchimpPublishLandingPageTool } from './publish_landing_page'
|
||||
export { mailchimpRemoveMemberTagsTool } from './remove_member_tags'
|
||||
export { mailchimpRemoveSegmentMemberTool } from './remove_segment_member'
|
||||
export { mailchimpReplicateCampaignTool } from './replicate_campaign'
|
||||
export { mailchimpScheduleCampaignTool } from './schedule_campaign'
|
||||
export { mailchimpSendCampaignTool } from './send_campaign'
|
||||
export { mailchimpSetCampaignContentTool } from './set_campaign_content'
|
||||
export { mailchimpStartAutomationTool } from './start_automation'
|
||||
export { mailchimpUnarchiveMemberTool } from './unarchive_member'
|
||||
export { mailchimpUnpublishLandingPageTool } from './unpublish_landing_page'
|
||||
export { mailchimpUnscheduleCampaignTool } from './unschedule_campaign'
|
||||
export { mailchimpUpdateAudienceTool } from './update_audience'
|
||||
export { mailchimpUpdateCampaignTool } from './update_campaign'
|
||||
export { mailchimpUpdateInterestTool } from './update_interest'
|
||||
export { mailchimpUpdateInterestCategoryTool } from './update_interest_category'
|
||||
export { mailchimpUpdateLandingPageTool } from './update_landing_page'
|
||||
export { mailchimpUpdateMemberTool } from './update_member'
|
||||
export { mailchimpUpdateMergeFieldTool } from './update_merge_field'
|
||||
export { mailchimpUpdateSegmentTool } from './update_segment'
|
||||
export { mailchimpUpdateTemplateTool } from './update_template'
|
||||
@@ -0,0 +1,89 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpPauseAutomation')
|
||||
|
||||
export interface MailchimpPauseAutomationParams {
|
||||
apiKey: string
|
||||
workflowId: string
|
||||
}
|
||||
|
||||
export interface MailchimpPauseAutomationResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'pause_automation'
|
||||
workflowId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpPauseAutomationTool: ToolConfig<
|
||||
MailchimpPauseAutomationParams,
|
||||
MailchimpPauseAutomationResponse
|
||||
> = {
|
||||
id: 'mailchimp_pause_automation',
|
||||
name: 'Pause Automation in Mailchimp',
|
||||
description: 'Pause all emails in a Mailchimp automation workflow',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
workflowId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the automation workflow',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) =>
|
||||
buildMailchimpUrl(
|
||||
params.apiKey,
|
||||
`/automations/${params.workflowId}/actions/pause-all-emails`
|
||||
),
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'pause_automation')
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'pause_automation' as const,
|
||||
workflowId: '',
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Pause confirmation',
|
||||
properties: {
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpPublishLandingPage')
|
||||
|
||||
export interface MailchimpPublishLandingPageParams {
|
||||
apiKey: string
|
||||
pageId: string
|
||||
}
|
||||
|
||||
export interface MailchimpPublishLandingPageResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'publish_landing_page'
|
||||
pageId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpPublishLandingPageTool: ToolConfig<
|
||||
MailchimpPublishLandingPageParams,
|
||||
MailchimpPublishLandingPageResponse
|
||||
> = {
|
||||
id: 'mailchimp_publish_landing_page',
|
||||
name: 'Publish Landing Page in Mailchimp',
|
||||
description: 'Publish a landing page in Mailchimp',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
pageId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the landing page',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) =>
|
||||
buildMailchimpUrl(params.apiKey, `/landing-pages/${params.pageId}/actions/publish`),
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'publish_landing_page')
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'publish_landing_page' as const,
|
||||
pageId: '',
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Publish confirmation',
|
||||
properties: {
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpRemoveMemberTags')
|
||||
|
||||
export interface MailchimpRemoveMemberTagsParams {
|
||||
apiKey: string
|
||||
listId: string
|
||||
subscriberEmail: string
|
||||
tags: string
|
||||
}
|
||||
|
||||
export interface MailchimpRemoveMemberTagsResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'remove_member_tags'
|
||||
subscriberHash: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpRemoveMemberTagsTool: ToolConfig<
|
||||
MailchimpRemoveMemberTagsParams,
|
||||
MailchimpRemoveMemberTagsResponse
|
||||
> = {
|
||||
id: 'mailchimp_remove_member_tags',
|
||||
name: 'Remove Tags from Member in Mailchimp',
|
||||
description: 'Remove tags from a member in a Mailchimp audience',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
listId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the list',
|
||||
},
|
||||
subscriberEmail: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Member email address or MD5 hash',
|
||||
},
|
||||
tags: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'JSON array of tags with inactive status',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) =>
|
||||
buildMailchimpUrl(
|
||||
params.apiKey,
|
||||
`/lists/${params.listId}/members/${params.subscriberEmail}/tags`
|
||||
),
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
body: (params) => {
|
||||
let tags = []
|
||||
try {
|
||||
tags = JSON.parse(params.tags)
|
||||
} catch (error) {
|
||||
logger.warn('Failed to parse tags', { error })
|
||||
}
|
||||
|
||||
return { tags }
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'remove_member_tags')
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'remove_member_tags' as const,
|
||||
subscriberHash: '',
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Tag removal confirmation',
|
||||
properties: {
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpRemoveSegmentMember')
|
||||
|
||||
export interface MailchimpRemoveSegmentMemberParams {
|
||||
apiKey: string
|
||||
listId: string
|
||||
segmentId: string
|
||||
subscriberEmail: string
|
||||
}
|
||||
|
||||
export interface MailchimpRemoveSegmentMemberResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'remove_segment_member'
|
||||
subscriberHash: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpRemoveSegmentMemberTool: ToolConfig<
|
||||
MailchimpRemoveSegmentMemberParams,
|
||||
MailchimpRemoveSegmentMemberResponse
|
||||
> = {
|
||||
id: 'mailchimp_remove_segment_member',
|
||||
name: 'Remove Member from Segment in Mailchimp',
|
||||
description: 'Remove a member from a specific segment in a Mailchimp audience',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
listId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the list',
|
||||
},
|
||||
segmentId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the segment',
|
||||
},
|
||||
subscriberEmail: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Member email address or MD5 hash',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) =>
|
||||
buildMailchimpUrl(
|
||||
params.apiKey,
|
||||
`/lists/${params.listId}/segments/${params.segmentId}/members/${params.subscriberEmail}`
|
||||
),
|
||||
method: 'DELETE',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'remove_segment_member')
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'remove_segment_member' as const,
|
||||
subscriberHash: '',
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Removal confirmation',
|
||||
properties: {
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpReplicateCampaign')
|
||||
|
||||
export interface MailchimpReplicateCampaignParams {
|
||||
apiKey: string
|
||||
campaignId: string
|
||||
}
|
||||
|
||||
export interface MailchimpReplicateCampaignResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
campaign: any
|
||||
metadata: {
|
||||
operation: 'replicate_campaign'
|
||||
campaignId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpReplicateCampaignTool: ToolConfig<
|
||||
MailchimpReplicateCampaignParams,
|
||||
MailchimpReplicateCampaignResponse
|
||||
> = {
|
||||
id: 'mailchimp_replicate_campaign',
|
||||
name: 'Replicate Campaign in Mailchimp',
|
||||
description: 'Create a copy of an existing Mailchimp campaign',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
campaignId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the campaign to replicate',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) =>
|
||||
buildMailchimpUrl(params.apiKey, `/campaigns/${params.campaignId}/actions/replicate`),
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'replicate_campaign')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
campaign: data,
|
||||
metadata: {
|
||||
operation: 'replicate_campaign' as const,
|
||||
campaignId: data.id,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Replicated campaign data',
|
||||
properties: {
|
||||
campaign: { type: 'object', description: 'Replicated campaign object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpScheduleCampaign')
|
||||
|
||||
export interface MailchimpScheduleCampaignParams {
|
||||
apiKey: string
|
||||
campaignId: string
|
||||
scheduleTime: string
|
||||
}
|
||||
|
||||
export interface MailchimpScheduleCampaignResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'schedule_campaign'
|
||||
campaignId: string
|
||||
scheduleTime: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpScheduleCampaignTool: ToolConfig<
|
||||
MailchimpScheduleCampaignParams,
|
||||
MailchimpScheduleCampaignResponse
|
||||
> = {
|
||||
id: 'mailchimp_schedule_campaign',
|
||||
name: 'Schedule Campaign in Mailchimp',
|
||||
description: 'Schedule a Mailchimp campaign to be sent at a specific time',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
campaignId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the campaign to schedule',
|
||||
},
|
||||
scheduleTime: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'ISO 8601 format date and time',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) =>
|
||||
buildMailchimpUrl(params.apiKey, `/campaigns/${params.campaignId}/actions/schedule`),
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
body: (params) => ({
|
||||
schedule_time: params.scheduleTime,
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'schedule_campaign')
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'schedule_campaign' as const,
|
||||
campaignId: '',
|
||||
scheduleTime: '',
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Schedule confirmation',
|
||||
properties: {
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpSendCampaign')
|
||||
|
||||
export interface MailchimpSendCampaignParams {
|
||||
apiKey: string
|
||||
campaignId: string
|
||||
}
|
||||
|
||||
export interface MailchimpSendCampaignResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'send_campaign'
|
||||
campaignId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpSendCampaignTool: ToolConfig<
|
||||
MailchimpSendCampaignParams,
|
||||
MailchimpSendCampaignResponse
|
||||
> = {
|
||||
id: 'mailchimp_send_campaign',
|
||||
name: 'Send Campaign in Mailchimp',
|
||||
description: 'Send a Mailchimp campaign',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
campaignId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the campaign to send',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) =>
|
||||
buildMailchimpUrl(params.apiKey, `/campaigns/${params.campaignId}/actions/send`),
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'send_campaign')
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'send_campaign' as const,
|
||||
campaignId: '',
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Send confirmation',
|
||||
properties: {
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpSetCampaignContent')
|
||||
|
||||
export interface MailchimpSetCampaignContentParams {
|
||||
apiKey: string
|
||||
campaignId: string
|
||||
html?: string
|
||||
plainText?: string
|
||||
templateId?: string
|
||||
}
|
||||
|
||||
export interface MailchimpSetCampaignContentResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
content: any
|
||||
metadata: {
|
||||
operation: 'set_campaign_content'
|
||||
campaignId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpSetCampaignContentTool: ToolConfig<
|
||||
MailchimpSetCampaignContentParams,
|
||||
MailchimpSetCampaignContentResponse
|
||||
> = {
|
||||
id: 'mailchimp_set_campaign_content',
|
||||
name: 'Set Campaign Content in Mailchimp',
|
||||
description: 'Set the content for a Mailchimp campaign',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
campaignId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the campaign',
|
||||
},
|
||||
html: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'The HTML content for the campaign',
|
||||
},
|
||||
plainText: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'The plain-text content for the campaign',
|
||||
},
|
||||
templateId: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'The ID of the template to use',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => buildMailchimpUrl(params.apiKey, `/campaigns/${params.campaignId}/content`),
|
||||
method: 'PUT',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
body: (params) => {
|
||||
const body: any = {}
|
||||
|
||||
if (params.html) body.html = params.html
|
||||
if (params.plainText) body.plain_text = params.plainText
|
||||
if (params.templateId) body.template = { id: params.templateId }
|
||||
|
||||
return body
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'set_campaign_content')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
content: data,
|
||||
metadata: {
|
||||
operation: 'set_campaign_content' as const,
|
||||
campaignId: '',
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Campaign content data',
|
||||
properties: {
|
||||
content: { type: 'object', description: 'Campaign content object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpStartAutomation')
|
||||
|
||||
export interface MailchimpStartAutomationParams {
|
||||
apiKey: string
|
||||
workflowId: string
|
||||
}
|
||||
|
||||
export interface MailchimpStartAutomationResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'start_automation'
|
||||
workflowId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpStartAutomationTool: ToolConfig<
|
||||
MailchimpStartAutomationParams,
|
||||
MailchimpStartAutomationResponse
|
||||
> = {
|
||||
id: 'mailchimp_start_automation',
|
||||
name: 'Start Automation in Mailchimp',
|
||||
description: 'Start all emails in a Mailchimp automation workflow',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
workflowId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the automation workflow',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) =>
|
||||
buildMailchimpUrl(
|
||||
params.apiKey,
|
||||
`/automations/${params.workflowId}/actions/start-all-emails`
|
||||
),
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'start_automation')
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'start_automation' as const,
|
||||
workflowId: '',
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Start confirmation',
|
||||
properties: {
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
|
||||
const logger = createLogger('Mailchimp')
|
||||
|
||||
// Base params
|
||||
export interface MailchimpBaseParams {
|
||||
apiKey: string // API key with server prefix (e.g., "key-us19")
|
||||
}
|
||||
|
||||
export interface MailchimpPaginationParams {
|
||||
count?: string
|
||||
offset?: string
|
||||
}
|
||||
|
||||
export interface MailchimpPagingInfo {
|
||||
totalItems: number
|
||||
}
|
||||
|
||||
export interface MailchimpResponse<T> {
|
||||
success: boolean
|
||||
output: {
|
||||
data?: T
|
||||
paging?: MailchimpPagingInfo
|
||||
metadata: {
|
||||
operation: string
|
||||
[key: string]: any
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
// Helper function to extract server prefix from API key
|
||||
export function extractServerPrefix(apiKey: string): string {
|
||||
const parts = apiKey.split('-')
|
||||
if (parts.length < 2) {
|
||||
throw new Error('Invalid Mailchimp API key format. Expected format: key-dc (e.g., abc123-us19)')
|
||||
}
|
||||
return parts[parts.length - 1]
|
||||
}
|
||||
|
||||
// Helper function to build Mailchimp API URLs
|
||||
export function buildMailchimpUrl(apiKey: string, path: string): string {
|
||||
const serverPrefix = extractServerPrefix(apiKey)
|
||||
return `https://${serverPrefix}.api.mailchimp.com/3.0${path}`
|
||||
}
|
||||
|
||||
// Helper function for consistent error handling
|
||||
export function handleMailchimpError(data: any, status: number, operation: string): never {
|
||||
logger.error(`Mailchimp API request failed for ${operation}`, { data, status })
|
||||
|
||||
const errorMessage = data.detail || data.title || data.error || data.message || 'Unknown error'
|
||||
throw new Error(`Mailchimp ${operation} failed: ${errorMessage}`)
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpUnarchiveMember')
|
||||
|
||||
export interface MailchimpUnarchiveMemberParams {
|
||||
apiKey: string
|
||||
listId: string
|
||||
subscriberEmail: string
|
||||
emailAddress: string
|
||||
status: string
|
||||
}
|
||||
|
||||
export interface MailchimpUnarchiveMemberResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
member: any
|
||||
metadata: {
|
||||
operation: 'unarchive_member'
|
||||
subscriberHash: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpUnarchiveMemberTool: ToolConfig<
|
||||
MailchimpUnarchiveMemberParams,
|
||||
MailchimpUnarchiveMemberResponse
|
||||
> = {
|
||||
id: 'mailchimp_unarchive_member',
|
||||
name: 'Unarchive Member in Mailchimp Audience',
|
||||
description: 'Restore an archived member to a Mailchimp audience',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
listId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the list',
|
||||
},
|
||||
subscriberEmail: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Member email address or MD5 hash',
|
||||
},
|
||||
emailAddress: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Member email address',
|
||||
},
|
||||
status: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'Subscriber status',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) =>
|
||||
buildMailchimpUrl(params.apiKey, `/lists/${params.listId}/members/${params.subscriberEmail}`),
|
||||
method: 'PUT',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
body: (params) => ({
|
||||
email_address: params.emailAddress,
|
||||
status: params.status,
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'unarchive_member')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
member: data,
|
||||
metadata: {
|
||||
operation: 'unarchive_member' as const,
|
||||
subscriberHash: data.id,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Unarchived member data',
|
||||
properties: {
|
||||
member: { type: 'object', description: 'Unarchived member object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpUnpublishLandingPage')
|
||||
|
||||
export interface MailchimpUnpublishLandingPageParams {
|
||||
apiKey: string
|
||||
pageId: string
|
||||
}
|
||||
|
||||
export interface MailchimpUnpublishLandingPageResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'unpublish_landing_page'
|
||||
pageId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpUnpublishLandingPageTool: ToolConfig<
|
||||
MailchimpUnpublishLandingPageParams,
|
||||
MailchimpUnpublishLandingPageResponse
|
||||
> = {
|
||||
id: 'mailchimp_unpublish_landing_page',
|
||||
name: 'Unpublish Landing Page in Mailchimp',
|
||||
description: 'Unpublish a landing page in Mailchimp',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
pageId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the landing page',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) =>
|
||||
buildMailchimpUrl(params.apiKey, `/landing-pages/${params.pageId}/actions/unpublish`),
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'unpublish_landing_page')
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'unpublish_landing_page' as const,
|
||||
pageId: '',
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Unpublish confirmation',
|
||||
properties: {
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpUnscheduleCampaign')
|
||||
|
||||
export interface MailchimpUnscheduleCampaignParams {
|
||||
apiKey: string
|
||||
campaignId: string
|
||||
}
|
||||
|
||||
export interface MailchimpUnscheduleCampaignResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'unschedule_campaign'
|
||||
campaignId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpUnscheduleCampaignTool: ToolConfig<
|
||||
MailchimpUnscheduleCampaignParams,
|
||||
MailchimpUnscheduleCampaignResponse
|
||||
> = {
|
||||
id: 'mailchimp_unschedule_campaign',
|
||||
name: 'Unschedule Campaign in Mailchimp',
|
||||
description: 'Unschedule a previously scheduled Mailchimp campaign',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
campaignId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the campaign to unschedule',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) =>
|
||||
buildMailchimpUrl(params.apiKey, `/campaigns/${params.campaignId}/actions/unschedule`),
|
||||
method: 'POST',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'unschedule_campaign')
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
metadata: {
|
||||
operation: 'unschedule_campaign' as const,
|
||||
campaignId: '',
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Unschedule confirmation',
|
||||
properties: {
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpUpdateAudience')
|
||||
|
||||
export interface MailchimpUpdateAudienceParams {
|
||||
apiKey: string
|
||||
listId: string
|
||||
audienceName?: string
|
||||
permissionReminder?: string
|
||||
campaignDefaults?: string
|
||||
emailTypeOption?: string
|
||||
}
|
||||
|
||||
export interface MailchimpUpdateAudienceResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
list: any
|
||||
metadata: {
|
||||
operation: 'update_audience'
|
||||
listId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpUpdateAudienceTool: ToolConfig<
|
||||
MailchimpUpdateAudienceParams,
|
||||
MailchimpUpdateAudienceResponse
|
||||
> = {
|
||||
id: 'mailchimp_update_audience',
|
||||
name: 'Update Audience in Mailchimp',
|
||||
description: 'Update an existing audience (list) in Mailchimp',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
listId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the list',
|
||||
},
|
||||
audienceName: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'The name of the list',
|
||||
},
|
||||
permissionReminder: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Permission reminder text',
|
||||
},
|
||||
campaignDefaults: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'JSON object of default campaign settings',
|
||||
},
|
||||
emailTypeOption: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'Support multiple email formats',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => buildMailchimpUrl(params.apiKey, `/lists/${params.listId}`),
|
||||
method: 'PATCH',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
body: (params) => {
|
||||
const body: any = {}
|
||||
|
||||
if (params.audienceName) body.name = params.audienceName
|
||||
if (params.permissionReminder) body.permission_reminder = params.permissionReminder
|
||||
if (params.emailTypeOption !== undefined)
|
||||
body.email_type_option = params.emailTypeOption === 'true'
|
||||
|
||||
if (params.campaignDefaults) {
|
||||
try {
|
||||
body.campaign_defaults = JSON.parse(params.campaignDefaults)
|
||||
} catch (error) {
|
||||
logger.warn('Failed to parse campaign defaults', { error })
|
||||
}
|
||||
}
|
||||
|
||||
return body
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'update_audience')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
list: data,
|
||||
metadata: {
|
||||
operation: 'update_audience' as const,
|
||||
listId: data.id,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Updated audience data',
|
||||
properties: {
|
||||
list: { type: 'object', description: 'Updated audience/list object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
import { createLogger } from '@/lib/logs/console/logger'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
import { buildMailchimpUrl, handleMailchimpError } from './types'
|
||||
|
||||
const logger = createLogger('MailchimpUpdateCampaign')
|
||||
|
||||
export interface MailchimpUpdateCampaignParams {
|
||||
apiKey: string
|
||||
campaignId: string
|
||||
campaignSettings?: string
|
||||
recipients?: string
|
||||
}
|
||||
|
||||
export interface MailchimpUpdateCampaignResponse {
|
||||
success: boolean
|
||||
output: {
|
||||
campaign: any
|
||||
metadata: {
|
||||
operation: 'update_campaign'
|
||||
campaignId: string
|
||||
}
|
||||
success: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const mailchimpUpdateCampaignTool: ToolConfig<
|
||||
MailchimpUpdateCampaignParams,
|
||||
MailchimpUpdateCampaignResponse
|
||||
> = {
|
||||
id: 'mailchimp_update_campaign',
|
||||
name: 'Update Campaign in Mailchimp',
|
||||
description: 'Update an existing campaign in Mailchimp',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
apiKey: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'hidden',
|
||||
description: 'Mailchimp API key with server prefix',
|
||||
},
|
||||
campaignId: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-only',
|
||||
description: 'The unique ID for the campaign',
|
||||
},
|
||||
campaignSettings: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'JSON object of campaign settings',
|
||||
},
|
||||
recipients: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-only',
|
||||
description: 'JSON object of recipients',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => buildMailchimpUrl(params.apiKey, `/campaigns/${params.campaignId}`),
|
||||
method: 'PATCH',
|
||||
headers: (params) => ({
|
||||
Authorization: `Bearer ${params.apiKey}`,
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
body: (params) => {
|
||||
const body: any = {}
|
||||
|
||||
if (params.campaignSettings) {
|
||||
try {
|
||||
body.settings = JSON.parse(params.campaignSettings)
|
||||
} catch (error) {
|
||||
logger.warn('Failed to parse campaign settings', { error })
|
||||
}
|
||||
}
|
||||
|
||||
if (params.recipients) {
|
||||
try {
|
||||
body.recipients = JSON.parse(params.recipients)
|
||||
} catch (error) {
|
||||
logger.warn('Failed to parse recipients', { error })
|
||||
}
|
||||
}
|
||||
|
||||
return body
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response: Response) => {
|
||||
if (!response.ok) {
|
||||
const data = await response.json()
|
||||
handleMailchimpError(data, response.status, 'update_campaign')
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
campaign: data,
|
||||
metadata: {
|
||||
operation: 'update_campaign' as const,
|
||||
campaignId: data.id,
|
||||
},
|
||||
success: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Operation success status' },
|
||||
output: {
|
||||
type: 'object',
|
||||
description: 'Updated campaign data',
|
||||
properties: {
|
||||
campaign: { type: 'object', description: 'Updated campaign object' },
|
||||
metadata: { type: 'object', description: 'Operation metadata' },
|
||||
success: { type: 'boolean', description: 'Operation success' },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user