: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(data-warehouse): add justcall campaigns, user groups and calls ai tables (#112524)
Tom Owers0284549aac5c
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.mdindex 3bbb4eb35bfd..4a93289b4bd3 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md@@ -4630,14 +4630,14 @@ Note: Two separate specs: v1 at https://docs.jumpcloud.com/api/1.0/index.yaml (2## JustCall — gaps-Today (6): `calls`, `contacts`, `phone_numbers`, `sales_dialer_calls`, `texts`, `users`+Today (9): `calls`, `calls_ai`, `contacts`, `phone_numbers`, `sales_dialer_calls`, `sales_dialer_campaigns`, `texts`, `user_groups`, `users`Diffed against: <https://developer.justcall.io/llms.txt>-- [ ] `/v2.1/sales_dialer/campaigns (List all campaigns)` — lookup resolving the campaign a sales_dialer_call belongs to - already syncing the calls without it (high)-- [ ] `/v2.1/calls/ai (List calls AI data)` — transcripts, sentiment and AI scores per call, JustCall's headline conversation-intelligence output (high)-- [ ] `/v2.1/texts/threads (List all threads)` — conversation-level grouping for the already-synced texts; per-message rows alone can't measure response time (high)-- [ ] `/v2.1/users/groups (List all user groups)` — team lookup for rolling agent-level call and text metrics up to teams (high)+- [x] `/v2.1/sales_dialer/campaigns (List all campaigns)` — lookup resolving the campaign a sales_dialer_call belongs to - already syncing the calls without it (high)+- [x] `/v2.1/calls_ai (List calls AI data)` — transcripts, sentiment and AI scores per call, JustCall's headline conversation-intelligence output (high)+- [ ] `/v2.1/texts/threads (List all threads)` — conversation-level grouping for the already-synced texts; per-message rows alone can't measure response time (high) - needs a fan-out over phone numbers, since `phone_id` is a required filter+- [x] `/v2.1/user_groups (List all user groups)` — team lookup for rolling agent-level call and text metrics up to teams (high)- [ ] `/v2.1/sales_dialer/campaigns/{id}/contacts (List campaign contacts)` — campaign membership edges needed for dial-through and contact-rate metrics (medium)- [ ] `/v2.1/calls/{id}/journey (Get call journey)` — per-call routing and leg history - who it rang, transfers, IVR path (medium)- [ ] `/v2.1/texts/tags (List all tags)` — tag lookup resolving the tags applied to text threads (medium)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/justcall/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/justcall/canonical_descriptions.pyindex 77c974ade2f4..d25be74b7551 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/justcall/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/justcall/canonical_descriptions.py@@ -130,4 +130,60 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"number_owner": "Owner of the number.",},},+ "user_groups": {+ "description": "A JustCall user group (team) and the agents who are members of it.",+ "docs_url": "https://developer.justcall.io/reference/users_groups_list_v21",+ "columns": {+ "id": "Unique identifier for the user group, generated by JustCall.",+ "group_name": "Name of the user group.",+ "group_extension": "Extension of the user group.",+ "total_members": "Number of members in the user group.",+ "members": "Agents in the user group, with their id, name, email, extension, role, and timezone.",+ "updated_on": "Date and time of the last update to the user group, in UTC.",+ },+ },+ "sales_dialer_campaigns": {+ "description": "A Sales Dialer campaign that groups the contacts agents dial, with its dialing configuration.",+ "docs_url": "https://developer.justcall.io/docs/sales-dialer-campaign-object",+ "columns": {+ "id": "Unique identifier for the campaign, generated by JustCall.",+ "name": "Name of the campaign.",+ "type": "Type of the campaign (e.g. Autodial, Predictive, Dynamic).",+ "status": "Whether the campaign is Completed or Remaining.",+ "default_number": "Default phone number set for the campaign.",+ "country_code": "Default country code for phone numbers without a country code.",+ "contact_dialing_order": "Order in which the contact lists of the campaign are dialed.",+ "contacts_count": "Contact count details for the campaign.",+ "maximum_calls_per_agent": "Maximum number of calls allowed per agent in the campaign.",+ "assigned_to_id": "Assignment details for the campaign.",+ "call_scripts": "Call scripts assigned to the campaign.",+ "disposition_groups": "Disposition groups assigned to the campaign.",+ "call_forwarding_number": "Number to which incoming calls to the campaign are forwarded.",+ "created_by_id": "Identifier of the agent who created the campaign.",+ "created_by_name": "Name of the agent who created the campaign.",+ "created_by_email": "Email of the agent who created the campaign.",+ "created_date": "Date of campaign creation.",+ "created_time": "Time of campaign creation.",+ },+ },+ "calls_ai": {+ "description": "JustCall AI analysis of a call: summary, transcript, sentiment, scores, and action items.",+ "docs_url": "https://developer.justcall.io/reference/call_ai_list_v21",+ "columns": {+ "id": "Unique identifier of the call, generated by JustCall. Joins to the calls table.",+ "call_sid": "Telephony provider identifier for the call.",+ "platform": "Platform the call belongs to.",+ "call_summary": "Summary of the key highlights and takeaways from the call.",+ "action_items": "Summary of the key action items from the call.",+ "call_transcription": "Transcript of the call in a script-like format.",+ "customer_sentiment": "Overall sentiment of the customer, based on words and tone.",+ "call_score": "Overall AI score of the call, out of 10.",+ "call_score_parameters": "AI scores for individual parameters such as empathy, greetings, and talk-listen ratio.",+ "manual_call_score": "Average of all manual scores added to the call.",+ "interaction_stats": "Interaction statistics such as agent and customer speak time and dead air time.",+ "call_moments": "Most important keywords from the call.",+ "smart_chapters": "Sections of the call, each with an overview of the conversation.",+ "tags": "Tags added by the agent for the call.",+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/justcall/justcall.py b/products/warehouse_sources/backend/temporal/data_imports/sources/justcall/justcall.pyindex 268171769088..70ed9dbbbf12 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/justcall/justcall.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/justcall/justcall.py@@ -23,7 +23,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.typfrom products.warehouse_sources.backend.temporal.data_imports.sources.justcall.settings import JUSTCALL_ENDPOINTSJUSTCALL_BASE_URL = "https://api.justcall.io/v2.1"-# JustCall caps list pages at 100 items across the v2.1 list endpoints.+# JustCall caps most v2.1 list pages at 100 items; endpoints with a lower cap override it in settings.PAGE_SIZE = 100# v2.1 list endpoints are 0-indexed ("page 0 indicates first page").FIRST_PAGE = 0@@ -99,7 +99,8 @@ def justcall_source(# `order` is set per endpoint; page/per_page/from_datetime are added by the paginator and the# incremental config below. Ascending order keeps already-paged results stable under concurrent# inserts and lets the incremental watermark advance monotonically.- params: dict[str, Any] = {"per_page": PAGE_SIZE, "order": config.order}+ page_size = config.page_size or PAGE_SIZE+ params: dict[str, Any] = {**config.extra_params, "per_page": page_size, "order": config.order}incremental: Optional[IncrementalConfig] = Noneif config.incremental_cursor:@@ -140,7 +141,7 @@ def justcall_source("name": "Authorization","location": "header",},- "paginator": JustCallPageNumberPaginator(page_size=PAGE_SIZE),+ "paginator": JustCallPageNumberPaginator(page_size=page_size),},"resources": [endpoint_config],}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/justcall/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/justcall/settings.pyindex ca5b7977204f..ffa60c42415d 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/justcall/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/justcall/settings.py@@ -1,10 +1,10 @@-from dataclasses import dataclass-from typing import Optional+from dataclasses import dataclass, field+from typing import Any, Optionalfrom products.warehouse_sources.backend.types import IncrementalField, IncrementalFieldType-@dataclass+@dataclass(frozen=True)class JustCallEndpointConfig:name: strpath: str@@ -22,6 +22,9 @@ class JustCallEndpointConfig:# `asc`/`desc`; phone-numbers documents uppercase `ASC`/`DESC`). Ascending keeps already-paged# results stable under concurrent inserts and lets the incremental watermark advance monotonically.order: str = "asc"+ # Per-endpoint page-size cap where JustCall documents a lower maximum than the default of 100.+ page_size: Optional[int] = None+ extra_params: dict[str, Any] = field(default_factory=dict)def _incremental_fields(cursor: str) -> list[IncrementalField]:@@ -40,8 +43,9 @@ def _incremental_fields(cursor: str) -> list[IncrementalField]:# Endpoints are the JustCall v2.1 list resources a warehouse user is most likely to want:# telephony (calls), messaging (texts), the sales-dialer contact-center calls, plus the-# supporting dimensions (contacts, users, phone numbers). Analytics/aggregate endpoints are-# intentionally excluded — they return computed rollups, not raw records.+# supporting dimensions (contacts, users, user groups, phone numbers, campaigns), and the per-call+# JustCall AI analysis. Analytics/aggregate endpoints are intentionally excluded — they return+# computed rollups, not raw records.JUSTCALL_ENDPOINTS: dict[str, JustCallEndpointConfig] = {"calls": JustCallEndpointConfig(name="calls",@@ -73,6 +77,25 @@ JUSTCALL_ENDPOINTS: dict[str, JustCallEndpointConfig] = {path="/phone-numbers",order="ASC",),+ "user_groups": JustCallEndpointConfig(+ name="user_groups",+ path="/user_groups",+ ),+ # Campaign status and contact counts change after creation, so a creation-date+ # `from_datetime` filter would miss updates; campaigns are a small table, so full refresh.+ "sales_dialer_campaigns": JustCallEndpointConfig(+ name="sales_dialer_campaigns",+ path="/sales_dialer/campaigns",+ page_size=50,+ ),+ # Rows carry no date field to use as a cursor, so full refresh. Only JustCall-platform calls are+ # requested: `id` is the call id, which is not unique across the JustCall and Sales Dialer platforms.+ "calls_ai": JustCallEndpointConfig(+ name="calls_ai",+ path="/calls_ai",+ page_size=20,+ extra_params={"platform": "justcall", "fetch_transcription": "true"},+ ),}ENDPOINTS = tuple(JUSTCALL_ENDPOINTS.keys())diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/justcall/tests/test_justcall.py b/products/warehouse_sources/backend/temporal/data_imports/sources/justcall/tests/test_justcall.pyindex 5769ee82b053..9020f42448a0 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/justcall/tests/test_justcall.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/justcall/tests/test_justcall.py@@ -129,6 +129,15 @@ class TestRequestParams:assert params[0]["order"] == "ASC"+ @mock.patch(CLIENT_SESSION_PATCH)+ def test_calls_ai_requests_justcall_platform_with_transcripts(self, MockSession):+ session = MockSession.return_value+ _, params = _run(session, [_response([{"id": 1}])], "calls_ai", _make_manager())++ assert params[0]["per_page"] == 20+ assert params[0]["platform"] == "justcall"+ assert params[0]["fetch_transcription"] == "true"+@mock.patch(CLIENT_SESSION_PATCH)def test_incremental_request_carries_from_datetime(self, MockSession):session = MockSession.return_value@@ -163,6 +172,18 @@ class TestPagination:assert params[0]["page"] == 0assert params[1]["page"] == 1+ @pytest.mark.parametrize("endpoint, page_size", [("sales_dialer_campaigns", 50), ("calls_ai", 20)])+ @mock.patch(CLIENT_SESSION_PATCH)+ def test_endpoint_page_size_cap_drives_short_page_detection(self, MockSession, endpoint, page_size):+ # A full page at the endpoint's lower cap must not be read as the last page.+ session = MockSession.return_value+ full_page = [{"id": i} for i in range(page_size)]+ rows, params = _run(session, [_response(full_page), _response([{"id": page_size}])], endpoint, _make_manager())++ assert len(rows) == page_size + 1+ assert session.send.call_count == 2+ assert params[0]["per_page"] == page_size+@mock.patch(f"{JUSTCALL_MODULE}.PAGE_SIZE", 2)@mock.patch(CLIENT_SESSION_PATCH)def test_full_page_then_short_page_checkpoints_next_page(self, MockSession):