Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(data-warehouse): add Help Scout source (#78839)

Tom Owers376bdcd73b03
diff --git a/frontend/src/lib/integrations/integrationsLogic.ts b/frontend/src/lib/integrations/integrationsLogic.ts
index c6d95c1e10f7..30d8933c2550 100644
--- a/frontend/src/lib/integrations/integrationsLogic.ts
+++ b/frontend/src/lib/integrations/integrationsLogic.ts
@@ -91,6 +91,7 @@ export interface integrationsLogicValues {
| 'google-pubsub'
| 'google-search-console'
| 'google-sheets'
+ | 'helpscout'
| 'hubspot'
| 'instagram'
| 'intercom'
@@ -185,6 +186,7 @@ export interface integrationsLogicActions {
| 'google-pubsub'
| 'google-search-console'
| 'google-sheets'
+ | 'helpscout'
| 'hubspot'
| 'instagram'
| 'intercom'
@@ -328,6 +330,7 @@ export interface integrationsLogicActions {
| 'google-pubsub'
| 'google-search-console'
| 'google-sheets'
+ | 'helpscout'
| 'hubspot'
| 'instagram'
| 'intercom'
@@ -390,6 +393,7 @@ export interface integrationsLogicActions {
| 'google-pubsub'
| 'google-search-console'
| 'google-sheets'
+ | 'helpscout'
| 'hubspot'
| 'instagram'
| 'intercom'
@@ -446,6 +450,7 @@ export interface integrationsLogicActions {
| 'google-pubsub'
| 'google-search-console'
| 'google-sheets'
+ | 'helpscout'
| 'hubspot'
| 'instagram'
| 'intercom'
@@ -509,6 +514,7 @@ export interface integrationsLogicActions {
| 'google-pubsub'
| 'google-search-console'
| 'google-sheets'
+ | 'helpscout'
| 'hubspot'
| 'instagram'
| 'intercom'
@@ -557,6 +563,7 @@ export interface integrationsLogicActions {
| 'google-pubsub'
| 'google-search-console'
| 'google-sheets'
+ | 'helpscout'
| 'hubspot'
| 'instagram'
| 'intercom'
@@ -630,6 +637,7 @@ export interface integrationsLogicMeta {
| 'google-pubsub'
| 'google-search-console'
| 'google-sheets'
+ | 'helpscout'
| 'hubspot'
| 'instagram'
| 'intercom'
diff --git a/frontend/src/lib/integrations/utils.ts b/frontend/src/lib/integrations/utils.ts
index 2391ba8bd209..147699e96954 100644
--- a/frontend/src/lib/integrations/utils.ts
+++ b/frontend/src/lib/integrations/utils.ts
@@ -19,6 +19,7 @@ import IconGoogleSearchConsole from 'public/services/google-search-console.svg'
import IconGoogleSheets from 'public/services/google-sheets.svg'
import IconGoogleAnalytics from 'public/services/google_analytics.png'
import IconGoogleCalendar from 'public/services/google_calendar.png'
+import IconHelpScout from 'public/services/helpscout.png'
import IconHubspot from 'public/services/hubspot.png'
import IconInstagram from 'public/services/instagram.png'
import IconIntercom from 'public/services/intercom.png'
@@ -84,6 +85,7 @@ export const ICONS: Record<IntegrationKind, any> = {
snapchat: IconSnapchat,
stripe: IconStripe,
intercom: IconIntercom,
+ helpscout: IconHelpScout,
'linkedin-ads': IconLinkedIn,
email: IconMailjet,
linear: IconLinear,
@@ -151,6 +153,8 @@ export const getIntegrationNameFromKind = (kind: string): string => {
return 'email'
case 'github':
return 'GitHub'
+ case 'helpscout':
+ return 'Help Scout'
case 'firebase':
return 'Firebase'
case 'apns':
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json
index b3719d6ef412..76c1262368b0 100644
--- a/frontend/src/queries/schema.json
+++ b/frontend/src/queries/schema.json
@@ -30981,6 +30981,7 @@
"linear",
"github",
"gitlab",
+ "helpscout",
"meta-ads",
"instagram",
"clickup",
diff --git a/frontend/src/scenes/settings/organization/organizationIntegrationsLogic.ts b/frontend/src/scenes/settings/organization/organizationIntegrationsLogic.ts
index 4a747c5510ea..b6e73ee2e112 100644
--- a/frontend/src/scenes/settings/organization/organizationIntegrationsLogic.ts
+++ b/frontend/src/scenes/settings/organization/organizationIntegrationsLogic.ts
@@ -37,6 +37,7 @@ export interface organizationIntegrationsLogicValues {
| 'google-pubsub'
| 'google-search-console'
| 'google-sheets'
+ | 'helpscout'
| 'hubspot'
| 'instagram'
| 'intercom'
@@ -113,6 +114,7 @@ export interface organizationIntegrationsLogicActions {
| 'google-pubsub'
| 'google-search-console'
| 'google-sheets'
+ | 'helpscout'
| 'hubspot'
| 'instagram'
| 'intercom'
@@ -171,6 +173,7 @@ export interface organizationIntegrationsLogicActions {
| 'google-pubsub'
| 'google-search-console'
| 'google-sheets'
+ | 'helpscout'
| 'hubspot'
| 'instagram'
| 'intercom'
@@ -227,6 +230,7 @@ export interface organizationIntegrationsLogicMeta {
| 'google-pubsub'
| 'google-search-console'
| 'google-sheets'
+ | 'helpscout'
| 'hubspot'
| 'instagram'
| 'intercom'
diff --git a/frontend/src/types.ts b/frontend/src/types.ts
index cd2b3ba7ef5c..7389b097abb2 100644
--- a/frontend/src/types.ts
+++ b/frontend/src/types.ts
@@ -5586,6 +5586,7 @@ export const INTEGRATION_KINDS = [
'linear',
'github',
'gitlab',
+ 'helpscout',
'meta-ads',
'instagram',
'clickup',
diff --git a/posthog/models/integration/model.py b/posthog/models/integration/model.py
index 71d52c660575..12ec04ab44d5 100644
--- a/posthog/models/integration/model.py
+++ b/posthog/models/integration/model.py
@@ -149,6 +149,7 @@ class Integration(models.Model):
GOOGLE_PUBSUB = "google-pubsub"
GOOGLE_SEARCH_CONSOLE = "google-search-console"
GOOGLE_SHEETS = "google-sheets"
+ HELPSCOUT = "helpscout"
HUBSPOT = "hubspot"
INSTAGRAM = "instagram"
INTERCOM = "intercom"
diff --git a/posthog/models/integration/oauth.py b/posthog/models/integration/oauth.py
index 150fd6ccab10..5a06cf3c48f7 100644
--- a/posthog/models/integration/oauth.py
+++ b/posthog/models/integration/oauth.py
@@ -246,6 +246,7 @@ class OauthIntegration:
"meta-ads",
"instagram",
"intercom",
+ "helpscout",
"linear",
"clickup",
"jira",
@@ -565,6 +566,23 @@ class OauthIntegration:
id_path="id",
name_path="email",
)
+ elif kind == "helpscout":
+ if not settings.HELPSCOUT_APP_CLIENT_ID or not settings.HELPSCOUT_APP_CLIENT_SECRET:
+ raise NotImplementedError("Help Scout app not configured")
+
+ return OauthConfig(
+ authorize_url="https://secure.helpscout.net/authentication/authorizeClientApplication",
+ token_url="https://api.helpscout.net/v2/oauth2/token",
+ token_info_url="https://api.helpscout.net/v2/users/me",
+ client_id=settings.HELPSCOUT_APP_CLIENT_ID,
+ client_secret=settings.HELPSCOUT_APP_CLIENT_SECRET,
+ # Help Scout grants the authorizing user's full Mailbox API access and takes no
+ # scope parameter on the authorize URL.
+ scope="",
+ id_path="id",
+ name_path="email",
+ token_info_config_fields=["id", "email"],
+ )
elif kind == "linear":
if not settings.LINEAR_APP_CLIENT_ID or not settings.LINEAR_APP_CLIENT_SECRET:
raise NotImplementedError("Linear app not configured")
diff --git a/posthog/schema_enums.py b/posthog/schema_enums.py
index 073ee7fdb71a..3e229a5658ee 100644
--- a/posthog/schema_enums.py
+++ b/posthog/schema_enums.py
@@ -3049,6 +3049,7 @@ class IntegrationKind(StrEnum):
LINEAR = "linear"
GITHUB = "github"
GITLAB = "gitlab"
+ HELPSCOUT = "helpscout"
META_ADS = "meta-ads"
INSTAGRAM = "instagram"
CLICKUP = "clickup"
diff --git a/posthog/settings/integrations.py b/posthog/settings/integrations.py
index 0e794a1855ed..db7f32ba6deb 100644
--- a/posthog/settings/integrations.py
+++ b/posthog/settings/integrations.py
@@ -51,6 +51,9 @@ SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = get_from_env("SOCIAL_AUTH_GOOGLE_OAUTH2_SECRE
LINEAR_APP_CLIENT_ID = get_from_env("LINEAR_APP_CLIENT_ID", "")
LINEAR_APP_CLIENT_SECRET = get_from_env("LINEAR_APP_CLIENT_SECRET", "")
+HELPSCOUT_APP_CLIENT_ID = get_from_env("HELPSCOUT_APP_CLIENT_ID", "")
+HELPSCOUT_APP_CLIENT_SECRET = get_from_env("HELPSCOUT_APP_CLIENT_SECRET", "")
+
GITHUB_APP_CLIENT_ID = get_from_env("GITHUB_APP_CLIENT_ID", "")
GITHUB_APP_PRIVATE_KEY = get_from_env("GITHUB_APP_PRIVATE_KEY", "")
# OAuth *secret* for the same GitHub App as above - generated in the App's settings
diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.ts
index 33c7a0830597..bf680ce1fe11 100644
--- a/products/dashboards/frontend/generated/api.schemas.ts
+++ b/products/dashboards/frontend/generated/api.schemas.ts
@@ -5177,6 +5177,7 @@ export const IntegrationKindApi = {
Linear: 'linear',
Github: 'github',
Gitlab: 'gitlab',
+ Helpscout: 'helpscout',
MetaAds: 'meta-ads',
Instagram: 'instagram',
Clickup: 'clickup',
diff --git a/products/integrations/frontend/generated/api.schemas.ts b/products/integrations/frontend/generated/api.schemas.ts
index 29778f0c9caf..1eeca929590e 100644
--- a/products/integrations/frontend/generated/api.schemas.ts
+++ b/products/integrations/frontend/generated/api.schemas.ts
@@ -174,6 +174,7 @@ export interface RoleLookupResponseApi {
* * `google-pubsub` - Google Pubsub
* * `google-search-console` - Google Search Console
* * `google-sheets` - Google Sheets
+ * * `helpscout` - Helpscout
* * `hubspot` - Hubspot
* * `instagram` - Instagram
* * `intercom` - Intercom
@@ -225,6 +226,7 @@ export const IntegrationKindEnumApi = {
GooglePubsub: 'google-pubsub',
GoogleSearchConsole: 'google-search-console',
GoogleSheets: 'google-sheets',
+ Helpscout: 'helpscout',
Hubspot: 'hubspot',
Instagram: 'instagram',
Intercom: 'intercom',
@@ -551,6 +553,7 @@ export interface IntegrationAccessRequestApi {
* * `google-pubsub` - Google Pubsub
* * `google-search-console` - Google Search Console
* * `google-sheets` - Google Sheets
+ * * `helpscout` - Helpscout
* * `hubspot` - Hubspot
* * `instagram` - Instagram
* * `intercom` - Intercom
@@ -714,6 +717,7 @@ export type IntegrationsListParams = {
* * `google-pubsub` - Google Pubsub
* * `google-search-console` - Google Search Console
* * `google-sheets` - Google Sheets
+ * * `helpscout` - Helpscout
* * `hubspot` - Hubspot
* * `instagram` - Instagram
* * `intercom` - Intercom
@@ -776,6 +780,7 @@ export const IntegrationsListKind = {
GooglePubsub: 'google-pubsub',
GoogleSearchConsole: 'google-search-console',
GoogleSheets: 'google-sheets',
+ Helpscout: 'helpscout',
Hubspot: 'hubspot',
Instagram: 'instagram',
Intercom: 'intercom',
diff --git a/products/integrations/frontend/generated/api.zod.ts b/products/integrations/frontend/generated/api.zod.ts
index 1a98db40eedb..9cde3904733e 100644
--- a/products/integrations/frontend/generated/api.zod.ts
+++ b/products/integrations/frontend/generated/api.zod.ts
@@ -85,6 +85,7 @@ export const IntegrationsCreateBody = /* @__PURE__ */ zod
'google-pubsub',
'google-search-console',
'google-sheets',
+ 'helpscout',
'hubspot',
'instagram',
'intercom',
@@ -111,7 +112,7 @@ export const IntegrationsCreateBody = /* @__PURE__ */ zod
'youtube-analytics',
])
.describe(
- '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-redshift` - Aws Redshift\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-calendar` - Google Calendar\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `instagram` - Instagram\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pardot` - Pardot\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `posthog` - Posthog\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel\n\* `youtube-analytics` - Youtube Analytics'
+ '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-redshift` - Aws Redshift\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-calendar` - Google Calendar\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `helpscout` - Helpscout\n\* `hubspot` - Hubspot\n\* `instagram` - Instagram\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pardot` - Pardot\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `posthog` - Posthog\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel\n\* `youtube-analytics` - Youtube Analytics'
),
config: zod.unknown().optional(),
})
@@ -144,6 +145,7 @@ export const IntegrationsEmailPartialUpdateBody = /* @__PURE__ */ zod
'google-pubsub',
'google-search-console',
'google-sheets',
+ 'helpscout',
'hubspot',
'instagram',
'intercom',
@@ -171,7 +173,7 @@ export const IntegrationsEmailPartialUpdateBody = /* @__PURE__ */ zod
])
.optional()
.describe(
- '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-redshift` - Aws Redshift\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-calendar` - Google Calendar\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `instagram` - Instagram\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pardot` - Pardot\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `posthog` - Posthog\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel\n\* `youtube-analytics` - Youtube Analytics'
+ '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-redshift` - Aws Redshift\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-calendar` - Google Calendar\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `helpscout` - Helpscout\n\* `hubspot` - Hubspot\n\* `instagram` - Instagram\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pardot` - Pardot\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `posthog` - Posthog\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel\n\* `youtube-analytics` - Youtube Analytics'
),
config: zod.unknown().optional(),
})
@@ -204,6 +206,7 @@ export const IntegrationsEmailVerifyCreateBody = /* @__PURE__ */ zod
'google-pubsub',
'google-search-console',
'google-sheets',
+ 'helpscout',
'hubspot',
'instagram',
'intercom',
@@ -230,7 +233,7 @@ export const IntegrationsEmailVerifyCreateBody = /* @__PURE__ */ zod
'youtube-analytics',
])
.describe(
- '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-redshift` - Aws Redshift\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-calendar` - Google Calendar\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `instagram` - Instagram\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pardot` - Pardot\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `posthog` - Posthog\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel\n\* `youtube-analytics` - Youtube Analytics'
+ '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-redshift` - Aws Redshift\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-calendar` - Google Calendar\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `helpscout` - Helpscout\n\* `hubspot` - Hubspot\n\* `instagram` - Instagram\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pardot` - Pardot\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `posthog` - Posthog\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel\n\* `youtube-analytics` - Youtube Analytics'
),
config: zod.unknown().optional(),
})
@@ -270,6 +273,7 @@ export const IntegrationsDomainConnectApplyUrlCreateBody = /* @__PURE__ */ zod
'google-pubsub',
'google-search-console',
'google-sheets',
+ 'helpscout',
'hubspot',
'instagram',
'intercom',
@@ -296,7 +300,7 @@ export const IntegrationsDomainConnectApplyUrlCreateBody = /* @__PURE__ */ zod
'youtube-analytics',
])
.describe(
- '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-redshift` - Aws Redshift\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-calendar` - Google Calendar\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `instagram` - Instagram\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pardot` - Pardot\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `posthog` - Posthog\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel\n\* `youtube-analytics` - Youtube Analytics'
+ '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-redshift` - Aws Redshift\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-calendar` - Google Calendar\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `helpscout` - Helpscout\n\* `hubspot` - Hubspot\n\* `instagram` - Instagram\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pardot` - Pardot\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `posthog` - Posthog\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel\n\* `youtube-analytics` - Youtube Analytics'
),
config: zod.unknown().optional(),
})
@@ -383,6 +387,7 @@ export const IntegrationsRequestAccessCreateBody = /* @__PURE__ */ zod.object({
'google-pubsub',
'google-search-console',
'google-sheets',
+ 'helpscout',
'hubspot',
'instagram',
'intercom',
@@ -409,10 +414,10 @@ export const IntegrationsRequestAccessCreateBody = /* @__PURE__ */ zod.object({
'youtube-analytics',
])
.describe(
- '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-redshift` - Aws Redshift\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-calendar` - Google Calendar\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `instagram` - Instagram\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pardot` - Pardot\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `posthog` - Posthog\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel\n\* `youtube-analytics` - Youtube Analytics'
+ '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-redshift` - Aws Redshift\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-calendar` - Google Calendar\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `helpscout` - Helpscout\n\* `hubspot` - Hubspot\n\* `instagram` - Instagram\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pardot` - Pardot\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `posthog` - Posthog\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel\n\* `youtube-analytics` - Youtube Analytics'
)
.describe(
- "The kind of integration the member is requesting be connected (e.g. 'slack', 'github').\n\n\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-redshift` - Aws Redshift\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-calendar` - Google Calendar\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `instagram` - Instagram\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pardot` - Pardot\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `posthog` - Posthog\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel\n\* `youtube-analytics` - Youtube Analytics"
+ "The kind of integration the member is requesting be connected (e.g. 'slack', 'github').\n\n\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-redshift` - Aws Redshift\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-calendar` - Google Calendar\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `helpscout` - Helpscout\n\* `hubspot` - Hubspot\n\* `instagram` - Instagram\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pardot` - Pardot\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `posthog` - Posthog\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel\n\* `youtube-analytics` - Youtube Analytics"
),
reason: zod
.string()
diff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.ts
index bdaa607727a7..dfa375086e75 100644
--- a/products/product_analytics/frontend/generated/api.schemas.ts
+++ b/products/product_analytics/frontend/generated/api.schemas.ts
@@ -4171,6 +4171,7 @@ export const IntegrationKindApi = {
Linear: 'linear',
Github: 'github',
Gitlab: 'gitlab',
+ Helpscout: 'helpscout',
MetaAds: 'meta-ads',
Instagram: 'instagram',
Clickup: 'clickup',
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md b/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md
index e2a409a4461c..1676613735f1 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md
@@ -347,6 +347,7 @@ the row lists both.
| height | HTTP | requests | ✅ |
| helicone | HTTP | requests | ✅ |
| hellobaton | HTTP | requests | ✅ |
+| helpscout | HTTP | requests + `rest_source.RESTClient` | ✅ |
| heroku | HTTP | requests | ✅ |
| hetzner | HTTP | requests | ✅ |
| hex | HTTP | requests + `rest_source.RESTClient` | ✅ |
@@ -1105,7 +1106,6 @@ doesn't conflict with concurrent PRs.
- harvey
- healthie
- heap
-- helpscout
- hetzner
- heygen
- hibob
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/helpscout.py b/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/helpscout.py
index f49387b74d98..4f02bb12edcd 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/helpscout.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/helpscout.py
@@ -6,4 +6,4 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common imp
@config.config
class HelpScoutSourceConfig(config.Config):
- pass
+ helpscout_integration_id: int = config.value(converter=config.str_to_int)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/helpscout/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/helpscout/canonical_descriptions.py
new file mode 100644
index 000000000000..d4bce5146de3
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/helpscout/canonical_descriptions.py
@@ -0,0 +1,105 @@
+"""Canonical, documentation-sourced descriptions for Help Scout endpoints and columns.
+
+Sourced from the official Help Scout Mailbox API 2.0 reference
+(https://developer.helpscout.com/mailbox-api/). Keyed by the endpoint names in `settings.py`
+`HELP_SCOUT_ENDPOINTS`, which match the `ExternalDataSchema.name` of a synced Help Scout table.
+Columns absent here fall back to LLM enrichment.
+"""
+
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (
+ CanonicalDescriptions,
+)
+
+CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
+ "conversations": {
+ "description": "A single support conversation (email, chat, or phone) within a mailbox.",
+ "docs_url": "https://developer.helpscout.com/mailbox-api/endpoints/conversations/list/",
+ "columns": {
+ "id": "Unique identifier for the conversation.",
+ "number": "Conversation number, unique within the account and shown in the Help Scout UI.",
+ "type": "Conversation type: email, chat, or phone.",
+ "status": "Conversation status: active, pending, closed, or spam.",
+ "state": "Conversation state: draft, published, or deleted.",
+ "subject": "Conversation subject line.",
+ "mailboxId": "ID of the mailbox the conversation belongs to.",
+ "createdAt": "Time the conversation was created, in ISO 8601 format.",
+ "closedAt": "Time the conversation was closed, in ISO 8601 format.",
+ "userUpdatedAt": "Time a user last updated the conversation, in ISO 8601 format.",
+ },
+ },
+ "threads": {
+ "description": "A single message or note within a conversation.",
+ "docs_url": "https://developer.helpscout.com/mailbox-api/endpoints/conversations/threads/list/",
+ "columns": {
+ "id": "Unique identifier for the thread, unique within its conversation.",
+ "conversation_id": "ID of the conversation this thread belongs to.",
+ "type": "Thread type, e.g. customer, message, note, or chat.",
+ "status": "Thread status at the time it was created.",
+ "state": "Thread state: draft, published, or deleted.",
+ "body": "Thread body content.",
+ "createdAt": "Time the thread was created, in ISO 8601 format.",
+ },
+ },
+ "customers": {
+ "description": "A customer who has contacted or been added to your Help Scout account.",
+ "docs_url": "https://developer.helpscout.com/mailbox-api/endpoints/customers/list/",
+ "columns": {
+ "id": "Unique identifier for the customer.",
+ "firstName": "Customer's first name.",
+ "lastName": "Customer's last name.",
+ "photoUrl": "URL of the customer's photo.",
+ "createdAt": "Time the customer was created, in ISO 8601 format.",
+ "modifiedAt": "Time the customer was last modified, in ISO 8601 format.",
+ },
+ },
+ "mailboxes": {
+ "description": "A Help Scout mailbox (inbox) that conversations are organized under.",
+ "docs_url": "https://developer.helpscout.com/mailbox-api/endpoints/inboxes/list/",
+ "columns": {
+ "id": "Unique identifier for the mailbox.",
+ "name": "Mailbox display name.",
+ "slug": "URL-friendly identifier for the mailbox.",
+ "email": "Email address associated with the mailbox.",
+ "createdAt": "Time the mailbox was created, in ISO 8601 format.",
+ "updatedAt": "Time the mailbox was last updated, in ISO 8601 format.",
+ },
+ },
+ "users": {
+ "description": "A Help Scout user (agent) who can be assigned conversations.",
+ "docs_url": "https://developer.helpscout.com/mailbox-api/endpoints/users/list/",
+ "columns": {
+ "id": "Unique identifier for the user.",
+ "firstName": "User's first name.",
+ "lastName": "User's last name.",
+ "email": "User's email address.",
+ "role": "User's role, e.g. owner, admin, or user.",
+ "type": "User type.",
+ "createdAt": "Time the user was created, in ISO 8601 format.",
+ "updatedAt": "Time the user was last updated, in ISO 8601 format.",
+ },
+ },
+ "tags": {
+ "description": "A tag used to categorize conversations across all mailboxes.",
+ "docs_url": "https://developer.helpscout.com/mailbox-api/endpoints/tags/list/",
+ "columns": {
+ "id": "Unique identifier for the tag.",
+ "name": "Tag display name as shown in the app.",
+ "slug": "URL-friendly identifier for the tag.",
+ "ticketCount": "Number of conversations tagged with this tag.",
+ "createdAt": "Time the tag was created, in ISO 8601 format.",
+ },
+ },
+ "workflows": {
+ "description": "A manual or automatic workflow that runs actions on conversations.",
+ "docs_url": "https://developer.helpscout.com/mailbox-api/endpoints/workflows/list/",
+ "columns": {
+ "id": "Unique identifier for the workflow.",
+ "mailboxId": "ID of the mailbox the workflow applies to.",
+ "type": "Workflow type: manual or automatic.",
+ "status": "Workflow status: active, inactive, or invalid.",
+ "name": "Workflow display name.",
+ "createdAt": "Time the workflow was created, in ISO 8601 format.",
+ "modifiedAt": "Time the workflow was last modified, in ISO 8601 format.",
+ },
+ },
+}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/helpscout/helpscout.py b/products/warehouse_sources/backend/temporal/data_imports/sources/helpscout/helpscout.py
new file mode 100644
index 000000000000..16a349b0aacd
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/helpscout/helpscout.py
@@ -0,0 +1,269 @@
+from datetime import UTC, date, datetime
+from typing import Any, Optional, cast
+
+from posthog.dataclasses import frozen
+
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.http import make_tracked_session
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source import (
+ RESTAPIConfig,
+ rest_api_resource,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.auth import BearerTokenAuth
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.fanout import (
+ build_dependent_resource,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.paginators import (
+ JSONResponsePaginator,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.resource import Resource
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.typing import ClientConfig
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.source_helpers import validate_via_probe
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceResponse
+from products.warehouse_sources.backend.temporal.data_imports.sources.helpscout.settings import (
+ HELP_SCOUT_API_BASE,
+ HELP_SCOUT_ENDPOINTS,
+ HelpScoutEndpointConfig,
+)
+
+# Help Scout paginates every list endpoint via the HAL `_links.next.href` URL, which is
+# self-contained (carries its own query string), so it's all we ever need to persist or send.
+_NEXT_URL_PATH = "_links.next.href"
+
+_AUTH_ERROR = (
+ "Help Scout authentication failed. Check your client ID and client secret, and confirm the "
+ "app has an active user invited to your Help Scout account."
+)
+
+
+@frozen
+class HelpScoutResumeConfig:
+ # Top-level endpoints: the HAL next-page URL.
+ next_url: str = ""
+ # Fan-out (threads): the framework's dependent-resource resume state
+ # (`{"completed": [...], "current": ..., "child_state": ...}`).
+ fanout_state: Optional[dict[str, Any]] = None
+
+
+def _client_config(access_token: str) -> ClientConfig:
+ return {
+ "base_url": HELP_SCOUT_API_BASE,
+ "auth": BearerTokenAuth(token=access_token),
+ "paginator": JSONResponsePaginator(next_url_path=_NEXT_URL_PATH),
+ # Pagination follows absolute `_links.next.href` URLs straight out of the response body,
+ # and a resumed sync replays one that was persisted earlier. Pin every outgoing request to
+ # the Help Scout API host and reject redirects, so a spoofed or tampered link can't replay
+ # the bearer token against another origin (SSRF / credential exfiltration).
+ # `allowed_hosts=[]` means "the base_url host only".
+ "allowed_hosts": [],
+ "allow_redirects": False,
+ # capture=False: conversation subjects and thread bodies are free-text, customer-authored
+ # support content the name-based HTTP sample scrubbers aren't guaranteed to catch, same as
+ # the other PII-heavy sources.
+ "capture": False,
+ }
+
+
+def _format_since(value: Any) -> str:
+ if isinstance(value, datetime):
+ utc = value.replace(tzinfo=UTC) if value.tzinfo is None else value.astimezone(UTC)
+ return utc.strftime("%Y-%m-%dT%H:%M:%SZ")
+ if isinstance(value, date):
+ return datetime.combine(value, datetime.min.time(), tzinfo=UTC).strftime("%Y-%m-%dT%H:%M:%SZ")
+ return str(value)
+
+
+def _list_params(
+ config: HelpScoutEndpointConfig,
+ should_use_incremental_field: bool,
+ incremental_field: Optional[str],
+ db_incremental_field_last_value: Any,
+) -> dict[str, Any]:
+ if not config.supports_sort:
+ return {}
+
+ if should_use_incremental_field and config.updated_since_param and db_incremental_field_last_value is not None:
+ sort_field = incremental_field or config.default_incremental_field or "modifiedAt"
+ return {
+ config.updated_since_param: _format_since(db_incremental_field_last_value),
+ "sortField": sort_field,
+ "sortOrder": "asc",
+ }
+
+ # Full refresh: an explicit stable sort avoids page-boundary skips/duplicates from rows
+ # created while the sync is paginating (Help Scout doesn't document its default sort order).
+ return {"sortField": config.partition_key or "createdAt", "sortOrder": "asc"}
+
+
+def _top_level_resource(
+ client_config: ClientConfig,
+ config: HelpScoutEndpointConfig,
+ team_id: int,
+ job_id: str,
+ resumable_source_manager: ResumableSourceManager[HelpScoutResumeConfig],
+ should_use_incremental_field: bool,
+ incremental_field: Optional[str],
+ db_incremental_field_last_value: Any,
+) -> Resource:
+ rest_config: RESTAPIConfig = {
+ "client": client_config,
+ "resources": [
+ {
+ "name": config.name,
+ "endpoint": {
+ "path": config.path,
+ "params": _list_params(
+ config, should_use_incremental_field, incremental_field, db_incremental_field_last_value
+ ),
+ "data_selector": f"_embedded.{config.embedded_key}",
+ },
+ }
+ ],
+ }
+
+ initial_paginator_state: Optional[dict[str, Any]] = None
+ if resumable_source_manager.can_resume():
+ resume = resumable_source_manager.load_state()
+ if resume is not None and resume.next_url:
+ initial_paginator_state = {"next_url": resume.next_url}
+
+ def save_checkpoint(state: Optional[dict[str, Any]]) -> None:
+ # Save AFTER a page is yielded so a crash re-yields the last page (merge dedupes on the
+ # primary key) rather than skipping it; persist only while a next page remains.
+ if state and state.get("next_url"):
+ resumable_source_manager.save_state(HelpScoutResumeConfig(next_url=state["next_url"]))
+
+ return rest_api_resource(
+ rest_config,
+ team_id,
+ job_id,
+ db_incremental_field_last_value if should_use_incremental_field else None,
+ resume_hook=save_checkpoint,
+ initial_paginator_state=initial_paginator_state,
+ )
+
+
+def _threads_resource(
+ client_config: ClientConfig,
+ team_id: int,
+ job_id: str,
+ resumable_source_manager: ResumableSourceManager[HelpScoutResumeConfig],
+) -> Resource:
+ threads_config = HELP_SCOUT_ENDPOINTS["threads"]
+ assert threads_config.fanout is not None
+
+ initial_paginator_state: Optional[dict[str, Any]] = None
+ if resumable_source_manager.can_resume():
+ resume = resumable_source_manager.load_state()
+ if resume is not None and resume.fanout_state:
+ initial_paginator_state = resume.fanout_state
+
+ def save_checkpoint(state: Optional[dict[str, Any]]) -> None:
+ if state is not None:
+ resumable_source_manager.save_state(HelpScoutResumeConfig(fanout_state=state))
+
+ return cast(
+ Resource,
+ build_dependent_resource(
+ endpoint_configs=HELP_SCOUT_ENDPOINTS,
+ child_endpoint="threads",
+ fanout=threads_config.fanout,
+ client_config=client_config,
+ path_format_values={},
+ team_id=team_id,
+ job_id=job_id,
+ db_incremental_field_last_value=None,
+ # Help Scout list endpoints take no page-size param — page size is fixed server-side.
+ page_size_param=None,
+ resume_hook=save_checkpoint,
+ initial_paginator_state=initial_paginator_state,
+ parent_endpoint_extra={
+ "paginator": JSONResponsePaginator(next_url_path=_NEXT_URL_PATH),
+ "data_selector": "_embedded.conversations",
+ },
+ child_endpoint_extra={
+ "paginator": JSONResponsePaginator(next_url_path=_NEXT_URL_PATH),
+ "data_selector": "_embedded.threads",
+ },
+ ),
+ )
+
+
+def helpscout_source(
+ access_token: str,
+ endpoint: str,
+ team_id: int,
+ job_id: str,
+ resumable_source_manager: ResumableSourceManager[HelpScoutResumeConfig],
+ should_use_incremental_field: bool = False,
+ incremental_field: Optional[str] = None,
+ db_incremental_field_last_value: Optional[Any] = None,
+) -> SourceResponse:
+ config = HELP_SCOUT_ENDPOINTS[endpoint]
+ client_config = _client_config(access_token)
+
+ if config.fanout:
+ resource: Resource = _threads_resource(client_config, team_id, job_id, resumable_source_manager)
+ else:
+ resource = _top_level_resource(
+ client_config,
+ config,
+ team_id,
+ job_id,
+ resumable_source_manager,
+ should_use_incremental_field,
+ incremental_field,
+ db_incremental_field_last_value,
+ )
+
+ return SourceResponse(
+ name=endpoint,
+ items=lambda: resource,
+ primary_keys=config.primary_key,
+ partition_count=1 if config.partition_key else None,
+ partition_size=1 if config.partition_key else None,
+ partition_mode="datetime" if config.partition_key else None,
+ partition_format="week" if config.partition_key else None,
+ partition_keys=[config.partition_key] if config.partition_key else None,
+ sort_mode="asc",
+ )
+
+
+def validate_credentials(
+ access_token: str,
+ schema_name: Optional[str] = None,
+) -> tuple[bool, str | None]:
+ auth = BearerTokenAuth(token=access_token)
+
+ if schema_name is None:
+ # Help Scout tokens carry the authorizing user's full Mailbox API access, so there are no
+ # per-resource scopes to probe. /users/me is the cheapest call that proves the token works.
+ # capture=False: same free-text-content rationale as `_client_config` above.
+ ok, status = validate_via_probe(
+ lambda: make_tracked_session(redact_values=(access_token,), capture=False),
+ f"{HELP_SCOUT_API_BASE}/users/me",
+ auth=auth,
+ )
+ if ok:
+ return True, None
+ return False, _AUTH_ERROR
+
+ config = HELP_SCOUT_ENDPOINTS.get(schema_name)
+ if config is None:
+ return False, f"Unknown Help Scout table '{schema_name}'"
+ # threads has no bare list endpoint (it's always scoped to a conversation); probe
+ # conversations instead, since that's the parent it fans out from.
+ probe_path = HELP_SCOUT_ENDPOINTS["conversations"].path if config.fanout else config.path
+
+ # capture=False: same free-text-content rationale as `_client_config` above — the probed
+ # endpoint can be `conversations`, whose responses carry customer-authored subjects.
+ ok, status = validate_via_probe(
+ lambda: make_tracked_session(redact_values=(access_token,), capture=False),
+ f"{HELP_SCOUT_API_BASE}{probe_path}",
+ auth=auth,
+ )
+ if ok:
+ return True, None
+ if status == 401:
+ return False, _AUTH_ERROR
+ return False, f"Help Scout API returned an unexpected status ({status}) while checking access to {schema_name}."
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/helpscout/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/helpscout/settings.py
new file mode 100644
index 000000000000..62e541fb17ec
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/helpscout/settings.py
@@ -0,0 +1,99 @@
+"""Help Scout source settings and endpoint catalog."""
+
+from dataclasses import field
+from typing import Optional
+
+from posthog.dataclasses import frozen
+
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.fanout import (
+ DependentEndpointConfig,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.schema import incremental_field
+from products.warehouse_sources.backend.types import IncrementalField
+
+HELP_SCOUT_API_BASE = "https://api.helpscout.net/v2"
+
+
+@frozen
+class HelpScoutEndpointConfig:
+ name: str
+ path: str
+ # Key the rows live under inside the HAL `_embedded` object.
+ embedded_key: str
+ primary_key: list[str] = field(default_factory=lambda: ["id"])
+ incremental_fields: list[IncrementalField] = field(default_factory=list)
+ default_incremental_field: Optional[str] = None
+ # Server-side `modifiedSince` filter param name; None means full refresh only.
+ updated_since_param: Optional[str] = None
+ # Every Help Scout resource carries an immutable createdAt.
+ partition_key: Optional[str] = "createdAt"
+ # Only conversations/customers document a `sortField`/`sortOrder` param; other list
+ # endpoints don't accept one (and reject unknown params on some Help Scout API versions).
+ supports_sort: bool = False
+ # Structural requirement of `FanoutEndpointLike` (see common/rest_source/fanout.py); unused
+ # here since threads' fan-out passes `page_size_param=None` (Help Scout has no page-size param).
+ page_size: int = 50
+ fanout: Optional[DependentEndpointConfig] = None
+
+
+HELP_SCOUT_ENDPOINTS: dict[str, HelpScoutEndpointConfig] = {
+ "conversations": HelpScoutEndpointConfig(
+ name="conversations",
+ path="/conversations",
+ embedded_key="conversations",
+ incremental_fields=[incremental_field("modifiedAt")],
+ default_incremental_field="modifiedAt",
+ updated_since_param="modifiedSince",
+ supports_sort=True,
+ ),
+ "customers": HelpScoutEndpointConfig(
+ name="customers",
+ path="/customers",
+ embedded_key="customers",
+ incremental_fields=[incremental_field("modifiedAt")],
+ default_incremental_field="modifiedAt",
+ updated_since_param="modifiedSince",
+ supports_sort=True,
+ ),
+ "mailboxes": HelpScoutEndpointConfig(
+ name="mailboxes",
+ path="/mailboxes",
+ embedded_key="mailboxes",
+ ),
+ "users": HelpScoutEndpointConfig(
+ name="users",
+ path="/users",
+ embedded_key="users",
+ ),
+ "tags": HelpScoutEndpointConfig(
+ name="tags",
+ path="/tags",
+ embedded_key="tags",
+ ),
+ "workflows": HelpScoutEndpointConfig(
+ name="workflows",
+ path="/workflows",
+ embedded_key="workflows",
+ ),
+ "threads": HelpScoutEndpointConfig(
+ name="threads",
+ path="/conversations/{conversation_id}/threads",
+ embedded_key="threads",
+ # Thread ids are unique only within their conversation, so the parent id is part of the
+ # key to keep it unique across the whole table.
+ primary_key=["conversation_id", "id"],
+ fanout=DependentEndpointConfig(
+ parent_name="conversations",
+ resolve_param="conversation_id",
+ resolve_field="id",
+ include_from_parent=["id"],
+ parent_field_renames={"id": "conversation_id"},
+ ),
+ ),
+}
+
+ENDPOINTS = tuple(HELP_SCOUT_ENDPOINTS.keys())
+
+INCREMENTAL_FIELDS: dict[str, list[IncrementalField]] = {
+ name: config.incremental_fields for name, config in HELP_SCOUT_ENDPOINTS.items()
+}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/helpscout/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/helpscout/source.py
index 46ae90019915..0cdeb66b8170 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/helpscout/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/helpscout/source.py
@@ -1,33 +1,158 @@
-from typing import cast
+from typing import Optional, cast
from posthog.schema import (
DataWarehouseSourceCategory,
ExternalDataSourceType as SchemaExternalDataSourceType,
+ ReleaseStatus,
SourceConfig,
+ SourceFieldOauthConfig,
)
-from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import FieldType, SimpleSource
+from posthog.models.integration import Integration, OauthIntegration
+
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import FieldType, ResumableSource
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (
+ CanonicalDescriptions,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.mixins import OAuthMixin
from products.warehouse_sources.backend.temporal.data_imports.sources.common.registry import SourceRegistry
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.schema import (
+ SourceSchema,
+ build_endpoint_schemas,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceInputs, SourceResponse
from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.helpscout import (
HelpScoutSourceConfig,
)
+from products.warehouse_sources.backend.temporal.data_imports.sources.helpscout.helpscout import (
+ HelpScoutResumeConfig,
+ helpscout_source,
+ validate_credentials as validate_helpscout_credentials,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.helpscout.settings import (
+ ENDPOINTS,
+ INCREMENTAL_FIELDS,
+)
from products.warehouse_sources.backend.types import ExternalDataSourceType
@SourceRegistry.register
-class HelpScoutSource(SimpleSource[HelpScoutSourceConfig]):
+class HelpScoutSource(OAuthMixin, ResumableSource[HelpScoutSourceConfig, HelpScoutResumeConfig]):
+ supported_versions = ("v2",)
+ default_version = "v2"
+ api_docs_url = "https://developer.helpscout.com/mailbox-api/"
+
+ lists_tables_without_credentials = True # static endpoint catalog — safe for public docs
+
@property
def source_type(self) -> ExternalDataSourceType:
return ExternalDataSourceType.HELPSCOUT
+ def get_canonical_descriptions(self) -> CanonicalDescriptions:
+ from products.warehouse_sources.backend.temporal.data_imports.sources.helpscout.canonical_descriptions import (
+ CANONICAL_DESCRIPTIONS,
+ )
+
+ return CANONICAL_DESCRIPTIONS
+
+ def get_non_retryable_errors(self) -> dict[str, str | None]:
+ return {
+ # Permanent token-exchange failures (invalid_client, inactive user, …) carry the
+ # framework's stable marker; transient 429/5xx token errors don't.
+ "401 Client Error: Unauthorized for url: https://api.helpscout.net": "Help Scout authentication failed. Please reconnect your Help Scout account.",
+ # The linked OAuth integration was deleted while the source still references it.
+ # Retrying can never resolve this, so ask the user to reconnect.
+ "Integration not found": "The linked Help Scout integration no longer exists. Please reconnect your Help Scout account.",
+ # The Help Scout app isn't configured on this PostHog instance, so the source can't
+ # refresh its access token. Deterministic, so retrying never resolves it.
+ "Help Scout app not configured": "The Help Scout app is not configured on this PostHog instance. Please contact support.",
+ }
+
@property
def get_source_config(self) -> SourceConfig:
return SourceConfig(
name=SchemaExternalDataSourceType.HELP_SCOUT,
category=DataWarehouseSourceCategory.CUSTOMER_SUPPORT,
- keywords=["helpscout"],
+ keywords=["helpscout", "helpdesk"],
label="Help Scout",
+ caption="Sync your Help Scout conversations, customers, and mailboxes into the PostHog Data warehouse.",
iconPath="/static/services/helpscout.png",
- fields=cast(list[FieldType], []),
- unreleasedSource=True,
+ docsUrl="https://posthog.com/docs/cdp/sources/helpscout",
+ releaseStatus=ReleaseStatus.ALPHA,
+ fields=cast(
+ list[FieldType],
+ [
+ SourceFieldOauthConfig(
+ name="helpscout_integration_id",
+ label="Help Scout account",
+ required=True,
+ kind="helpscout",
+ ),
+ ],
+ ),
+ )
+
+ def _get_access_token(self, config: HelpScoutSourceConfig, team_id: int) -> str:
+ integration = self.get_oauth_integration(config.helpscout_integration_id, team_id)
+ # The lookup only scopes to the team, so a config pointing at some other provider's
+ # integration in the same team would otherwise send that provider's access token to the
+ # Help Scout API. Reject it before the token is read or refreshed.
+ if integration.kind != Integration.IntegrationKind.HELPSCOUT:
+ raise ValueError(f"Integration not found: {config.helpscout_integration_id}")
+
+ oauth_integration = OauthIntegration(integration)
+ if oauth_integration.access_token_expired():
+ oauth_integration.refresh_access_token()
+
+ if not integration.access_token:
+ raise ValueError("Help Scout access token not found")
+ return integration.access_token
+
+ def get_schemas(
+ self,
+ config: HelpScoutSourceConfig,
+ team_id: int,
+ with_counts: bool = False,
+ names: list[str] | None = None,
+ force_refresh: bool = False,
+ api_version: str | None = None,
+ ) -> list[SourceSchema]:
+ return build_endpoint_schemas(ENDPOINTS, INCREMENTAL_FIELDS, names)
+
+ def validate_credentials(
+ self,
+ config: HelpScoutSourceConfig,
+ team_id: int,
+ schema_name: Optional[str] = None,
+ api_version: str | None = None,
+ ) -> tuple[bool, str | None]:
+ try:
+ access_token = self._get_access_token(config, team_id)
+ return validate_helpscout_credentials(access_token, schema_name)
+ except Exception as e:
+ return False, str(e)
+
+ def get_resumable_source_manager(self, inputs: SourceInputs) -> ResumableSourceManager[HelpScoutResumeConfig]:
+ return ResumableSourceManager[HelpScoutResumeConfig](inputs, HelpScoutResumeConfig)
+
+ def source_for_pipeline(
+ self,
+ config: HelpScoutSourceConfig,
+ resumable_source_manager: ResumableSourceManager[HelpScoutResumeConfig],
+ inputs: SourceInputs,
+ ) -> SourceResponse:
+ access_token = self._get_access_token(config, inputs.team_id)
+
+ return helpscout_source(
+ access_token=access_token,
+ endpoint=inputs.schema_name,
+ team_id=inputs.team_id,
+ job_id=inputs.job_id,
+ resumable_source_manager=resumable_source_manager,
+ should_use_incremental_field=inputs.should_use_incremental_field,
+ incremental_field=inputs.incremental_field,
+ db_incremental_field_last_value=inputs.db_incremental_field_last_value
+ if inputs.should_use_incremental_field
+ else None,
)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/helpscout/tests/test_helpscout.py b/products/warehouse_sources/backend/temporal/data_imports/sources/helpscout/tests/test_helpscout.py
new file mode 100644
index 000000000000..7d9d9d8a582c
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/helpscout/tests/test_helpscout.py
@@ -0,0 +1,463 @@
+import json
+from typing import Any
+
+import pytest
+from unittest import mock
+
+import requests
+from requests import Response
+
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.auth import BearerTokenAuth
+from products.warehouse_sources.backend.temporal.data_imports.sources.helpscout.helpscout import (
+ HELP_SCOUT_API_BASE,
+ HelpScoutResumeConfig,
+ _client_config,
+ helpscout_source,
+ validate_credentials,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.helpscout.settings import (
+ ENDPOINTS,
+ HELP_SCOUT_ENDPOINTS,
+)
+
+# RESTClient builds its HTTP session via make_tracked_session in the rest_client module.
+CLIENT_SESSION_PATCH = "products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.rest_client.make_tracked_session"
+# OAuth2Auth mints its token through make_tracked_session in the rest_source auth module.
+AUTH_SESSION_PATCH = (
+ "products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.auth.make_tracked_session"
+)
+# validate_credentials builds its probe session via make_tracked_session in the helpscout module.
+HELPSCOUT_SESSION_PATCH = (
+ "products.warehouse_sources.backend.temporal.data_imports.sources.helpscout.helpscout.make_tracked_session"
+)
+# threads' fan-out is driven through the shared fanout helper's rest_api_resources call.
+FANOUT_RESOURCES_PATCH = (
+ "products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.fanout.rest_api_resources"
+)
+
+
+def _response(embedded_key: str, items: list[dict[str, Any]], next_url: str | None = None) -> Response:
+ body: dict[str, Any] = {"_embedded": {embedded_key: items}, "_links": {}}
+ if next_url:
+ body["_links"]["next"] = {"href": next_url}
+ resp = Response()
+ resp.status_code = 200
+ resp._content = json.dumps(body).encode()
+ resp.url = f"{HELP_SCOUT_API_BASE}/probe"
+ return resp
+
+
+def _bare_response(body: dict[str, Any]) -> Response:
+ resp = Response()
+ resp.status_code = 200
+ resp._content = json.dumps(body).encode()
+ resp.url = f"{HELP_SCOUT_API_BASE}/probe"
+ return resp
+
+
+def _error_response(status_code: int) -> Response:
+ resp = Response()
+ resp.status_code = status_code
+ resp._content = b"{}"
+ resp.url = f"{HELP_SCOUT_API_BASE}/conversations"
+ return resp
+
+
+def _manager(resume_state: HelpScoutResumeConfig | None = None) -> mock.MagicMock:
+ manager = mock.MagicMock()
+ manager.can_resume.return_value = resume_state is not None
+ manager.load_state.return_value = resume_state
+ return manager
+
+
+def _wire(session: mock.MagicMock, responses: list[Response]) -> tuple[list[str], list[dict[str, Any]]]:
+ """Wire a mock session and snapshot each request's url + params AT PREPARE TIME.
+
+ ``prepare_request`` is mocked, which bypasses the auth callable entirely — these tests exercise
+ pagination/fan-out/resume, not token minting (covered separately in TestValidateCredentials).
+ ``request.params`` is one dict mutated in place across pages, so snapshot a copy per request.
+ The stand-in prepared request carries the real URL string: the client host-checks
+ ``prepared.url`` before sending, and a bare MagicMock there would not be a URL at all.
+ """
+ session.headers = {}
+ url_snapshots: list[str] = []
+ param_snapshots: list[dict[str, Any]] = []
+
+ def _prepare(request: Any) -> mock.MagicMock:
+ url_snapshots.append(request.url)
+ param_snapshots.append(dict(request.params or {}))
+ prepared = mock.MagicMock()
+ prepared.url = request.url
+ return prepared
+
+ session.prepare_request.side_effect = _prepare
+ session.send.side_effect = responses
+ return url_snapshots, param_snapshots
+
+
+def _source(endpoint: str, manager: mock.MagicMock, **kwargs: Any):
+ return helpscout_source("token", endpoint, team_id=1, job_id="job-1", resumable_source_manager=manager, **kwargs)
+
+
+def _rows(source_response: Any) -> list[dict[str, Any]]:
+ return [row for page in source_response.items() for row in page]
+
+
+class TestAuth:
+ def test_client_config_sends_bearer_token(self) -> None:
+ # The token now comes from the Integration, so the source must not mint its own.
+ auth = _client_config("token")["auth"]
+ assert isinstance(auth, BearerTokenAuth)
+ assert auth.token == "token"
+
+ def test_client_config_pins_requests_to_the_api_host(self) -> None:
+ # Pagination follows `_links.next.href` out of the response body, so the client must
+ # refuse off-host URLs and redirects rather than replay the bearer token elsewhere.
+ config = _client_config("token")
+ assert config["allowed_hosts"] == []
+ assert config["allow_redirects"] is False
+
+ def test_client_config_excludes_requests_from_sample_capture(self) -> None:
+ # Conversation subjects and thread bodies are free-text, customer-authored support
+ # content, so responses must not land in HTTP sample capture.
+ assert _client_config("token")["capture"] is False
+
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_off_host_next_link_is_rejected(self, MockSession) -> None:
+ session = MockSession.return_value
+ _wire(
+ session,
+ [
+ _response("mailboxes", [{"id": 1}], next_url="https://evil.example.com/v2/mailboxes?page=2"),
+ _response("mailboxes", [{"id": 2}]),
+ ],
+ )
+
+ with pytest.raises(ValueError, match="evil.example.com"):
+ _rows(_source("mailboxes", _manager()))
+
+
+class TestTopLevelPagination:
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_paginates_via_hal_next_link(self, MockSession) -> None:
+ session = MockSession.return_value
+ next_url = f"{HELP_SCOUT_API_BASE}/mailboxes?page=2"
+ urls, _params = _wire(
+ session,
+ [
+ _response("mailboxes", [{"id": 1}, {"id": 2}], next_url=next_url),
+ _response("mailboxes", [{"id": 3}]),
+ ],
+ )
+
+ rows = _rows(_source("mailboxes", _manager()))
+
+ assert [r["id"] for r in rows] == [1, 2, 3]
+ assert urls[1] == next_url
+ manager_calls = session.send.call_count
+ assert manager_calls == 2
+
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_first_request_uses_endpoint_path_with_no_params(self, MockSession) -> None:
+ session = MockSession.return_value
+ urls, params = _wire(session, [_response("tags", [])])
+
+ _rows(_source("tags", _manager()))
+
+ assert urls[0] == f"{HELP_SCOUT_API_BASE}/tags"
+ assert params[0] == {}
+
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_resumes_from_saved_state(self, MockSession) -> None:
+ session = MockSession.return_value
+ resume_url = f"{HELP_SCOUT_API_BASE}/users?page=3"
+ urls, params = _wire(session, [_response("users", [{"id": 9}])])
+
+ manager = _manager(HelpScoutResumeConfig(next_url=resume_url))
+ _rows(_source("users", manager))
+
+ assert urls[0] == resume_url
+ assert params[0] == {}
+
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_saves_state_after_each_non_terminal_page(self, MockSession) -> None:
+ session = MockSession.return_value
+ next_url = f"{HELP_SCOUT_API_BASE}/workflows?page=2"
+ _wire(
+ session,
+ [
+ _response("workflows", [{"id": 1}], next_url=next_url),
+ _response("workflows", [{"id": 2}]),
+ ],
+ )
+
+ manager = _manager()
+ _rows(_source("workflows", manager))
+
+ manager.save_state.assert_called_once()
+ assert manager.save_state.call_args.args[0] == HelpScoutResumeConfig(next_url=next_url)
+
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_terminal_single_page_saves_no_state(self, MockSession) -> None:
+ session = MockSession.return_value
+ _wire(session, [_response("tags", [{"id": 1}])])
+
+ manager = _manager()
+ _rows(_source("tags", manager))
+
+ manager.save_state.assert_not_called()
+
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_missing_embedded_block_yields_nothing(self, MockSession) -> None:
+ # A 200 body without an `_embedded` block is a legitimate empty page, not an error.
+ session = MockSession.return_value
+ _wire(session, [_bare_response({"page": {"totalElements": 0}, "_links": {}})])
+
+ rows = _rows(_source("mailboxes", _manager()))
+
+ assert rows == []
+
+
+class TestIncrementalParams:
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_conversations_incremental_sends_modified_since_and_sort(self, MockSession) -> None:
+ session = MockSession.return_value
+ _, params = _wire(session, [_response("conversations", [])])
+
+ _rows(
+ _source(
+ "conversations",
+ _manager(),
+ should_use_incremental_field=True,
+ incremental_field="modifiedAt",
+ db_incremental_field_last_value="2024-01-01T00:00:00Z",
+ )
+ )
+
+ assert params[0]["modifiedSince"] == "2024-01-01T00:00:00Z"
+ assert params[0]["sortField"] == "modifiedAt"
+ assert params[0]["sortOrder"] == "asc"
+
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_conversations_full_refresh_sorts_on_created_at(self, MockSession) -> None:
+ session = MockSession.return_value
+ _, params = _wire(session, [_response("conversations", [])])
+
+ _rows(_source("conversations", _manager()))
+
+ assert "modifiedSince" not in params[0]
+ assert params[0]["sortField"] == "createdAt"
+ assert params[0]["sortOrder"] == "asc"
+
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_customers_incremental_sends_modified_since(self, MockSession) -> None:
+ session = MockSession.return_value
+ _, params = _wire(session, [_response("customers", [])])
+
+ _rows(
+ _source(
+ "customers",
+ _manager(),
+ should_use_incremental_field=True,
+ incremental_field="modifiedAt",
+ db_incremental_field_last_value="2024-06-01T00:00:00Z",
+ )
+ )
+
+ assert params[0]["modifiedSince"] == "2024-06-01T00:00:00Z"
+
+ @pytest.mark.parametrize("endpoint", ["mailboxes", "users", "tags", "workflows"])
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_endpoints_without_sort_support_send_no_extra_params(self, MockSession, endpoint) -> None:
+ session = MockSession.return_value
+ _, params = _wire(session, [_response(HELP_SCOUT_ENDPOINTS[endpoint].embedded_key, [])])
+
+ _rows(_source(endpoint, _manager()))
+
+ assert params[0] == {}
+
+
+class TestRetries:
+ @pytest.mark.parametrize("retryable_status", [429, 500, 503])
+ @mock.patch("tenacity.nap.time.sleep", return_value=None)
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_retryable_status_triggers_retry_then_succeeds(self, MockSession, _mock_sleep, retryable_status) -> None:
+ session = MockSession.return_value
+ _wire(session, [_error_response(retryable_status), _response("conversations", [{"id": 1}])])
+
+ rows = _rows(_source("conversations", _manager()))
+
+ assert [r["id"] for r in rows] == [1]
+ assert session.send.call_count == 2
+
+ @mock.patch("tenacity.nap.time.sleep", return_value=None)
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_non_retryable_4xx_raises_immediately(self, MockSession, _mock_sleep) -> None:
+ session = MockSession.return_value
+ _wire(session, [_error_response(403)])
+
+ with pytest.raises(requests.HTTPError):
+ _rows(_source("conversations", _manager()))
+
+ assert session.send.call_count == 1
+
+
+class _FakeResource:
+ def __init__(self, name: str) -> None:
+ self.name = name
+ self.maps: list[Any] = []
+
+ def add_map(self, fn: Any) -> "_FakeResource":
+ self.maps.append(fn)
+ return self
+
+
+class TestThreadsFanout:
+ def _build(self, **kwargs: Any) -> tuple[_FakeResource, list[Any]]:
+ child = _FakeResource("threads")
+ with mock.patch(FANOUT_RESOURCES_PATCH, return_value=[_FakeResource("conversations"), child]) as mocked:
+ helpscout_source(
+ "token", "threads", team_id=1, job_id="job-1", resumable_source_manager=_manager(), **kwargs
+ )
+ return child, mocked.call_args[0]
+
+ def test_parent_and_child_endpoints(self) -> None:
+ _, args = self._build()
+ parent, child = args[0]["resources"]
+
+ assert parent["endpoint"]["path"] == "/conversations"
+ assert child["endpoint"]["path"] == "/conversations/{conversation_id}/threads"
+ assert child["endpoint"]["params"]["conversation_id"] == {
+ "type": "resolve",
+ "resource": "conversations",
+ "field": "id",
+ }
+ assert child["include_from_parent"] == ["id"]
+ # Help Scout has no page-size param; neither endpoint should send one.
+ assert "limit" not in parent["endpoint"]["params"]
+ assert "limit" not in child["endpoint"]["params"]
+
+ def test_thread_rows_carry_the_parent_conversation_id(self) -> None:
+ child, _ = self._build()
+
+ row = child.maps[0]({"_conversations_id": 42, "id": 7, "body": "hi"})
+
+ assert row == {"conversation_id": 42, "id": 7, "body": "hi"}
+
+ def test_resume_seeds_fanout_state(self) -> None:
+ state = {"completed": ["/conversations/1/threads"], "current": None, "child_state": None}
+ manager = _manager(HelpScoutResumeConfig(fanout_state=state))
+ child = _FakeResource("threads")
+
+ with mock.patch(FANOUT_RESOURCES_PATCH, return_value=[_FakeResource("conversations"), child]) as mocked:
+ helpscout_source("token", "threads", team_id=1, job_id="job-1", resumable_source_manager=manager)
+
+ assert mocked.call_args.kwargs["initial_paginator_state"] == state
+
+ def test_checkpoints_fanout_progress(self) -> None:
+ manager = _manager()
+ child = _FakeResource("threads")
+
+ with mock.patch(FANOUT_RESOURCES_PATCH, return_value=[_FakeResource("conversations"), child]) as mocked:
+ helpscout_source("token", "threads", team_id=1, job_id="job-1", resumable_source_manager=manager)
+ resume_hook = mocked.call_args.kwargs["resume_hook"]
+ resume_hook({"completed": ["/conversations/1/threads"], "current": None, "child_state": None})
+
+ manager.save_state.assert_called_once()
+ saved = manager.save_state.call_args.args[0]
+ assert saved.fanout_state == {"completed": ["/conversations/1/threads"], "current": None, "child_state": None}
+
+
+class TestSourceResponseShape:
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_response_metadata_per_top_level_endpoint(self, _MockSession) -> None:
+ for endpoint in ENDPOINTS:
+ if endpoint == "threads":
+ continue
+ config = HELP_SCOUT_ENDPOINTS[endpoint]
+ response = _source(endpoint, _manager())
+
+ assert response.name == endpoint
+ assert response.primary_keys == config.primary_key
+ assert response.sort_mode == "asc"
+ assert response.partition_mode == "datetime"
+ assert response.partition_keys == ["createdAt"]
+
+ def test_threads_response_uses_composite_primary_key(self) -> None:
+ with mock.patch(
+ FANOUT_RESOURCES_PATCH, return_value=[_FakeResource("conversations"), _FakeResource("threads")]
+ ):
+ response = _source("threads", _manager())
+
+ assert response.primary_keys == ["conversation_id", "id"]
+
+
+class TestValidateCredentials:
+ @mock.patch(HELPSCOUT_SESSION_PATCH)
+ def test_source_create_probes_users_me(self, helpscout_session) -> None:
+ helpscout_session.return_value.get.return_value = mock.MagicMock(status_code=200)
+
+ ok, error = validate_credentials("token", schema_name=None)
+
+ assert ok is True
+ assert error is None
+ assert helpscout_session.return_value.get.call_args.args[0].endswith("/users/me")
+
+ @mock.patch(HELPSCOUT_SESSION_PATCH)
+ def test_probe_sessions_exclude_sample_capture(self, helpscout_session) -> None:
+ # /users/me and the schema probes can return customer-authored free-text content
+ # (e.g. a conversation subject), so neither must land in HTTP sample capture.
+ helpscout_session.return_value.get.return_value = mock.MagicMock(status_code=200)
+
+ validate_credentials("token", schema_name=None)
+ assert helpscout_session.call_args.kwargs["capture"] is False
+
+ validate_credentials("token", schema_name="mailboxes")
+ assert helpscout_session.call_args.kwargs["capture"] is False
+
+ @mock.patch(HELPSCOUT_SESSION_PATCH)
+ def test_revoked_token_fails_at_source_create(self, helpscout_session) -> None:
+ helpscout_session.return_value.get.return_value = mock.MagicMock(status_code=401)
+
+ ok, error = validate_credentials("token", schema_name=None)
+
+ assert ok is False
+ assert error is not None
+
+ @mock.patch(HELPSCOUT_SESSION_PATCH)
+ def test_schema_probe_success(self, helpscout_session) -> None:
+ helpscout_session.return_value.get.return_value = mock.MagicMock(status_code=200)
+
+ ok, error = validate_credentials("token", schema_name="mailboxes")
+
+ assert ok is True
+ assert error is None
+
+ @mock.patch(HELPSCOUT_SESSION_PATCH)
+ def test_schema_probe_401_reports_auth_error(self, helpscout_session) -> None:
+ helpscout_session.return_value.get.return_value = mock.MagicMock(status_code=401)
+
+ ok, error = validate_credentials("token", schema_name="mailboxes")
+
+ assert ok is False
+ assert error is not None and "authentication failed" in error
+
+ @mock.patch(HELPSCOUT_SESSION_PATCH)
+ def test_unknown_schema_fails_without_probing(self, helpscout_session) -> None:
+ helpscout_session.return_value.get.return_value = mock.MagicMock(status_code=200)
+
+ ok, error = validate_credentials("token", schema_name="not_a_table")
+
+ assert ok is False
+ assert error == "Unknown Help Scout table 'not_a_table'"
+ helpscout_session.return_value.get.assert_not_called()
+
+ @mock.patch(HELPSCOUT_SESSION_PATCH)
+ def test_threads_probe_uses_conversations_endpoint(self, helpscout_session) -> None:
+ helpscout_session.return_value.get.return_value = mock.MagicMock(status_code=200)
+
+ ok, _error = validate_credentials("token", schema_name="threads")
+
+ assert ok is True
+ probed_url = helpscout_session.return_value.get.call_args.args[0]
+ assert probed_url == f"{HELP_SCOUT_API_BASE}/conversations"
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/helpscout/tests/test_helpscout_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/helpscout/tests/test_helpscout_source.py
new file mode 100644
index 000000000000..a32245313e36
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/helpscout/tests/test_helpscout_source.py
@@ -0,0 +1,199 @@
+import pytest
+from unittest import mock
+
+from posthog.schema import ReleaseStatus, SourceFieldOauthConfig
+
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager
+from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.helpscout import (
+ HelpScoutSourceConfig,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.helpscout.helpscout import HelpScoutResumeConfig
+from products.warehouse_sources.backend.temporal.data_imports.sources.helpscout.settings import ENDPOINTS
+from products.warehouse_sources.backend.temporal.data_imports.sources.helpscout.source import HelpScoutSource
+from products.warehouse_sources.backend.types import ExternalDataSourceType
+
+
+class TestHelpScoutSource:
+ def setup_method(self):
+ self.source = HelpScoutSource()
+ self.team_id = 123
+ self.config = HelpScoutSourceConfig(helpscout_integration_id=456)
+
+ def test_source_type(self):
+ assert self.source.source_type == ExternalDataSourceType.HELPSCOUT
+
+ def test_get_source_config(self):
+ config = self.source.get_source_config
+
+ assert config.name.value == "HelpScout"
+ assert config.label == "Help Scout"
+ assert config.releaseStatus == ReleaseStatus.ALPHA
+ assert config.unreleasedSource is None
+ assert config.iconPath == "/static/services/helpscout.png"
+
+ # The only field is the OAuth connect button. A regression that reintroduced raw client
+ # credential inputs would make users register their own Help Scout app again.
+ oauth_fields = [f for f in config.fields if isinstance(f, SourceFieldOauthConfig)]
+ assert [f.name for f in oauth_fields] == ["helpscout_integration_id"]
+ assert oauth_fields[0].kind == "helpscout"
+ assert oauth_fields[0].required is True
+ assert len(config.fields) == 1
+
+ @pytest.mark.parametrize(
+ "observed_error",
+ [
+ "401 Client Error: Unauthorized for url: https://api.helpscout.net/v2/conversations",
+ "Integration not found: 456",
+ "Help Scout app not configured",
+ ],
+ )
+ def test_non_retryable_errors_match_client_errors(self, observed_error):
+ non_retryable_errors = self.source.get_non_retryable_errors()
+ assert any(key in observed_error for key in non_retryable_errors)
+
+ @pytest.mark.parametrize(
+ "other_vendor_error",
+ [
+ "401 Client Error: Unauthorized for url: https://api.stripe.com/v1/customers",
+ "500 Server Error for url: https://api.helpscout.net/v2/conversations",
+ ],
+ )
+ def test_non_retryable_errors_does_not_match_unrelated(self, other_vendor_error):
+ non_retryable_errors = self.source.get_non_retryable_errors()
+ assert not any(key in other_vendor_error for key in non_retryable_errors)
+
+ def test_get_schemas_covers_every_endpoint(self):
+ schemas = self.source.get_schemas(self.config, self.team_id)
+ assert {schema.name for schema in schemas} == set(ENDPOINTS)
+
+ @pytest.mark.parametrize("endpoint", ["conversations", "customers"])
+ def test_get_schemas_supports_incremental_for_modified_since_endpoints(self, endpoint):
+ schemas = {s.name: s for s in self.source.get_schemas(self.config, self.team_id)}
+ assert schemas[endpoint].supports_incremental is True
+ assert [f["field"] for f in schemas[endpoint].incremental_fields] == ["modifiedAt"]
+
+ @pytest.mark.parametrize("endpoint", ["mailboxes", "users", "tags", "workflows", "threads"])
+ def test_get_schemas_full_refresh_only_for_remaining_endpoints(self, endpoint):
+ schemas = {s.name: s for s in self.source.get_schemas(self.config, self.team_id)}
+ assert schemas[endpoint].supports_incremental is False
+ assert schemas[endpoint].incremental_fields == []
+
+ def test_get_schemas_filtered_by_names(self):
+ schemas = self.source.get_schemas(self.config, self.team_id, names=["mailboxes"])
+ assert len(schemas) == 1
+ assert schemas[0].name == "mailboxes"
+
+ def test_get_schemas_filtered_unknown_name_returns_empty(self):
+ assert self.source.get_schemas(self.config, self.team_id, names=["nope"]) == []
+
+ @mock.patch("products.warehouse_sources.backend.temporal.data_imports.sources.helpscout.source.OauthIntegration")
+ @mock.patch(
+ "products.warehouse_sources.backend.temporal.data_imports.sources.helpscout.source.HelpScoutSource.get_oauth_integration"
+ )
+ @mock.patch(
+ "products.warehouse_sources.backend.temporal.data_imports.sources.helpscout.source.validate_helpscout_credentials"
+ )
+ def test_validate_credentials_plumbs_arguments(self, mock_validate, mock_get_integration, mock_oauth):
+ mock_validate.return_value = (True, None)
+ mock_get_integration.return_value = mock.MagicMock(access_token="token", kind="helpscout")
+ mock_oauth.return_value.access_token_expired.return_value = False
+
+ is_valid, error_message = self.source.validate_credentials(self.config, self.team_id, schema_name="tags")
+
+ assert is_valid is True
+ assert error_message is None
+ mock_get_integration.assert_called_once_with(456, self.team_id)
+ mock_validate.assert_called_once_with("token", "tags")
+
+ @mock.patch(
+ "products.warehouse_sources.backend.temporal.data_imports.sources.helpscout.source.HelpScoutSource.get_oauth_integration"
+ )
+ def test_validate_credentials_reports_missing_integration(self, mock_get_integration):
+ mock_get_integration.side_effect = ValueError("Integration not found: 456")
+
+ is_valid, error_message = self.source.validate_credentials(self.config, self.team_id)
+
+ assert is_valid is False
+ assert error_message == "Integration not found: 456"
+
+ @mock.patch("products.warehouse_sources.backend.temporal.data_imports.sources.helpscout.source.OauthIntegration")
+ @mock.patch(
+ "products.warehouse_sources.backend.temporal.data_imports.sources.helpscout.source.HelpScoutSource.get_oauth_integration"
+ )
+ def test_integration_of_another_kind_is_rejected(self, mock_get_integration, mock_oauth):
+ # The lookup only scopes to the team, so a config pointing at another provider's
+ # integration must be rejected before its access token is read or refreshed.
+ mock_get_integration.return_value = mock.MagicMock(access_token="token", kind="salesforce")
+
+ with pytest.raises(ValueError, match="Integration not found: 456"):
+ self.source._get_access_token(self.config, self.team_id)
+
+ mock_oauth.assert_not_called()
+
+ @mock.patch("products.warehouse_sources.backend.temporal.data_imports.sources.helpscout.source.OauthIntegration")
+ @mock.patch(
+ "products.warehouse_sources.backend.temporal.data_imports.sources.helpscout.source.HelpScoutSource.get_oauth_integration"
+ )
+ def test_expired_token_is_refreshed_before_use(self, mock_get_integration, mock_oauth):
+ # Help Scout access tokens last ~2 days, so a source syncing on a stale token would 401
+ # mid-run instead of refreshing.
+ mock_get_integration.return_value = mock.MagicMock(access_token="token", kind="helpscout")
+ mock_oauth.return_value.access_token_expired.return_value = True
+
+ self.source._get_access_token(self.config, self.team_id)
+
+ mock_oauth.return_value.refresh_access_token.assert_called_once()
+
+ def test_get_resumable_source_manager_binds_resume_config(self):
+ inputs = mock.MagicMock()
+ manager = self.source.get_resumable_source_manager(inputs)
+
+ assert isinstance(manager, ResumableSourceManager)
+ assert manager._data_class is HelpScoutResumeConfig
+
+ @mock.patch("products.warehouse_sources.backend.temporal.data_imports.sources.helpscout.source.OauthIntegration")
+ @mock.patch(
+ "products.warehouse_sources.backend.temporal.data_imports.sources.helpscout.source.HelpScoutSource.get_oauth_integration"
+ )
+ @mock.patch("products.warehouse_sources.backend.temporal.data_imports.sources.helpscout.source.helpscout_source")
+ def test_source_for_pipeline_plumbs_arguments(self, mock_helpscout_source, mock_get_integration, mock_oauth):
+ mock_get_integration.return_value = mock.MagicMock(access_token="token", kind="helpscout")
+ mock_oauth.return_value.access_token_expired.return_value = False
+ inputs = mock.MagicMock()
+ inputs.schema_name = "conversations"
+ inputs.should_use_incremental_field = True
+ inputs.incremental_field = "modifiedAt"
+ inputs.db_incremental_field_last_value = "2024-01-01T00:00:00Z"
+ manager = mock.MagicMock()
+
+ self.source.source_for_pipeline(self.config, manager, inputs)
+
+ mock_helpscout_source.assert_called_once()
+ kwargs = mock_helpscout_source.call_args.kwargs
+ assert kwargs["access_token"] == "token"
+ assert kwargs["endpoint"] == "conversations"
+ assert kwargs["resumable_source_manager"] is manager
+ assert kwargs["should_use_incremental_field"] is True
+ assert kwargs["incremental_field"] == "modifiedAt"
+ assert kwargs["db_incremental_field_last_value"] == "2024-01-01T00:00:00Z"
+
+ @mock.patch("products.warehouse_sources.backend.temporal.data_imports.sources.helpscout.source.OauthIntegration")
+ @mock.patch(
+ "products.warehouse_sources.backend.temporal.data_imports.sources.helpscout.source.HelpScoutSource.get_oauth_integration"
+ )
+ @mock.patch("products.warehouse_sources.backend.temporal.data_imports.sources.helpscout.source.helpscout_source")
+ def test_source_for_pipeline_omits_last_value_on_full_refresh(
+ self, mock_helpscout_source, mock_get_integration, mock_oauth
+ ):
+ mock_get_integration.return_value = mock.MagicMock(access_token="token", kind="helpscout")
+ mock_oauth.return_value.access_token_expired.return_value = False
+ inputs = mock.MagicMock()
+ inputs.schema_name = "mailboxes"
+ inputs.should_use_incremental_field = False
+ inputs.db_incremental_field_last_value = "should-be-ignored"
+ manager = mock.MagicMock()
+
+ self.source.source_for_pipeline(self.config, manager, inputs)
+
+ kwargs = mock_helpscout_source.call_args.kwargs
+ assert kwargs["db_incremental_field_last_value"] is None
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 286b360ecfd7..3b17276ba4b9 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -7028,6 +7028,7 @@ export namespace Schemas {
Linear: 'linear',
Github: 'github',
Gitlab: 'gitlab',
+ Helpscout: 'helpscout',
MetaAds: 'meta-ads',
Instagram: 'instagram',
Clickup: 'clickup',
@@ -48086,6 +48087,7 @@ export namespace Schemas {
* * `google-pubsub` - Google Pubsub
* * `google-search-console` - Google Search Console
* * `google-sheets` - Google Sheets
+ * * `helpscout` - Helpscout
* * `hubspot` - Hubspot
* * `instagram` - Instagram
* * `intercom` - Intercom
@@ -48138,6 +48140,7 @@ export namespace Schemas {
GooglePubsub: 'google-pubsub',
GoogleSearchConsole: 'google-search-console',
GoogleSheets: 'google-sheets',
+ Helpscout: 'helpscout',
Hubspot: 'hubspot',
Instagram: 'instagram',
Intercom: 'intercom',
@@ -48190,6 +48193,7 @@ export namespace Schemas {
* * `google-pubsub` - Google Pubsub
* * `google-search-console` - Google Search Console
* * `google-sheets` - Google Sheets
+ * * `helpscout` - Helpscout
* * `hubspot` - Hubspot
* * `instagram` - Instagram
* * `intercom` - Intercom
@@ -99456,6 +99460,7 @@ export namespace Schemas {
* * `google-pubsub` - Google Pubsub
* * `google-search-console` - Google Search Console
* * `google-sheets` - Google Sheets
+ * * `helpscout` - Helpscout
* * `hubspot` - Hubspot
* * `instagram` - Instagram
* * `intercom` - Intercom
@@ -99519,6 +99524,7 @@ export namespace Schemas {
GooglePubsub: 'google-pubsub',
GoogleSearchConsole: 'google-search-console',
GoogleSheets: 'google-sheets',
+ Helpscout: 'helpscout',
Hubspot: 'hubspot',
Instagram: 'instagram',
Intercom: 'intercom',
diff --git a/services/mcp/src/generated/integrations/api.ts b/services/mcp/src/generated/integrations/api.ts
index 1a62f4f3e0d3..58e89ecd4200 100644
--- a/services/mcp/src/generated/integrations/api.ts
+++ b/services/mcp/src/generated/integrations/api.ts
@@ -42,6 +42,7 @@ export const IntegrationsListQueryParams = () => zod.object({
'google-pubsub',
'google-search-console',
'google-sheets',
+ 'helpscout',
'hubspot',
'instagram',
'intercom',
@@ -69,7 +70,7 @@ export const IntegrationsListQueryParams = () => zod.object({
])
.optional()
.describe(
- '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-redshift` - Aws Redshift\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-calendar` - Google Calendar\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `hubspot` - Hubspot\n\* `instagram` - Instagram\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pardot` - Pardot\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `posthog` - Posthog\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel\n\* `youtube-analytics` - Youtube Analytics'
+ '\* `anthropic` - Anthropic\n\* `apns` - Apple Push\n\* `aws-redshift` - Aws Redshift\n\* `aws-s3` - Aws S3\n\* `azure-blob` - Azure Blob\n\* `bing-ads` - Bing Ads\n\* `clickup` - Clickup\n\* `customerio-app` - Customerio App\n\* `customerio-track` - Customerio Track\n\* `customerio-webhook` - Customerio Webhook\n\* `databricks` - Databricks\n\* `email` - Email\n\* `firebase` - Firebase\n\* `github` - Github\n\* `gitlab` - Gitlab\n\* `google-ads` - Google Ads\n\* `google-analytics` - Google Analytics\n\* `google-calendar` - Google Calendar\n\* `google-cloud-service-account` - Google Cloud Service Account\n\* `google-cloud-storage` - Google Cloud Storage\n\* `google-pubsub` - Google Pubsub\n\* `google-search-console` - Google Search Console\n\* `google-sheets` - Google Sheets\n\* `helpscout` - Helpscout\n\* `hubspot` - Hubspot\n\* `instagram` - Instagram\n\* `intercom` - Intercom\n\* `jira` - Jira\n\* `linear` - Linear\n\* `linkedin-ads` - Linkedin Ads\n\* `meta-ads` - Meta Ads\n\* `pardot` - Pardot\n\* `pinterest-ads` - Pinterest Ads\n\* `postgresql` - Postgresql\n\* `posthog` - Posthog\n\* `reddit-ads` - Reddit Ads\n\* `resend` - Resend\n\* `s3-compatible` - S3 Compatible\n\* `salesforce` - Salesforce\n\* `slack` - Slack\n\* `slack-posthog-code` - Slack Posthog Code\n\* `snapchat` - Snapchat\n\* `snowflake` - Snowflake\n\* `stripe` - Stripe\n\* `tiktok-ads` - Tiktok Ads\n\* `twilio` - Twilio\n\* `vercel` - Vercel\n\* `youtube-analytics` - Youtube Analytics'
),
limit: zod.number().optional().describe('Number of results to return per page.'),
offset: zod.number().optional().describe('The initial index from which to return the results.'),
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/integrations-list.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/integrations-list.json
index 36f78b38b6eb..e5e558d0a6a2 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/integrations-list.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/integrations-list.json
@@ -2,7 +2,7 @@
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"kind": {
- "description": "* `anthropic` - Anthropic\n* `apns` - Apple Push\n* `aws-redshift` - Aws Redshift\n* `aws-s3` - Aws S3\n* `azure-blob` - Azure Blob\n* `bing-ads` - Bing Ads\n* `clickup` - Clickup\n* `customerio-app` - Customerio App\n* `customerio-track` - Customerio Track\n* `customerio-webhook` - Customerio Webhook\n* `databricks` - Databricks\n* `email` - Email\n* `firebase` - Firebase\n* `github` - Github\n* `gitlab` - Gitlab\n* `google-ads` - Google Ads\n* `google-analytics` - Google Analytics\n* `google-calendar` - Google Calendar\n* `google-cloud-service-account` - Google Cloud Service Account\n* `google-cloud-storage` - Google Cloud Storage\n* `google-pubsub` - Google Pubsub\n* `google-search-console` - Google Search Console\n* `google-sheets` - Google Sheets\n* `hubspot` - Hubspot\n* `instagram` - Instagram\n* `intercom` - Intercom\n* `jira` - Jira\n* `linear` - Linear\n* `linkedin-ads` - Linkedin Ads\n* `meta-ads` - Meta Ads\n* `pardot` - Pardot\n* `pinterest-ads` - Pinterest Ads\n* `postgresql` - Postgresql\n* `posthog` - Posthog\n* `reddit-ads` - Reddit Ads\n* `resend` - Resend\n* `s3-compatible` - S3 Compatible\n* `salesforce` - Salesforce\n* `slack` - Slack\n* `slack-posthog-code` - Slack Posthog Code\n* `snapchat` - Snapchat\n* `snowflake` - Snowflake\n* `stripe` - Stripe\n* `tiktok-ads` - Tiktok Ads\n* `twilio` - Twilio\n* `vercel` - Vercel\n* `youtube-analytics` - Youtube Analytics",
+ "description": "* `anthropic` - Anthropic\n* `apns` - Apple Push\n* `aws-redshift` - Aws Redshift\n* `aws-s3` - Aws S3\n* `azure-blob` - Azure Blob\n* `bing-ads` - Bing Ads\n* `clickup` - Clickup\n* `customerio-app` - Customerio App\n* `customerio-track` - Customerio Track\n* `customerio-webhook` - Customerio Webhook\n* `databricks` - Databricks\n* `email` - Email\n* `firebase` - Firebase\n* `github` - Github\n* `gitlab` - Gitlab\n* `google-ads` - Google Ads\n* `google-analytics` - Google Analytics\n* `google-calendar` - Google Calendar\n* `google-cloud-service-account` - Google Cloud Service Account\n* `google-cloud-storage` - Google Cloud Storage\n* `google-pubsub` - Google Pubsub\n* `google-search-console` - Google Search Console\n* `google-sheets` - Google Sheets\n* `helpscout` - Helpscout\n* `hubspot` - Hubspot\n* `instagram` - Instagram\n* `intercom` - Intercom\n* `jira` - Jira\n* `linear` - Linear\n* `linkedin-ads` - Linkedin Ads\n* `meta-ads` - Meta Ads\n* `pardot` - Pardot\n* `pinterest-ads` - Pinterest Ads\n* `postgresql` - Postgresql\n* `posthog` - Posthog\n* `reddit-ads` - Reddit Ads\n* `resend` - Resend\n* `s3-compatible` - S3 Compatible\n* `salesforce` - Salesforce\n* `slack` - Slack\n* `slack-posthog-code` - Slack Posthog Code\n* `snapchat` - Snapchat\n* `snowflake` - Snowflake\n* `stripe` - Stripe\n* `tiktok-ads` - Tiktok Ads\n* `twilio` - Twilio\n* `vercel` - Vercel\n* `youtube-analytics` - Youtube Analytics",
"enum": [
"anthropic",
"apns",
@@ -27,6 +27,7 @@
"google-pubsub",
"google-search-console",
"google-sheets",
+ "helpscout",
"hubspot",
"instagram",
"intercom",