Skip to content

Commit

Permalink
Use papercups for in-app support (airbytehq#1329)
Browse files Browse the repository at this point in the history
  • Loading branch information
michel-tricot authored Dec 15, 2020
1 parent 758daaa commit 57d9e30
Show file tree
Hide file tree
Showing 8 changed files with 690 additions and 51 deletions.
1 change: 1 addition & 0 deletions airbyte-webapp/nginx/default.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ server {
sub_filter </head>
'</head><script language="javascript"\>
window.TRACKING_STRATEGY = "$TRACKING_STRATEGY";
window.PAPERCUPS_STORYTIME = "$PAPERCUPS_STORYTIME";
window.AIRBYTE_VERSION = "$AIRBYTE_VERSION";
window.API_URL = "$API_URL";
</script>';
Expand Down
677 changes: 626 additions & 51 deletions airbyte-webapp/package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions airbyte-webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"@fortawesome/free-solid-svg-icons": "^5.12.1",
"@fortawesome/react-fontawesome": "^0.1.8",
"@hot-loader/react-dom": "16.13.0",
"@papercups-io/chat-widget": "^1.1.5",
"@papercups-io/storytime": "^1.0.6",
"dayjs": "^1.8.35",
"formik": "2.1.5",
"lodash.at": "^4.6.0",
Expand Down
41 changes: 41 additions & 0 deletions airbyte-webapp/src/components/SupportChat/SupportChat.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React, { useEffect } from "react";
import ChatWidget from "@papercups-io/chat-widget";
import { Storytime } from "@papercups-io/storytime";

type PapercupsConfig = {
accountId: string;
baseUrl: string;
enableStorytime: boolean;
};

type IProps = {
papercupsConfig: PapercupsConfig;
customerId: string;
};

const SupportChat: React.FC<IProps> = ({ papercupsConfig, customerId }) => {
useEffect(() => {
if (papercupsConfig.enableStorytime) {
Storytime.init({
accountId: papercupsConfig.accountId,
baseUrl: papercupsConfig.baseUrl,
customer: { external_id: customerId }
});
}
}, [customerId, papercupsConfig]);

return (
<ChatWidget
title="Welcome to Airbyte"
subtitle="Ask us anything in the chat window below 😊"
primaryColor="#625eff"
greeting="Hello!!!"
newMessagePlaceholder="Start typing..."
customer={{ external_id: customerId }}
accountId={papercupsConfig.accountId}
baseUrl={papercupsConfig.baseUrl}
/>
);
};

export default SupportChat;
3 changes: 3 additions & 0 deletions airbyte-webapp/src/components/SupportChat/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import SupportChat from "./SupportChat";

export default SupportChat;
11 changes: 11 additions & 0 deletions airbyte-webapp/src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
declare global {
interface Window {
TRACKING_STRATEGY?: string;
PAPERCUPS_STORYTIME?: string;
AIRBYTE_VERSION?: string;
API_URL?: string;
}
Expand All @@ -14,6 +15,11 @@ const config: {
tutorialLink: string;
};
segment: { token: string };
papercups: {
accountId: string;
baseUrl: string;
enableStorytime: boolean;
};
apiUrl: string;
version?: string;
} = {
Expand All @@ -31,6 +37,11 @@ const config: {
"6cxNSmQyGSKcATLdJ2pL6WsawkzEMDAN"
: ""
},
papercups: {
accountId: "74560291-451e-4ceb-a802-56706ece528b",
baseUrl: "https://app.papercups.io",
enableStorytime: window.PAPERCUPS_STORYTIME !== "disabled"
},
version: window.AIRBYTE_VERSION,
apiUrl:
window.API_URL ||
Expand Down
5 changes: 5 additions & 0 deletions airbyte-webapp/src/pages/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import WorkspaceResource from "../core/resources/Workspace";
import useSegment from "../components/hooks/useSegment";
import { AnalyticsService } from "../core/analytics/AnalyticsService";
import useRouter from "../components/hooks/useRouterHook";
import SupportChat from "../components/SupportChat";

export enum Routes {
Preferences = "/preferences",
Expand Down Expand Up @@ -152,6 +153,10 @@ export const Routing = () => {
) : (
<MainViewRoutes />
)}
<SupportChat
papercupsConfig={config.papercups}
customerId={workspace.customerId}
/>
</Suspense>
</Router>
);
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ services:
- server
environment:
- TRACKING_STRATEGY=${TRACKING_STRATEGY}
- PAPERCUPS_STORYTIME=${PAPERCUPS_STORYTIME:-}
- AIRBYTE_VERSION=${VERSION}
- AIRBYTE_ROLE=${AIRBYTE_ROLE:-}
- API_URL=${API_URL}
Expand Down

0 comments on commit 57d9e30

Please sign in to comment.