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(user-interviews): add per-interviewee context rows + CSV-aware skill (#58415)

Paul D'Ambra54c5d40b6e36
diff --git a/.semgrep/rules/idor-team-scoped-models.yaml b/.semgrep/rules/idor-team-scoped-models.yaml
index f5dc98824628..5eb9adffb195 100644
--- a/.semgrep/rules/idor-team-scoped-models.yaml
+++ b/.semgrep/rules/idor-team-scoped-models.yaml
@@ -144,6 +144,7 @@ rules:
|InsightVariable
|Integration
|IntegrationRepositoryCacheEntry
+ |IntervieweeContext
|KnowledgeChunk
|KnowledgeDocument
|KnowledgeSource
@@ -364,6 +365,7 @@ rules:
|InsightVariable
|Integration
|IntegrationRepositoryCacheEntry
+ |IntervieweeContext
|KnowledgeChunk
|KnowledgeDocument
|KnowledgeSource
diff --git a/posthog/api/__init__.py b/posthog/api/__init__.py
index baaaafee3b23..c6328d742c20 100644
--- a/posthog/api/__init__.py
+++ b/posthog/api/__init__.py
@@ -114,7 +114,11 @@ from products.product_tours.backend.api import ProductTourViewSet
from products.replay_vision.backend.api import ReplayLensViewSet, ReplayObservationViewSet
from products.signals.backend.views import SignalViewSet
from products.tracing.backend.presentation.views import SpansViewSet as TracingSpansViewSet
-from products.user_interviews.backend.api import UserInterviewTopicViewSet, UserInterviewViewSet
+from products.user_interviews.backend.api import (
+ IntervieweeContextViewSet,
+ UserInterviewTopicViewSet,
+ UserInterviewViewSet,
+)
from products.visual_review.backend.presentation.views import (
RepoRunsViewSet as VisualReviewRepoRunsViewSet,
RepoViewSet as VisualReviewRepoViewSet,
@@ -1326,12 +1330,18 @@ environments_router.register(
["team_id"],
)
-environments_router.register(
+user_interview_topics_router = environments_router.register(
r"user_interview_topics",
UserInterviewTopicViewSet,
"environment_user_interview_topics",
["team_id"],
)
+user_interview_topics_router.register(
+ r"interviewees",
+ IntervieweeContextViewSet,
+ "environment_user_interview_topic_interviewees",
+ ["team_id", "topic_id"],
+)
visual_review_repos_router = projects_router.register(
r"visual_review/repos",
diff --git a/products/user_interviews/backend/api.py b/products/user_interviews/backend/api.py
index 4c3818f52025..54e795c2f0b4 100644
--- a/products/user_interviews/backend/api.py
+++ b/products/user_interviews/backend/api.py
@@ -1,10 +1,12 @@
import re
import json
from functools import cached_property
+from typing import Any
from uuid import uuid4
from django.conf import settings
from django.core.files import File
+from django.db.models import QuerySet
import posthoganalytics
import posthoganalytics.ai.openai
@@ -20,7 +22,7 @@ from posthog.api.routing import TeamAndOrgViewSetMixin
from posthog.api.shared import UserBasicSerializer
from posthog.permissions import PostHogFeatureFlagPermission
-from .models import EmailWithDisplayNameValidator, UserInterview, UserInterviewTopic
+from .models import EmailWithDisplayNameValidator, IntervieweeContext, UserInterview, UserInterviewTopic
elevenlabs_client = ElevenLabs()
@@ -319,3 +321,76 @@ class UserInterviewTopicViewSet(TeamAndOrgViewSetMixin, viewsets.ModelViewSet):
search_fields = ["topic"]
posthog_feature_flag = "user-interviews"
permission_classes = [PostHogFeatureFlagPermission]
+
+
+class IntervieweeContextSerializer(serializers.ModelSerializer):
+ created_by = UserBasicSerializer(read_only=True)
+ interviewee_identifier = serializers.CharField(
+ max_length=400,
+ help_text="Identifier for the interviewee — typically an email address or PostHog distinct ID. Must match a value in the parent topic's interviewee_emails or interviewee_distinct_ids.",
+ )
+ agent_context = serializers.CharField(
+ max_length=10000,
+ help_text="Extra context the voice agent should know about this specific interviewee — e.g. 'uses the replay product but has never used summarization'.",
+ )
+
+ class Meta:
+ model = IntervieweeContext
+ fields = (
+ "id",
+ "created_by",
+ "created_at",
+ "interviewee_identifier",
+ "agent_context",
+ )
+ read_only_fields = ("id", "created_by", "created_at")
+
+ def validate(self, attrs: dict[str, Any]) -> dict[str, Any]:
+ topic_id = self.context["topic_id"]
+ team = self.context["get_team"]()
+
+ if not UserInterviewTopic.objects.filter(id=topic_id, team_id=team.id).exists():
+ raise serializers.ValidationError({"topic": "Topic not found in this project."})
+
+ if self.instance is None:
+ interviewee_identifier = attrs.get("interviewee_identifier")
+ if IntervieweeContext.objects.filter(
+ topic_id=topic_id, interviewee_identifier=interviewee_identifier
+ ).exists():
+ raise serializers.ValidationError(
+ {
+ "interviewee_identifier": "A context row for this interviewee already exists on this topic. Update the existing row instead of creating a new one."
+ }
+ )
+ return attrs
+
+ def create(self, validated_data: dict[str, Any]) -> IntervieweeContext:
+ request = self.context["request"]
+ team = self.context["get_team"]()
+ topic_id = self.context["topic_id"]
+ return IntervieweeContext.objects.create(
+ team=team,
+ topic_id=topic_id,
+ created_by=request.user,
+ **validated_data,
+ )
+
+
+@extend_schema(tags=[ProductKey.USER_INTERVIEWS])
+class IntervieweeContextViewSet(TeamAndOrgViewSetMixin, viewsets.ModelViewSet):
+ """Per-interviewee extra context for a user interview topic. At most one row per (topic, interviewee_identifier)."""
+
+ scope_object = "user_interview"
+ serializer_class = IntervieweeContextSerializer
+ queryset = IntervieweeContext.objects.select_related("created_by").all()
+ posthog_feature_flag = "user-interviews"
+ permission_classes = [PostHogFeatureFlagPermission]
+
+ def safely_get_queryset(self, queryset: QuerySet) -> QuerySet:
+ return queryset.filter(
+ topic_id=self.parents_query_dict["topic_id"],
+ team_id=self.parents_query_dict["team_id"],
+ )
+
+ def get_serializer_context(self) -> dict[str, Any]:
+ return {**super().get_serializer_context(), "topic_id": self.parents_query_dict["topic_id"]}
diff --git a/products/user_interviews/backend/migrations/0003_intervieweecontext.py b/products/user_interviews/backend/migrations/0003_intervieweecontext.py
new file mode 100644
index 000000000000..3e4c3c8a0e61
--- /dev/null
+++ b/products/user_interviews/backend/migrations/0003_intervieweecontext.py
@@ -0,0 +1,57 @@
+import django.db.models.deletion
+from django.conf import settings
+from django.db import migrations, models
+
+import posthog.models.utils
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+ ("posthog", "1152_fix_device_bucketing_persist_across_auth"),
+ ("user_interviews", "0002_userinterviewtopic"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="IntervieweeContext",
+ fields=[
+ ("created_at", models.DateTimeField(auto_now_add=True)),
+ (
+ "id",
+ models.UUIDField(
+ default=posthog.models.utils.UUIDT, editable=False, primary_key=True, serialize=False
+ ),
+ ),
+ ("interviewee_identifier", models.CharField(max_length=400)),
+ ("agent_context", models.TextField()),
+ (
+ "created_by",
+ models.ForeignKey(
+ blank=True,
+ null=True,
+ on_delete=django.db.models.deletion.SET_NULL,
+ to=settings.AUTH_USER_MODEL,
+ ),
+ ),
+ ("team", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="posthog.team")),
+ (
+ "topic",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ related_name="interviewee_contexts",
+ to="user_interviews.userinterviewtopic",
+ ),
+ ),
+ ],
+ options={
+ "ordering": ["-created_at"],
+ },
+ ),
+ migrations.AddConstraint(
+ model_name="intervieweecontext",
+ constraint=models.UniqueConstraint(
+ fields=("topic", "interviewee_identifier"), name="unique_interviewee_per_topic"
+ ),
+ ),
+ ]
diff --git a/products/user_interviews/backend/migrations/max_migration.txt b/products/user_interviews/backend/migrations/max_migration.txt
index 478eb5da8be7..55f2c4f2ea7a 100644
--- a/products/user_interviews/backend/migrations/max_migration.txt
+++ b/products/user_interviews/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0002_userinterviewtopic
+0003_intervieweecontext
diff --git a/products/user_interviews/backend/models.py b/products/user_interviews/backend/models.py
index e108f0d4cdd0..4c5a64a82919 100644
--- a/products/user_interviews/backend/models.py
+++ b/products/user_interviews/backend/models.py
@@ -54,3 +54,23 @@ class UserInterviewTopic(UUIDTModel, CreatedMetaFields):
class Meta:
ordering = ["-created_at"]
+
+
+class IntervieweeContext(UUIDTModel, CreatedMetaFields):
+ team = models.ForeignKey(Team, on_delete=models.CASCADE)
+ topic = models.ForeignKey(
+ UserInterviewTopic,
+ on_delete=models.CASCADE,
+ related_name="interviewee_contexts",
+ )
+ interviewee_identifier = models.CharField(max_length=400)
+ agent_context = models.TextField()
+
+ class Meta:
+ ordering = ["-created_at"]
+ constraints = [
+ models.UniqueConstraint(
+ fields=["topic", "interviewee_identifier"],
+ name="unique_interviewee_per_topic",
+ ),
+ ]
diff --git a/products/user_interviews/frontend/generated/api.schemas.ts b/products/user_interviews/frontend/generated/api.schemas.ts
index 3016d0b2f2a2..baff648ba0fa 100644
--- a/products/user_interviews/frontend/generated/api.schemas.ts
+++ b/products/user_interviews/frontend/generated/api.schemas.ts
@@ -113,6 +113,47 @@ export interface PatchedUserInterviewTopicApi {
questions?: string[]
}
+export interface IntervieweeContextApi {
+ readonly id: string
+ readonly created_by: UserBasicApi
+ readonly created_at: string
+ /**
+ * Identifier for the interviewee — typically an email address or PostHog distinct ID. Must match a value in the parent topic's interviewee_emails or interviewee_distinct_ids.
+ * @maxLength 400
+ */
+ interviewee_identifier: string
+ /**
+ * Extra context the voice agent should know about this specific interviewee — e.g. 'uses the replay product but has never used summarization'.
+ * @maxLength 10000
+ */
+ agent_context: string
+}
+
+export interface PaginatedIntervieweeContextListApi {
+ count: number
+ /** @nullable */
+ next?: string | null
+ /** @nullable */
+ previous?: string | null
+ results: IntervieweeContextApi[]
+}
+
+export interface PatchedIntervieweeContextApi {
+ readonly id?: string
+ readonly created_by?: UserBasicApi
+ readonly created_at?: string
+ /**
+ * Identifier for the interviewee — typically an email address or PostHog distinct ID. Must match a value in the parent topic's interviewee_emails or interviewee_distinct_ids.
+ * @maxLength 400
+ */
+ interviewee_identifier?: string
+ /**
+ * Extra context the voice agent should know about this specific interviewee — e.g. 'uses the replay product but has never used summarization'.
+ * @maxLength 10000
+ */
+ agent_context?: string
+}
+
export interface UserInterviewApi {
readonly id: string
readonly created_by: UserBasicApi
@@ -157,6 +198,17 @@ export type UserInterviewTopicsListParams = {
search?: string
}
+export type UserInterviewTopicsIntervieweesListParams = {
+ /**
+ * Number of results to return per page.
+ */
+ limit?: number
+ /**
+ * The initial index from which to return the results.
+ */
+ offset?: number
+}
+
export type UserInterviewsListParams = {
/**
* Number of results to return per page.
diff --git a/products/user_interviews/frontend/generated/api.ts b/products/user_interviews/frontend/generated/api.ts
index 2310c513f9de..2ef9064f8268 100644
--- a/products/user_interviews/frontend/generated/api.ts
+++ b/products/user_interviews/frontend/generated/api.ts
@@ -9,12 +9,16 @@ import { apiMutator } from '../../../../frontend/src/lib/api-orval-mutator'
* OpenAPI spec version: 1.0.0
*/
import type {
+ IntervieweeContextApi,
+ PaginatedIntervieweeContextListApi,
PaginatedUserInterviewListApi,
PaginatedUserInterviewTopicListApi,
+ PatchedIntervieweeContextApi,
PatchedUserInterviewApi,
PatchedUserInterviewTopicApi,
UserInterviewApi,
UserInterviewTopicApi,
+ UserInterviewTopicsIntervieweesListParams,
UserInterviewTopicsListParams,
UserInterviewsListParams,
} from './api.schemas'
@@ -164,6 +168,150 @@ export const userInterviewTopicsDestroy = async (
})
}
+export const getUserInterviewTopicsIntervieweesListUrl = (
+ projectId: string,
+ topicId: string,
+ params?: UserInterviewTopicsIntervieweesListParams
+) => {
+ const normalizedParams = new URLSearchParams()
+
+ Object.entries(params || {}).forEach(([key, value]) => {
+ if (value !== undefined) {
+ normalizedParams.append(key, value === null ? 'null' : value.toString())
+ }
+ })
+
+ const stringifiedParams = normalizedParams.toString()
+
+ return stringifiedParams.length > 0
+ ? `/api/environments/${projectId}/user_interview_topics/${topicId}/interviewees/?${stringifiedParams}`
+ : `/api/environments/${projectId}/user_interview_topics/${topicId}/interviewees/`
+}
+
+/**
+ * Per-interviewee extra context for a user interview topic. At most one row per (topic, interviewee_identifier).
+ */
+export const userInterviewTopicsIntervieweesList = async (
+ projectId: string,
+ topicId: string,
+ params?: UserInterviewTopicsIntervieweesListParams,
+ options?: RequestInit
+): Promise<PaginatedIntervieweeContextListApi> => {
+ return apiMutator<PaginatedIntervieweeContextListApi>(
+ getUserInterviewTopicsIntervieweesListUrl(projectId, topicId, params),
+ {
+ ...options,
+ method: 'GET',
+ }
+ )
+}
+
+export const getUserInterviewTopicsIntervieweesCreateUrl = (projectId: string, topicId: string) => {
+ return `/api/environments/${projectId}/user_interview_topics/${topicId}/interviewees/`
+}
+
+/**
+ * Per-interviewee extra context for a user interview topic. At most one row per (topic, interviewee_identifier).
+ */
+export const userInterviewTopicsIntervieweesCreate = async (
+ projectId: string,
+ topicId: string,
+ intervieweeContextApi: NonReadonly<IntervieweeContextApi>,
+ options?: RequestInit
+): Promise<IntervieweeContextApi> => {
+ return apiMutator<IntervieweeContextApi>(getUserInterviewTopicsIntervieweesCreateUrl(projectId, topicId), {
+ ...options,
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json', ...options?.headers },
+ body: JSON.stringify(intervieweeContextApi),
+ })
+}
+
+export const getUserInterviewTopicsIntervieweesRetrieveUrl = (projectId: string, topicId: string, id: string) => {
+ return `/api/environments/${projectId}/user_interview_topics/${topicId}/interviewees/${id}/`
+}
+
+/**
+ * Per-interviewee extra context for a user interview topic. At most one row per (topic, interviewee_identifier).
+ */
+export const userInterviewTopicsIntervieweesRetrieve = async (
+ projectId: string,
+ topicId: string,
+ id: string,
+ options?: RequestInit
+): Promise<IntervieweeContextApi> => {
+ return apiMutator<IntervieweeContextApi>(getUserInterviewTopicsIntervieweesRetrieveUrl(projectId, topicId, id), {
+ ...options,
+ method: 'GET',
+ })
+}
+
+export const getUserInterviewTopicsIntervieweesUpdateUrl = (projectId: string, topicId: string, id: string) => {
+ return `/api/environments/${projectId}/user_interview_topics/${topicId}/interviewees/${id}/`
+}
+
+/**
+ * Per-interviewee extra context for a user interview topic. At most one row per (topic, interviewee_identifier).
+ */
+export const userInterviewTopicsIntervieweesUpdate = async (
+ projectId: string,
+ topicId: string,
+ id: string,
+ intervieweeContextApi: NonReadonly<IntervieweeContextApi>,
+ options?: RequestInit
+): Promise<IntervieweeContextApi> => {
+ return apiMutator<IntervieweeContextApi>(getUserInterviewTopicsIntervieweesUpdateUrl(projectId, topicId, id), {
+ ...options,
+ method: 'PUT',
+ headers: { 'Content-Type': 'application/json', ...options?.headers },
+ body: JSON.stringify(intervieweeContextApi),
+ })
+}
+
+export const getUserInterviewTopicsIntervieweesPartialUpdateUrl = (projectId: string, topicId: string, id: string) => {
+ return `/api/environments/${projectId}/user_interview_topics/${topicId}/interviewees/${id}/`
+}
+
+/**
+ * Per-interviewee extra context for a user interview topic. At most one row per (topic, interviewee_identifier).
+ */
+export const userInterviewTopicsIntervieweesPartialUpdate = async (
+ projectId: string,
+ topicId: string,
+ id: string,
+ patchedIntervieweeContextApi?: NonReadonly<PatchedIntervieweeContextApi>,
+ options?: RequestInit
+): Promise<IntervieweeContextApi> => {
+ return apiMutator<IntervieweeContextApi>(
+ getUserInterviewTopicsIntervieweesPartialUpdateUrl(projectId, topicId, id),
+ {
+ ...options,
+ method: 'PATCH',
+ headers: { 'Content-Type': 'application/json', ...options?.headers },
+ body: JSON.stringify(patchedIntervieweeContextApi),
+ }
+ )
+}
+
+export const getUserInterviewTopicsIntervieweesDestroyUrl = (projectId: string, topicId: string, id: string) => {
+ return `/api/environments/${projectId}/user_interview_topics/${topicId}/interviewees/${id}/`
+}
+
+/**
+ * Per-interviewee extra context for a user interview topic. At most one row per (topic, interviewee_identifier).
+ */
+export const userInterviewTopicsIntervieweesDestroy = async (
+ projectId: string,
+ topicId: string,
+ id: string,
+ options?: RequestInit
+): Promise<void> => {
+ return apiMutator<void>(getUserInterviewTopicsIntervieweesDestroyUrl(projectId, topicId, id), {
+ ...options,
+ method: 'DELETE',
+ })
+}
+
export const getUserInterviewsListUrl = (projectId: string, params?: UserInterviewsListParams) => {
const normalizedParams = new URLSearchParams()
diff --git a/products/user_interviews/frontend/generated/api.zod.ts b/products/user_interviews/frontend/generated/api.zod.ts
index 73586ce89735..9c9a8223db14 100644
--- a/products/user_interviews/frontend/generated/api.zod.ts
+++ b/products/user_interviews/frontend/generated/api.zod.ts
@@ -114,6 +114,74 @@ export const UserInterviewTopicsPartialUpdateBody = /* @__PURE__ */ zod.object({
.describe('Ordered list of questions the voice agent should work through during the interview.'),
})
+/**
+ * Per-interviewee extra context for a user interview topic. At most one row per (topic, interviewee_identifier).
+ */
+export const userInterviewTopicsIntervieweesCreateBodyIntervieweeIdentifierMax = 400
+
+export const userInterviewTopicsIntervieweesCreateBodyAgentContextMax = 10000
+
+export const UserInterviewTopicsIntervieweesCreateBody = /* @__PURE__ */ zod.object({
+ interviewee_identifier: zod
+ .string()
+ .max(userInterviewTopicsIntervieweesCreateBodyIntervieweeIdentifierMax)
+ .describe(
+ "Identifier for the interviewee — typically an email address or PostHog distinct ID. Must match a value in the parent topic's interviewee_emails or interviewee_distinct_ids."
+ ),
+ agent_context: zod
+ .string()
+ .max(userInterviewTopicsIntervieweesCreateBodyAgentContextMax)
+ .describe(
+ "Extra context the voice agent should know about this specific interviewee — e.g. 'uses the replay product but has never used summarization'."
+ ),
+})
+
+/**
+ * Per-interviewee extra context for a user interview topic. At most one row per (topic, interviewee_identifier).
+ */
+export const userInterviewTopicsIntervieweesUpdateBodyIntervieweeIdentifierMax = 400
+
+export const userInterviewTopicsIntervieweesUpdateBodyAgentContextMax = 10000
+
+export const UserInterviewTopicsIntervieweesUpdateBody = /* @__PURE__ */ zod.object({
+ interviewee_identifier: zod
+ .string()
+ .max(userInterviewTopicsIntervieweesUpdateBodyIntervieweeIdentifierMax)
+ .describe(
+ "Identifier for the interviewee — typically an email address or PostHog distinct ID. Must match a value in the parent topic's interviewee_emails or interviewee_distinct_ids."
+ ),
+ agent_context: zod
+ .string()
+ .max(userInterviewTopicsIntervieweesUpdateBodyAgentContextMax)
+ .describe(
+ "Extra context the voice agent should know about this specific interviewee — e.g. 'uses the replay product but has never used summarization'."
+ ),
+})
+
+/**
+ * Per-interviewee extra context for a user interview topic. At most one row per (topic, interviewee_identifier).
+ */
+export const userInterviewTopicsIntervieweesPartialUpdateBodyIntervieweeIdentifierMax = 400
+
+export const userInterviewTopicsIntervieweesPartialUpdateBodyAgentContextMax = 10000
+
+export const UserInterviewTopicsIntervieweesPartialUpdateBody = /* @__PURE__ */ zod.object({
+ interviewee_identifier: zod
+ .string()
+ .max(userInterviewTopicsIntervieweesPartialUpdateBodyIntervieweeIdentifierMax)
+ .optional()
+ .describe(
+ "Identifier for the interviewee — typically an email address or PostHog distinct ID. Must match a value in the parent topic's interviewee_emails or interviewee_distinct_ids."
+ ),
+ agent_context: zod
+ .string()
+ .max(userInterviewTopicsIntervieweesPartialUpdateBodyAgentContextMax)
+ .optional()
+ .describe(
+ "Extra context the voice agent should know about this specific interviewee — e.g. 'uses the replay product but has never used summarization'."
+ ),
+})
+
export const userInterviewsCreateBodyIntervieweeEmailsItemMax = 254
export const UserInterviewsCreateBody = /* @__PURE__ */ zod.object({
diff --git a/products/user_interviews/mcp/tools.yaml b/products/user_interviews/mcp/tools.yaml
index 7c992d169e0b..a35107ddac90 100644
--- a/products/user_interviews/mcp/tools.yaml
+++ b/products/user_interviews/mcp/tools.yaml
@@ -37,6 +37,24 @@ tools:
user-interview-topics-destroy:
operation: user_interview_topics_destroy
enabled: false
+ user-interview-topics-interviewees-create:
+ operation: user_interview_topics_interviewees_create
+ enabled: false
+ user-interview-topics-interviewees-destroy:
+ operation: user_interview_topics_interviewees_destroy
+ enabled: false
+ user-interview-topics-interviewees-list:
+ operation: user_interview_topics_interviewees_list
+ enabled: false
+ user-interview-topics-interviewees-partial-update:
+ operation: user_interview_topics_interviewees_partial_update
+ enabled: false
+ user-interview-topics-interviewees-retrieve:
+ operation: user_interview_topics_interviewees_retrieve
+ enabled: false
+ user-interview-topics-interviewees-update:
+ operation: user_interview_topics_interviewees_update
+ enabled: false
user-interview-topics-list:
operation: user_interview_topics_list
enabled: true
diff --git a/products/user_interviews/skills/planning-user-interviews/SKILL.md b/products/user_interviews/skills/planning-user-interviews/SKILL.md
index 0e79173ee39c..1bf0741818eb 100644
--- a/products/user_interviews/skills/planning-user-interviews/SKILL.md
+++ b/products/user_interviews/skills/planning-user-interviews/SKILL.md
@@ -91,7 +91,41 @@ Once you have the pieces:
}
```
-After creation, show the new topic ID so it can be handed off to the voice agent.
+After creation, capture the returned topic ID — you'll need it for Step 4 and for handing off to the voice agent.
+
+## Step 4: Optionally attach per-interviewee context
+
+The topic-level `agent_context` applies to every interviewee. If the user knows something specific about individual interviewees that should shape that one conversation, attach it as a per-interviewee row via `user-interview-topic-interviewees-create`. This is optional — most topics won't need it.
+
+Each row pairs an `interviewee_identifier` (must match one of the emails or distinct IDs in the parent topic's targeting) with an `agent_context` string. At most one row per (topic, interviewee). A user can have zero rows.
+
+Good per-interviewee context looks like:
+
+- "uses the replay product but has never used summarization"
+- "churned from Scale plan last month — be empathetic, don't pitch"
+- "founder, very technical, skip basic product explanations"
+
+After Step 3 succeeds, ask the user: _"Want to add per-interviewee context? Useful when individual people have very different backgrounds. You can either dictate the rows or paste a CSV."_
+
+### Accepting CSV input
+
+If the user pastes a CSV, expect two columns: `identifier,context`. Either with or without a header row. Examples:
+
+```csv
[email protected],uses replay but never summarization
[email protected],founder; very technical; skip product basics
+```
+
+Or with a header:
+
+```csv
+identifier,context
+abc-distinct-id-1,churned from Scale last month — be empathetic
+```
+
+Parse the CSV, then call `user-interview-topic-interviewees-create` once per row with the captured `topic_id`. Skip blank lines. Quote-escape commas inside the context cell — standard CSV rules.
+
+If a row's identifier isn't present in the parent topic's `interviewee_emails` or `interviewee_distinct_ids`, warn the user before creating — the voice agent looks up context by exact string match, so a mismatched identifier just gets ignored at runtime.
## What this skill is not for
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 15152ec9d873..ae915671a005 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -18966,6 +18966,22 @@ export namespace Schemas {
line_refs: string;
}
+ export interface IntervieweeContext {
+ readonly id: string;
+ readonly created_by: UserBasic;
+ readonly created_at: string;
+ /**
+ * Identifier for the interviewee — typically an email address or PostHog distinct ID. Must match a value in the parent topic's interviewee_emails or interviewee_distinct_ids.
+ * @maxLength 400
+ */
+ interviewee_identifier: string;
+ /**
+ * Extra context the voice agent should know about this specific interviewee — e.g. 'uses the replay product but has never used summarization'.
+ * @maxLength 10000
+ */
+ agent_context: string;
+ }
+
/**
* * `2.0` - 2.0
*/
@@ -21832,6 +21848,15 @@ export namespace Schemas {
results: IntegrationConfig[];
}
+ export interface PaginatedIntervieweeContextList {
+ count: number;
+ /** @nullable */
+ next?: string | null;
+ /** @nullable */
+ previous?: string | null;
+ results: IntervieweeContext[];
+ }
+
export interface PaginatedKnowledgeSourceList {
count: number;
/** @nullable */
@@ -27007,6 +27032,22 @@ export namespace Schemas {
readonly display_name?: string;
}
+ export interface PatchedIntervieweeContext {
+ readonly id?: string;
+ readonly created_by?: UserBasic;
+ readonly created_at?: string;
+ /**
+ * Identifier for the interviewee — typically an email address or PostHog distinct ID. Must match a value in the parent topic's interviewee_emails or interviewee_distinct_ids.
+ * @maxLength 400
+ */
+ interviewee_identifier?: string;
+ /**
+ * Extra context the voice agent should know about this specific interviewee — e.g. 'uses the replay product but has never used summarization'.
+ * @maxLength 10000
+ */
+ agent_context?: string;
+ }
+
export interface PatchedJsSnippetVersion {
/**
* Version pin: null for latest, "1.358.0" for exact, "1" for major, "1.358" for minor
@@ -39634,6 +39675,17 @@ export namespace Schemas {
search?: string;
};
+ export type UserInterviewTopicsIntervieweesListParams = {
+ /**
+ * Number of results to return per page.
+ */
+ limit?: number;
+ /**
+ * The initial index from which to return the results.
+ */
+ offset?: number;
+ };
+
export type UserInterviewsListParams = {
/**
* Number of results to return per page.