diff --git a/apps/sim/tools/presend/email_verify.ts b/apps/sim/tools/presend/email_verify.ts new file mode 100644 index 00000000000..0a224ec92d8 --- /dev/null +++ b/apps/sim/tools/presend/email_verify.ts @@ -0,0 +1,96 @@ +import type { PresendEmailVerifyParams, PresendEmailVerifyResponse } from '@/tools/presend/types' +import type { ToolConfig } from '@/tools/types' + +export const emailVerifyTool: ToolConfig = { + id: 'presend_email_verify', + name: 'Presend Email Verify', + description: + 'Free, no-signup, no-key single-address email verification: syntax, MX record, disposable-domain, and role-account checks in one call.', + version: '1.0.0', + + params: { + email: { + type: 'string', + required: true, + visibility: 'user-or-llm', + description: 'The email address to verify', + }, + }, + + request: { + url: (params) => { + const url = new URL('https://presend.pages.dev/api/email-verify') + url.searchParams.append('email', params.email) + + return url.toString() + }, + method: 'GET', + headers: () => ({ + 'Content-Type': 'application/json', + }), + }, + + transformResponse: async (response: Response) => { + const data = await response.json() + + return { + success: true, + output: { + email: data?.email ?? '', + valid: data?.valid ?? null, + syntaxValid: data?.syntax_valid ?? false, + domain: data?.domain ?? '', + mxFound: data?.has_mx ?? null, + mxCount: data?.mx_count ?? 0, + disposable: data?.disposable ?? false, + roleAccount: data?.role_account ?? false, + reason: data?.reason ?? null, + }, + } + }, + + outputs: { + email: { + type: 'string', + description: 'The verified email address', + }, + valid: { + type: 'boolean', + description: + 'Whether the email address is valid overall. Null if it could not be checked (e.g. MX lookup failed); retry later', + nullable: true, + }, + syntaxValid: { + type: 'boolean', + description: 'Whether the email address is correctly formatted (RFC syntax)', + }, + domain: { + type: 'string', + description: 'The domain part of the email address', + }, + mxFound: { + type: 'boolean', + description: + "Whether the domain's MX records were found. Null if the MX lookup itself failed", + nullable: true, + }, + mxCount: { + type: 'number', + description: 'Number of MX records found for the domain', + }, + disposable: { + type: 'boolean', + description: 'Whether the email uses a disposable/temporary domain', + }, + roleAccount: { + type: 'boolean', + description: 'Whether the address is a role account (e.g. info@, support@)', + }, + reason: { + type: 'string', + description: + 'Why the address is not valid: invalid_syntax, no_mx_record, disposable_domain, or mx_lookup_failed. Null when the address is valid', + nullable: true, + }, + }, +} diff --git a/apps/sim/tools/presend/index.ts b/apps/sim/tools/presend/index.ts new file mode 100644 index 00000000000..0e828fb39eb --- /dev/null +++ b/apps/sim/tools/presend/index.ts @@ -0,0 +1,3 @@ +import { emailVerifyTool } from '@/tools/presend/email_verify' + +export const presendEmailVerifyTool = emailVerifyTool diff --git a/apps/sim/tools/presend/types.ts b/apps/sim/tools/presend/types.ts new file mode 100644 index 00000000000..1b3fd8406d9 --- /dev/null +++ b/apps/sim/tools/presend/types.ts @@ -0,0 +1,24 @@ +import type { ToolResponse } from '@/tools/types' + +/** Parameters for the Presend email verify tool. */ +export interface PresendEmailVerifyParams { + email: string +} + +/** Response from the Presend email verify tool. */ +export interface PresendEmailVerifyResponse extends ToolResponse { + output: { + email: string + /** `null` when the address could not be checked (e.g. MX lookup failed); retry later. */ + valid: boolean | null + syntaxValid: boolean + domain: string + /** `null` when the MX lookup itself failed. */ + mxFound: boolean | null + mxCount: number + disposable: boolean + roleAccount: boolean + /** One of `invalid_syntax`, `no_mx_record`, `disposable_domain`, `mx_lookup_failed`, or `null` when valid. */ + reason: string | null + } +} diff --git a/apps/sim/tools/registry.ts b/apps/sim/tools/registry.ts index 94e15cdad25..1e0f0cd58e5 100644 --- a/apps/sim/tools/registry.ts +++ b/apps/sim/tools/registry.ts @@ -4266,6 +4266,7 @@ import { posthogUpdatePropertyDefinitionTool, posthogUpdateSurveyTool, } from '@/tools/posthog' +import { presendEmailVerifyTool } from '@/tools/presend' import { powerbiExecuteQueryTool, powerbiGetDatasetTool, @@ -11909,6 +11910,7 @@ export const tools: Record = { hunter_email_verifier: hunterEmailVerifierTool, hunter_companies_find: hunterCompaniesFindTool, hunter_email_count: hunterEmailCountTool, + presend_email_verify: presendEmailVerifyTool, prospeo_account_information: prospeoAccountInformationTool, prospeo_enrich_person: prospeoEnrichPersonTool, prospeo_enrich_company: prospeoEnrichCompanyTool,