Skip to content

Commit

Permalink
fix: 🐛 disable help form if conversationId undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
gmpetrov committed Sep 24, 2023
1 parent 1709274 commit 400d34e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 96 deletions.
10 changes: 9 additions & 1 deletion components/ChatBubble.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function App(props: { agentId: string; initConfig?: AgentInterfaceConfig }) {
config: props.initConfig || defaultChatBubbleConfig,
hasOpenOnce: false,
showInitialMessage: false,
showHelp: true,
showHelp: false,
showCaptureForm: false,
isCaptureLoading: false,
visitorEmail: '',
Expand Down Expand Up @@ -172,6 +172,14 @@ function App(props: { agentId: string; initConfig?: AgentInterfaceConfig }) {
}
}, []);

useEffect(() => {
if (conversationId) {
setState({
showHelp: true,
})
}
}, [conversationId])

// useEffect(() => {
// if (config?.theme) {
// setMode(config.theme!);
Expand Down
95 changes: 0 additions & 95 deletions pages/api/agents/[id]/capture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,101 +78,6 @@ export const capture = async (req: AppNextApiRequest, res: NextApiResponse) => {
throw new ApiError(ApiErrorType.INVALID_REQUEST);
}

const html = `
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<title>Welcome Email</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Josefin+Sans:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;1,100;1,200;1,300;1,400;1,500;1,600;1,700&display=swap"
rel="stylesheet"
/>
<style>
* {
font-family: 'Josefin Sans', sans-serif;
}
h2 {
}
.history {
display: flex;
flex-direction: column;
}
.message {
margin-right: auto;
border: 1px solid rgba(0, 0, 0, 0.5);
border-radius: 8px;
padding: 2px 8px;
margin-bottom: 10px;
}
.agent {
background-color: #000;
color: white;
margin-left: 10px;
}
.message p {
padding: 0;
line-height: 2rem;
margin: 0;
}
.reply > div {
margin-top: 20px;
padding: 10px 15px;
border: 2px solid white;
display: inline-flex;
border-radius: 100px;
background-color: #5937a8;
color: white;
font-size: 1rem;
margin-bottom: 80px;
}
</style>
</head>
<body>
<h2>ChatbotGPT.ai</h2>
<h3>Visitor requested assistance</h3>
<p>Visitor Email: <strong>${data.visitorEmail}</strong></p>
<p>A visitor has requested assistance from your agent ${agent?.name}</p>
<p>Conversation History:</p>
<table class="history">
${agent?.conversations?.[0]?.messages
?.map(
(message) => `
<tr>
<td>
<div class="message ${message.from}">
<p>${message.text}</p>
</div>
</td>
</tr>
`
)
.join('\n')}
</table>
<a href="mailto:${data.visitorEmail}" class="reply">
<div>Reply</div>
</a>
</body>
</html>
`;

await Promise.all([
prisma.lead.create({
data: {
Expand Down

0 comments on commit 400d34e

Please sign in to comment.