Skip to content

Commit e7df5ba

Browse files
Remove supportFormConfig from Inkeep component (#1339)
* Remove supportFormConfig from Inkeep component Co-Authored-By: Alek Petuskey <[email protected]> * Remove getHelpOptions from Inkeep component Co-Authored-By: Alek Petuskey <[email protected]> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Alek Petuskey <[email protected]>
1 parent 7619aea commit e7df5ba

File tree

1 file changed

+1
-128
lines changed

1 file changed

+1
-128
lines changed

pcweb/components/docpage/navbar/inkeep.py

Lines changed: 1 addition & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -23,124 +23,6 @@ def add_hooks(self):
2323
return [
2424
"const { resolvedColorMode } = useContext(ColorModeContext)",
2525
"""
26-
const supportFormConfig = {
27-
heading: "Contact support",
28-
fields: [
29-
{
30-
label: 'Name',
31-
name: 'first_name',
32-
inputType: 'text',
33-
},
34-
{
35-
label: 'Company Email',
36-
name: 'email',
37-
inputType: 'email',
38-
isRequired: true,
39-
},
40-
{
41-
_type: 'include_chat_session',
42-
label: 'Include chat history',
43-
defaultValue: true,
44-
name: 'include_chat_session',
45-
},
46-
{
47-
label: 'Additional details',
48-
name: 'additional_details',
49-
inputType: 'textarea',
50-
},
51-
{
52-
label: 'Category',
53-
name: 'category',
54-
inputType: 'select',
55-
items: [
56-
{
57-
label: 'Bug',
58-
value: 'BUG',
59-
},
60-
{
61-
label: 'Feature idea',
62-
value: 'FEATURE',
63-
},
64-
{
65-
label: 'Account access',
66-
value: 'ACCOUNT',
67-
},
68-
],
69-
},
70-
],
71-
buttons: {
72-
submit: {
73-
onSubmit: async ({ values, conversation }) => {
74-
const webhookUrl = 'https://discord.com/api/webhooks/1338969279760044112/W9BeoqhcHGvi3uIRPoGgYwybFfxeH1g0yWANxBS-tQ8XbSN32SzCV6IVjkHLfjlc_hJn'
75-
if (!webhookUrl) {
76-
console.error('Discord webhook URL is not set in the environment.')
77-
return
78-
}
79-
80-
const currentUrl = window.location.href
81-
82-
// Build the chat history string manually
83-
let chatHistory = '**Chat History:**'
84-
const messages = conversation?.messages || []
85-
for (let i = 0; i < messages.length; i++) {
86-
const message = messages[i]
87-
const role = message.role === 'user' ? 'User' : 'Assistant'
88-
const content =
89-
typeof message.content === 'string'
90-
? message.content
91-
: message.content[0].text
92-
chatHistory += ` **${i + 1}. ${role}:** ${content}\n`;
93-
}
94-
95-
// Build a simple and readable message
96-
const discordMessage = `
97-
**New Support Request**
98-
99-
**Name:** ${values.first_name || "N/A"}
100-
**Email:** ${values.email || "N/A"}
101-
**Category:** ${values.category || "N/A"}
102-
**Additional Details:** ${values.additional_details || "N/A"}
103-
104-
**Current Page URL:** ${currentUrl || "N/A"}
105-
106-
**Chat Session ID:** ${conversation?.id || "N/A"}
107-
${chatHistory || "**Chat History:** No messages available."}
108-
`;
109-
110-
// Prepare the payload
111-
const payload = { content: discordMessage };
112-
113-
try {
114-
// Send the payload to the Discord webhook
115-
const response = await fetch(webhookUrl, {
116-
method: 'POST',
117-
headers: {
118-
'Content-Type': 'application/json',
119-
},
120-
body: JSON.stringify(payload),
121-
})
122-
123-
if (!response.ok) {
124-
throw new Error(`Failed to send message: ${response.statusText}`)
125-
}
126-
127-
console.log('Values sent successfully to Discord!')
128-
} catch (error) {
129-
console.error('Error sending values to Discord:', error)
130-
}
131-
},
132-
},
133-
},
134-
successView: {
135-
heading: 'Thank you!',
136-
message: 'Your form has been submitted successfully.',
137-
doneButton: {
138-
label: 'Back to chat',
139-
icon: { builtIn: 'LuArrowLeft' },
140-
action: 'return_to_chat',
141-
},
142-
},
143-
};
14426
const escalationParams = {
14527
type: "object",
14628
properties: {
@@ -404,7 +286,6 @@ def add_hooks(self):
404286
label: "Contact Support",
405287
action: {
406288
'type': 'open_form',
407-
formSettings: supportFormConfig,
408289
},
409290
}
410291
];
@@ -413,15 +294,7 @@ def add_hooks(self):
413294
},
414295
},
415296
],
416-
getHelpOptions: [
417-
{
418-
name: 'Get help',
419-
action: {
420-
type: 'open_form',
421-
formSettings: supportFormConfig,
422-
},
423-
},
424-
],
297+
425298
},
426299
};""",
427300
]

0 commit comments

Comments
 (0)