-
Notifications
You must be signed in to change notification settings - Fork 3.7k
fix(loops): align integration with live API docs, add suppression + get-template tools #5358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+482
−14
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
788320b
fix(loops): align integration with live API docs, add suppression + g…
waleedlatif1 7c49c26
fix(loops): expose contactId output, fix stale tool description
waleedlatif1 57014a3
fix(loops): restore lastUpdated as backwards-compat alias on list_tra…
waleedlatif1 bf5c0d5
fix(loops): update id output description to cover get_transactional_e…
waleedlatif1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| import type { | ||
| LoopsCheckContactSuppressionParams, | ||
| LoopsCheckContactSuppressionResponse, | ||
| } from '@/tools/loops/types' | ||
| import type { ToolConfig } from '@/tools/types' | ||
|
|
||
| export const loopsCheckContactSuppressionTool: ToolConfig< | ||
| LoopsCheckContactSuppressionParams, | ||
| LoopsCheckContactSuppressionResponse | ||
| > = { | ||
| id: 'loops_check_contact_suppression', | ||
| name: 'Loops Check Contact Suppression', | ||
| description: | ||
| 'Check whether a Loops contact is on the suppression list (bounced, complained, or unsubscribed) by email address or userId.', | ||
| version: '1.0.0', | ||
|
|
||
| params: { | ||
| apiKey: { | ||
| type: 'string', | ||
| required: true, | ||
| visibility: 'user-only', | ||
| description: 'Loops API key for authentication', | ||
| }, | ||
| email: { | ||
| type: 'string', | ||
| required: false, | ||
| visibility: 'user-or-llm', | ||
| description: | ||
| 'The contact email address to check (at least one of email or userId is required)', | ||
| }, | ||
| userId: { | ||
| type: 'string', | ||
| required: false, | ||
| visibility: 'user-or-llm', | ||
| description: 'The contact userId to check (at least one of email or userId is required)', | ||
| }, | ||
| }, | ||
|
|
||
| request: { | ||
| url: (params) => { | ||
| if (!params.email && !params.userId) { | ||
| throw new Error('At least one of email or userId is required to check suppression status') | ||
| } | ||
| const base = 'https://app.loops.so/api/v1/contacts/suppression' | ||
| if (params.email) return `${base}?email=${encodeURIComponent(params.email.trim())}` | ||
| return `${base}?userId=${encodeURIComponent(params.userId!.trim())}` | ||
| }, | ||
| method: 'GET', | ||
| headers: (params) => ({ | ||
| Authorization: `Bearer ${params.apiKey}`, | ||
| }), | ||
| }, | ||
|
|
||
| transformResponse: async (response: Response) => { | ||
| const data = await response.json() | ||
|
|
||
| if (data.isSuppressed == null) { | ||
| return { | ||
| success: false, | ||
| output: { | ||
| contactId: null, | ||
| email: null, | ||
| userId: null, | ||
| isSuppressed: false, | ||
| removalQuotaLimit: null, | ||
| removalQuotaRemaining: null, | ||
| }, | ||
| error: data.message ?? 'Failed to check contact suppression status', | ||
| } | ||
| } | ||
|
|
||
| return { | ||
| success: true, | ||
| output: { | ||
| contactId: (data.contact?.id as string) ?? null, | ||
| email: (data.contact?.email as string) ?? null, | ||
| userId: (data.contact?.userId as string) ?? null, | ||
| isSuppressed: (data.isSuppressed as boolean) ?? false, | ||
| removalQuotaLimit: (data.removalQuota?.limit as number) ?? null, | ||
| removalQuotaRemaining: (data.removalQuota?.remaining as number) ?? null, | ||
| }, | ||
| } | ||
| }, | ||
|
|
||
| outputs: { | ||
| contactId: { type: 'string', description: 'The Loops-assigned contact ID', optional: true }, | ||
| email: { type: 'string', description: 'The contact email address', optional: true }, | ||
| userId: { type: 'string', description: 'The contact userId', optional: true }, | ||
| isSuppressed: { | ||
| type: 'boolean', | ||
| description: 'Whether the contact is on the suppression list', | ||
| }, | ||
| removalQuotaLimit: { | ||
| type: 'number', | ||
| description: 'Total suppression-removal quota for the team', | ||
| optional: true, | ||
| }, | ||
| removalQuotaRemaining: { | ||
| type: 'number', | ||
| description: 'Remaining suppression-removal quota for the team', | ||
| optional: true, | ||
| }, | ||
| }, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| import type { | ||
| LoopsGetTransactionalEmailParams, | ||
| LoopsGetTransactionalEmailResponse, | ||
| } from '@/tools/loops/types' | ||
| import type { ToolConfig } from '@/tools/types' | ||
|
|
||
| export const loopsGetTransactionalEmailTool: ToolConfig< | ||
| LoopsGetTransactionalEmailParams, | ||
| LoopsGetTransactionalEmailResponse | ||
| > = { | ||
| id: 'loops_get_transactional_email', | ||
| name: 'Loops Get Transactional Email', | ||
| description: | ||
| 'Retrieve a single transactional email template from your Loops account by its ID, including its data variables and draft/published message IDs.', | ||
| version: '1.0.0', | ||
|
|
||
| params: { | ||
| apiKey: { | ||
| type: 'string', | ||
| required: true, | ||
| visibility: 'user-only', | ||
| description: 'Loops API key for authentication', | ||
| }, | ||
| transactionalId: { | ||
| type: 'string', | ||
| required: true, | ||
| visibility: 'user-or-llm', | ||
| description: 'The ID of the transactional email template to retrieve', | ||
| }, | ||
| }, | ||
|
|
||
| request: { | ||
| url: (params) => | ||
| `https://app.loops.so/api/v1/transactional-emails/${encodeURIComponent(params.transactionalId.trim())}`, | ||
| method: 'GET', | ||
| headers: (params) => ({ | ||
| Authorization: `Bearer ${params.apiKey}`, | ||
| }), | ||
| }, | ||
|
|
||
| transformResponse: async (response: Response) => { | ||
| const data = await response.json() | ||
|
|
||
| if (!data.id) { | ||
| return { | ||
| success: false, | ||
| output: { | ||
| id: null, | ||
| name: null, | ||
| draftEmailMessageId: null, | ||
| publishedEmailMessageId: null, | ||
| transactionalGroupId: null, | ||
| createdAt: null, | ||
| updatedAt: null, | ||
| dataVariables: [], | ||
| }, | ||
| error: data.message ?? 'Failed to get transactional email', | ||
| } | ||
| } | ||
|
|
||
| return { | ||
| success: true, | ||
| output: { | ||
| id: (data.id as string) ?? null, | ||
| name: (data.name as string) ?? null, | ||
| draftEmailMessageId: (data.draftEmailMessageId as string) ?? null, | ||
| publishedEmailMessageId: (data.publishedEmailMessageId as string) ?? null, | ||
| transactionalGroupId: (data.transactionalGroupId as string) ?? null, | ||
| createdAt: (data.createdAt as string) ?? null, | ||
| updatedAt: (data.updatedAt as string) ?? null, | ||
| dataVariables: (data.dataVariables as string[]) ?? [], | ||
| }, | ||
| } | ||
| }, | ||
|
|
||
| outputs: { | ||
| id: { type: 'string', description: 'The transactional email template ID', optional: true }, | ||
| name: { type: 'string', description: 'The template name', optional: true }, | ||
| draftEmailMessageId: { | ||
| type: 'string', | ||
| description: 'ID of the draft email message, if any', | ||
| optional: true, | ||
| }, | ||
| publishedEmailMessageId: { | ||
| type: 'string', | ||
| description: 'ID of the published email message, if any', | ||
| optional: true, | ||
| }, | ||
| transactionalGroupId: { | ||
| type: 'string', | ||
| description: 'ID of the transactional group this template belongs to, if any', | ||
| optional: true, | ||
| }, | ||
| createdAt: { type: 'string', description: 'Creation timestamp (ISO 8601)', optional: true }, | ||
| updatedAt: { | ||
| type: 'string', | ||
| description: 'Last updated timestamp (ISO 8601)', | ||
| optional: true, | ||
| }, | ||
| dataVariables: { | ||
| type: 'array', | ||
| description: 'Template data variable names', | ||
| items: { type: 'string' }, | ||
| }, | ||
| }, | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.