Skip to content

Commit

Permalink
Front: Display Intercom connections as coming soon (#2569)
Browse files Browse the repository at this point in the history
* Front: Display Intercom connections as coming soon

* Apply Gab's feedback
  • Loading branch information
PopDaph authored Nov 17, 2023
1 parent 3fe2359 commit 46690a2
Show file tree
Hide file tree
Showing 20 changed files with 116 additions and 9 deletions.
3 changes: 3 additions & 0 deletions front/admin/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ const workspace = async (command: string, args: parseArgs.ParsedArgs) => {
console.log(
` managed Github: ${plan.limits.connections.isGithubAllowed}`
);
console.log(
` managed Intercom: ${plan.limits.connections.isIntercomAllowed}`
);
console.log(
` managed Google Drive: ${plan.limits.connections.isGoogleDriveAllowed}`
);
Expand Down
3 changes: 3 additions & 0 deletions front/components/ConnectorPermissionsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const CONNECTOR_TYPE_TO_RESOURCE_NAME: Record<ConnectorProvider, string> = {
google_drive: "Google Drive folders",
slack: "Slack channels",
github: "GitHub repositories",
intercom: "Intercom Help Center articles",
};

const CONNECTOR_TYPE_TO_RESOURCE_LIST_TITLE_TEXT: Record<
Expand All @@ -30,6 +31,7 @@ const CONNECTOR_TYPE_TO_RESOURCE_LIST_TITLE_TEXT: Record<
notion: null,
google_drive: null,
github: null,
intercom: null,
};

const CONNECTOR_TYPE_TO_DEFAULT_PERMISSION_TITLE_TEXT: Record<
Expand All @@ -40,6 +42,7 @@ const CONNECTOR_TYPE_TO_DEFAULT_PERMISSION_TITLE_TEXT: Record<
notion: null,
google_drive: null,
github: null,
intercom: null,
};

const PERMISSIONS_EDITABLE_CONNECTOR_TYPES: Set<ConnectorProvider> = new Set([
Expand Down
1 change: 1 addition & 0 deletions front/components/ConnectorPermissionsTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const CONNECTOR_TYPE_TO_PERMISSIONS: Record<
},
notion: undefined,
github: undefined,
intercom: undefined,
};

function PermissionTreeChildren({
Expand Down
1 change: 1 addition & 0 deletions front/components/assistant_builder/AssistantBuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export const CONNECTOR_PROVIDER_TO_RESOURCE_NAME: Record<
google_drive: { singular: "folder", plural: "folders" },
slack: { singular: "channel", plural: "channels" },
github: { singular: "repository", plural: "repositories" },
intercom: { singular: "article", plural: "articles" },
};

export type AssistantBuilderDataSourceConfiguration = {
Expand Down
1 change: 1 addition & 0 deletions front/components/assistant_builder/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const CONNECTOR_PROVIDER_TO_RESOURCE_NAME: Record<
google_drive: { singular: "folder", plural: "folders" },
slack: { singular: "channel", plural: "channels" },
github: { singular: "repository", plural: "repositories" },
intercom: { singular: "article", plural: "articles" },
};

export const DROID_AVATARS_BASE_PATH = "/static/droidavatar/";
Expand Down
11 changes: 11 additions & 0 deletions front/components/poke/plans/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
DropdownMenu,
GithubLogo,
Input,
IntercomLogo,
NotionLogo,
SlackLogo,
} from "@dust-tt/sparkle";
Expand All @@ -21,6 +22,7 @@ export type EditingPlanType = {
isNotionAllowed: boolean;
isGoogleDriveAllowed: boolean;
isGithubAllowed: boolean;
isIntercomAllowed: boolean;
maxMessages: string | number;
dataSourcesCount: string | number;
dataSourcesDocumentsCount: string | number;
Expand All @@ -40,6 +42,7 @@ export const fromPlanType = (plan: PlanType): EditingPlanType => {
isNotionAllowed: plan.limits.connections.isNotionAllowed,
isGoogleDriveAllowed: plan.limits.connections.isGoogleDriveAllowed,
isGithubAllowed: plan.limits.connections.isGithubAllowed,
isIntercomAllowed: plan.limits.connections.isIntercomAllowed,
maxMessages: plan.limits.assistant.maxMessages,
dataSourcesCount: plan.limits.dataSources.count,
dataSourcesDocumentsCount: plan.limits.dataSources.documents.count,
Expand All @@ -64,6 +67,7 @@ export const toPlanType = (editingPlan: EditingPlanType): PlanType => {
isNotionAllowed: editingPlan.isNotionAllowed,
isGoogleDriveAllowed: editingPlan.isGoogleDriveAllowed,
isGithubAllowed: editingPlan.isGithubAllowed,
isIntercomAllowed: editingPlan.isIntercomAllowed,
},
dataSources: {
count: parseInt(editingPlan.dataSourcesCount.toString(), 10),
Expand Down Expand Up @@ -92,6 +96,7 @@ const getEmptyPlan = (): EditingPlanType => ({
isNotionAllowed: false,
isGoogleDriveAllowed: false,
isGithubAllowed: false,
isIntercomAllowed: false,
maxMessages: "",
dataSourcesCount: "",
dataSourcesDocumentsCount: "",
Expand Down Expand Up @@ -199,6 +204,12 @@ export const PLAN_FIELDS = {
title: "Github",
IconComponent: () => <GithubLogo className="h-4 w-4" />,
},
isIntercomAllowed: {
type: "boolean",
width: "tiny",
title: "Intercom",
IconComponent: () => <IntercomLogo className="h-4 w-4" />,
},
maxMessages: {
type: "number",
width: "medium",
Expand Down
1 change: 1 addition & 0 deletions front/lib/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ export async function subscriptionForWorkspace(
isNotionAllowed: plan.isManagedNotionAllowed,
isGoogleDriveAllowed: plan.isManagedGoogleDriveAllowed,
isGithubAllowed: plan.isManagedGithubAllowed,
isIntercomAllowed: plan.isManagedIntercomAllowed,
},
dataSources: {
count: plan.maxDataSourcesCount,
Expand Down
19 changes: 18 additions & 1 deletion front/lib/connector_providers.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { DriveLogo, GithubLogo, NotionLogo, SlackLogo } from "@dust-tt/sparkle";
import {
DriveLogo,
GithubLogo,
IntercomLogo,
NotionLogo,
SlackLogo,
} from "@dust-tt/sparkle";

import { ConnectorProvider } from "@app/lib/connectors_api";
import { isDevelopment } from "@app/lib/development";

export const CONNECTOR_CONFIGURATIONS: Record<
ConnectorProvider,
Expand Down Expand Up @@ -54,4 +61,14 @@ export const CONNECTOR_CONFIGURATIONS: Record<
logoComponent: GithubLogo,
isNested: false,
},
intercom: {
name: "Intercom",
connectorProvider: "intercom",
isBuilt: isDevelopment(), // TODO @daph Activate Intercom connector
logoPath: "/static/intercom_32x32.png",
description:
"Authorize granular access to your company's Intercom Help Centers. Dust does not access your conversations.",
logoComponent: IntercomLogo,
isNested: false,
},
};
2 changes: 2 additions & 0 deletions front/lib/connectors_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ const CONNECTOR_PROVIDERS = [
"notion",
"github",
"google_drive",
"intercom",
] as const;
export type ConnectorProvider = (typeof CONNECTOR_PROVIDERS)[number];
export const CONNECTOR_PROVIDERS_USING_NANGO = [
"slack",
"notion",
"google_drive",
"intercom",
] as const;
type ConnectorProviderUsingNango =
(typeof CONNECTOR_PROVIDERS_USING_NANGO)[number];
Expand Down
3 changes: 2 additions & 1 deletion front/lib/data_sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ export function getProviderLogoPathForDataSource(
return `/static/github_black_32x32.png`;
case "google_drive":
return `/static/google_drive_32x32.png`;

case "intercom":
return `/static/intercom_32x32.png`;
default:
// eslint-disable-next-line @typescript-eslint/no-unused-vars
((_provider: never) => {
Expand Down
5 changes: 5 additions & 0 deletions front/lib/models/plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class Plan extends Model<
declare isManagedNotionAllowed: boolean;
declare isManagedGoogleDriveAllowed: boolean;
declare isManagedGithubAllowed: boolean;
declare isManagedIntercomAllowed: boolean;
declare maxDataSourcesCount: number;
declare maxDataSourcesDocumentsCount: number;
declare maxDataSourcesDocumentsSizeMb: number;
Expand Down Expand Up @@ -110,6 +111,10 @@ Plan.init(
type: DataTypes.BOOLEAN,
defaultValue: false,
},
isManagedIntercomAllowed: {
type: DataTypes.BOOLEAN,
defaultValue: false,
},
maxDataSourcesCount: {
type: DataTypes.INTEGER,
allowNull: false,
Expand Down
1 change: 1 addition & 0 deletions front/lib/plans/enterprise_plans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const ENT_PLAN_FAKE_DATA: PlanAttributes = {
isManagedNotionAllowed: true,
isManagedGoogleDriveAllowed: true,
isManagedGithubAllowed: true,
isManagedIntercomAllowed: true,
maxDataSourcesCount: -1,
maxDataSourcesDocumentsCount: -1,
maxDataSourcesDocumentsSizeMb: 2,
Expand Down
2 changes: 2 additions & 0 deletions front/lib/plans/free_plans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const FREE_TEST_PLAN_DATA: PlanAttributes = {
isManagedNotionAllowed: false,
isManagedGoogleDriveAllowed: false,
isManagedGithubAllowed: false,
isManagedIntercomAllowed: false,
maxDataSourcesCount: 5,
maxDataSourcesDocumentsCount: 10,
maxDataSourcesDocumentsSizeMb: 2,
Expand All @@ -58,6 +59,7 @@ const FREE_PLANS_DATA: PlanAttributes[] = [
isManagedNotionAllowed: true,
isManagedGoogleDriveAllowed: true,
isManagedGithubAllowed: true,
isManagedIntercomAllowed: true,
maxDataSourcesCount: -1,
maxDataSourcesDocumentsCount: -1,
maxDataSourcesDocumentsSizeMb: 2,
Expand Down
1 change: 1 addition & 0 deletions front/lib/plans/pro_plans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ if (isDevelopment()) {
isManagedNotionAllowed: true,
isManagedGoogleDriveAllowed: true,
isManagedGithubAllowed: true,
isManagedIntercomAllowed: true,
maxDataSourcesCount: -1,
maxDataSourcesDocumentsCount: -1,
maxDataSourcesDocumentsSizeMb: 2,
Expand Down
3 changes: 3 additions & 0 deletions front/lib/plans/subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export const internalSubscribeWorkspaceToFreeTestPlan = async ({
isNotionAllowed: freeTestPlan.isManagedNotionAllowed,
isGoogleDriveAllowed: freeTestPlan.isManagedGoogleDriveAllowed,
isGithubAllowed: freeTestPlan.isManagedGithubAllowed,
isIntercomAllowed: freeTestPlan.isManagedIntercomAllowed,
},
dataSources: {
count: freeTestPlan.maxDataSourcesCount,
Expand Down Expand Up @@ -178,6 +179,7 @@ export const internalSubscribeWorkspaceToFreeUpgradedPlan = async ({
isNotionAllowed: plan.isManagedNotionAllowed,
isGoogleDriveAllowed: plan.isManagedGoogleDriveAllowed,
isGithubAllowed: plan.isManagedGithubAllowed,
isIntercomAllowed: plan.isManagedIntercomAllowed,
},
dataSources: {
count: plan.maxDataSourcesCount,
Expand Down Expand Up @@ -332,6 +334,7 @@ export const getCheckoutUrlForUpgrade = async (
isNotionAllowed: plan.isManagedNotionAllowed,
isGoogleDriveAllowed: plan.isManagedGoogleDriveAllowed,
isGithubAllowed: plan.isManagedGithubAllowed,
isIntercomAllowed: plan.isManagedIntercomAllowed,
},
dataSources: {
count: plan.maxDataSourcesCount,
Expand Down
3 changes: 3 additions & 0 deletions front/pages/api/poke/plans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const PlanTypeSchema = t.type({
isNotionAllowed: t.boolean,
isGoogleDriveAllowed: t.boolean,
isGithubAllowed: t.boolean,
isIntercomAllowed: t.boolean,
}),
dataSources: t.type({
count: t.number,
Expand Down Expand Up @@ -91,6 +92,7 @@ async function handler(
isNotionAllowed: plan.isManagedNotionAllowed,
isGoogleDriveAllowed: plan.isManagedGoogleDriveAllowed,
isGithubAllowed: plan.isManagedGithubAllowed,
isIntercomAllowed: plan.isManagedIntercomAllowed,
},
dataSources: {
count: plan.maxDataSourcesCount,
Expand Down Expand Up @@ -178,6 +180,7 @@ async function handler(
isManagedGoogleDriveAllowed:
body.limits.connections.isGoogleDriveAllowed,
isManagedGithubAllowed: body.limits.connections.isGithubAllowed,
isManagedIntercomAllowed: body.limits.connections.isIntercomAllowed,
maxDataSourcesCount: body.limits.dataSources.count,
maxDataSourcesDocumentsCount: body.limits.dataSources.documents.count,
maxDataSourcesDocumentsSizeMb: body.limits.dataSources.documents.sizeMb,
Expand Down
5 changes: 4 additions & 1 deletion front/pages/api/w/[wId]/data_sources/managed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async function handler(

if (
!req.body.provider ||
!["slack", "notion", "github", "google_drive"].includes(
!["slack", "notion", "github", "google_drive", "intercom"].includes(
req.body.provider
)
) {
Expand Down Expand Up @@ -133,6 +133,9 @@ async function handler(
isDataSourceAllowedInPlan =
plan.limits.connections.isGoogleDriveAllowed;
break;
case "intercom":
isDataSourceAllowedInPlan = plan.limits.connections.isIntercomAllowed;
break;
default:
isDataSourceAllowedInPlan = false; // default to false if provider is not recognized
}
Expand Down
9 changes: 9 additions & 0 deletions front/pages/w/[wId]/builder/data-sources/[name]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const {
NANGO_SLACK_CONNECTOR_ID = "",
NANGO_NOTION_CONNECTOR_ID = "",
NANGO_GOOGLE_DRIVE_CONNECTOR_ID = "",
NANGO_INTERCOM_CONNECTOR_ID = "",
NANGO_PUBLIC_KEY = "",
GITHUB_APP_URL = "",
} = process.env;
Expand All @@ -67,6 +68,7 @@ export const getServerSideProps: GetServerSideProps<{
slackConnectorId: string;
notionConnectorId: string;
googleDriveConnectorId: string;
intercomConnectorId: string;
};
githubAppUrl: string;
gaTrackingId: string;
Expand Down Expand Up @@ -125,6 +127,7 @@ export const getServerSideProps: GetServerSideProps<{
slackConnectorId: NANGO_SLACK_CONNECTOR_ID,
notionConnectorId: NANGO_NOTION_CONNECTOR_ID,
googleDriveConnectorId: NANGO_GOOGLE_DRIVE_CONNECTOR_ID,
intercomConnectorId: NANGO_INTERCOM_CONNECTOR_ID,
},
githubAppUrl: GITHUB_APP_URL,
gaTrackingId: GA_TRACKING_ID,
Expand Down Expand Up @@ -434,6 +437,7 @@ const CONNECTOR_TYPE_TO_HELPER_TEXT: Record<ConnectorProvider, string> = {
google_drive: "Google Drive folders and files Dust has access to.",
slack: "Slack channels synchronized with Dust:",
github: "GitHub repositories Dust has access to.",
intercom: "Intercom Help Centers synchronized with Dust:",
};

const CONNECTOR_TYPE_TO_MISMATCH_ERROR: Record<ConnectorProvider, string> = {
Expand All @@ -444,6 +448,8 @@ const CONNECTOR_TYPE_TO_MISMATCH_ERROR: Record<ConnectorProvider, string> = {
"You cannot select another Github Organization.\nPlease contact us at [email protected] if you initially selected a wrong Organization.",
google_drive:
"You cannot select another Google Drive Domain.\nPlease contact us at [email protected] if you initially selected a wrong shared Drive.",
intercom:
"You cannot select another Intercom Workspace.\nPlease contact us at [email protected] if you initially selected a wrong Workspace.",
};

function ManagedDataSourceView({
Expand All @@ -466,6 +472,7 @@ function ManagedDataSourceView({
slackConnectorId: string;
notionConnectorId: string;
googleDriveConnectorId: string;
intercomConnectorId: string;
};
githubAppUrl: string;
plan: PlanType;
Expand Down Expand Up @@ -518,6 +525,7 @@ function ManagedDataSourceView({
slack: nangoConfig.slackConnectorId,
notion: nangoConfig.notionConnectorId,
google_drive: nangoConfig.googleDriveConnectorId,
intercom: nangoConfig.intercomConnectorId,
}[provider];

const nango = new Nango({ publicKey: nangoConfig.publicKey });
Expand Down Expand Up @@ -670,6 +678,7 @@ function ManagedDataSourceView({
);
case "notion":
case "github":
case "intercom":
return (
<Button
label="Add / Remove data, manage permissions"
Expand Down
Loading

0 comments on commit 46690a2

Please sign in to comment.