Skip to content

Commit 85c3e72

Browse files
committed
fix (integrations): added tool descriptions in connect modals
fix: gsheet whatsapp number issue and description
1 parent 0d25151 commit 85c3e72

File tree

7 files changed

+96
-26
lines changed

7 files changed

+96
-26
lines changed

src/client/app/integrations/page.js

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// src/client/app/integrations/page.js
12
"use client"
23

34
import React, { useState, useEffect, useCallback, useMemo, useRef } from "react"
@@ -59,6 +60,7 @@ import {
5960
import { Tooltip } from "react-tooltip"
6061
import ModalDialog from "@components/ModalDialog"
6162
import { useRouter } from "next/navigation"
63+
import { INTEGRATION_CAPABILITIES } from "@utils/integration-capabilities"
6264

6365
const integrationColorIcons = {
6466
gmail: IconMail,
@@ -86,7 +88,14 @@ const integrationColorIcons = {
8688

8789
const IconPlaceholder = IconSettingsCog
8890

89-
const PRO_ONLY_INTEGRATIONS = ["notion", "github", "slack", "discord", "trello", "whatsapp"]
91+
const PRO_ONLY_INTEGRATIONS = [
92+
"notion",
93+
"github",
94+
"slack",
95+
"discord",
96+
"trello",
97+
"whatsapp"
98+
]
9099

91100
const proPlanFeatures = [
92101
{ name: "Text Chat", limit: "100 messages per day" },
@@ -797,7 +806,8 @@ const IntegrationsPage = () => {
797806
const [activeCategory, setActiveCategory] = useState("Most Popular")
798807
const [selectedIntegration, setSelectedIntegration] = useState(null)
799808
const [activeManualIntegration, setActiveManualIntegration] = useState(null)
800-
const [isWhatsAppDisclaimerOpen, setIsWhatsAppDisclaimerOpen] = useState(false)
809+
const [isWhatsAppDisclaimerOpen, setIsWhatsAppDisclaimerOpen] =
810+
useState(false)
801811
const [isWhatsAppQRModalOpen, setIsWhatsAppQRModalOpen] = useState(false)
802812
const [sparkleTrigger, setSparkleTrigger] = useState(0)
803813
const [privacyModalService, setPrivacyModalService] = useState(null)
@@ -1349,6 +1359,9 @@ const IntegrationsPage = () => {
13491359
(integration) => {
13501360
const Icon =
13511361
integrationColorIcons[integration.name] || IconPlaceholder
1362+
const capabilities =
1363+
INTEGRATION_CAPABILITIES[integration.name] ||
1364+
"Capabilities for this integration will be detailed here soon."
13521365
return (
13531366
<MorphingDialogContent className="pointer-events-auto relative flex h-auto w-full flex-col overflow-hidden border border-neutral-700 bg-neutral-900 sm:w-[600px] rounded-2xl">
13541367
<BorderTrail className="bg-brand-orange" />
@@ -1369,9 +1382,15 @@ const IntegrationsPage = () => {
13691382
</div>
13701383
</div>
13711384
<MorphingDialogDescription>
1372-
<p className="text-sm sm:text-base text-neutral-300 mb-6">
1373-
{integration.description}
1374-
</p>
1385+
<div className="bg-neutral-800/50 p-4 rounded-lg border border-neutral-700/50 mb-6">
1386+
<h4 className="font-semibold text-white mb-2">
1387+
What I can do with{" "}
1388+
{integration.display_name}:
1389+
</h4>
1390+
<p className="text-sm text-neutral-300 leading-relaxed">
1391+
{capabilities}
1392+
</p>
1393+
</div>
13751394
{["gmail", "gcalendar"].includes(
13761395
integration.name
13771396
) && (
@@ -1411,11 +1430,12 @@ const IntegrationsPage = () => {
14111430
onClick={async (e) => {
14121431
e.stopPropagation()
14131432
if (
1414-
integration.name ===
1415-
"whatsapp"
1433+
integration.name === "whatsapp"
14161434
) {
14171435
// Show disclaimer first
1418-
setIsWhatsAppDisclaimerOpen(true)
1436+
setIsWhatsAppDisclaimerOpen(
1437+
true
1438+
)
14191439
} else if (
14201440
integration.auth_type ===
14211441
"composio"
@@ -1628,4 +1648,4 @@ const IntegrationsPage = () => {
16281648
)
16291649
}
16301650

1631-
export default IntegrationsPage
1651+
export default IntegrationsPage

src/client/app/onboarding/page.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ const questions = [
177177
{
178178
id: "whatsapp_notifications_number",
179179
question:
180-
"If you'd like to receive them, please enter your number with the country code. Otherwise, just press Enter to skip.",
180+
"If you'd like to enable this, please enter your number with the country code. Otherwise, just press Enter to skip.",
181181
type: "text-input",
182182
required: false,
183183
placeholder: "+14155552671",
@@ -191,7 +191,7 @@ const sentientComments = [
191191
"Perfect. Now, to help with local info like weather and places...",
192192
"This helps me understand your professional goals and context.",
193193
"And when you're not working? Tell me about your hobbies.",
194-
"One last thing. I can send you important updates on WhatsApp. We are in the process of getting an official number for Sentient. Until then, notifications will be sent via our co-founder Sarthak's number (+91827507823).",
194+
"One last thing. I can send you important notifications, task updates, and reminders on WhatsApp. We're in the process of getting an official number, so for now, messages will come from our co-founder Sarthak (+91827507823), who may also occasionally reach out for feedback.",
195195
"Awesome! That's all I need. Let's get you set up."
196196
]
197197

src/client/app/settings/page.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,16 +224,12 @@ const WhatsAppSettings = () => {
224224
WhatsApp Notifications
225225
</h2>
226226
<p className="text-neutral-400 mb-6">
227-
Receive important system notifications on WhatsApp.
227+
Receive important notifications, task updates, and reminders on WhatsApp.
228228
</p>
229229
<div className="bg-neutral-900/50 p-6 rounded-2xl border border-neutral-800">
230230
<div className="space-y-4">
231231
<p className="text-neutral-400 text-sm">
232-
Receive important notifications on WhatsApp. We are in
233-
the process of getting an official number for Sentient.
234-
Until then, notifications will be sent via our
235-
co-founder Sarthak's number (+91827507823). Please enter
236-
your number with the country code.
232+
Receive important notifications, task updates, and reminders on WhatsApp. We're in the process of getting an official number, so for now, messages will come from our co-founder Sarthak (+91827507823), who may also occasionally reach out for feedback. Please enter your number with the country code.
237233
</p>
238234
{isNotifLoading ? (
239235
<div className="flex justify-center mt-4">

src/client/jsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"paths": {
44
"@*": ["./*"],
55
"@components/*": ["./components/*"],
6-
"@hooks/*": ["./hooks/*"]
6+
"@hooks/*": ["./hooks/*"],
7+
"@utils/*": ["./utils/*"]
78
}
89
}
910
}

src/client/utils/integration-capabilities.js

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/server/main/auth/utils.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ async def _validate_token_and_get_payload(self, token: str) -> dict:
5555
permissions = AUTH0_SCOPE.split() if AUTH0_SCOPE else []
5656
return {
5757
"sub": "self-hosted-user",
58-
"permissions": permissions
58+
"permissions": permissions,
59+
"email": "selfhost@example.com" # Add a dummy email
5960
}
6061
else:
6162
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail="Invalid self-host token")
@@ -135,6 +136,11 @@ async def get_decoded_payload_with_claims(self, token: str = Depends(oauth2_sche
135136
if ENVIRONMENT == "selfhost": plan = "selfhost"
136137
elif "Pro" in payload.get(f"{AUTH0_NAMESPACE}/roles", []): plan = "pro"
137138
payload["plan"] = plan
139+
140+
# Add the namespaced email to the top-level 'email' key for convenience
141+
if AUTH0_NAMESPACE:
142+
payload["email"] = payload.get(f"{AUTH0_NAMESPACE}/email")
143+
138144
return payload
139145

140146
async def ws_authenticate_with_data(self, websocket: WebSocket) -> Optional[Dict]:

src/server/main/settings/routes.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from main.auth.utils import PermissionChecker, AuthHelper
88
from main.notifications.whatsapp_client import check_phone_number_exists
99
from main.settings.models import WhatsAppMcpRequest, WhatsAppNotificationNumberRequest, ProfileUpdateRequest
10+
from main.settings.google_sheets_utils import update_contact_in_sheet
1011

1112
logger = logging.getLogger(__name__)
1213
router = APIRouter(
@@ -82,8 +83,20 @@ async def get_whatsapp_mcp_number(
8283
@router.post("/whatsapp-notifications", summary="Set or Update WhatsApp number for notifications")
8384
async def set_whatsapp_notification_number(
8485
request: WhatsAppNotificationNumberRequest,
85-
user_id: str = Depends(PermissionChecker(required_permissions=["write:config"]))
86+
payload: dict = Depends(auth_helper.get_decoded_payload_with_claims)
8687
):
88+
# 1. First, ensure the user has the required permission from the token payload
89+
required_permission = "write:config"
90+
if required_permission not in payload.get("permissions", []):
91+
raise HTTPException(
92+
status_code=status.HTTP_403_FORBIDDEN,
93+
detail=f"Missing required permission: {required_permission}"
94+
)
95+
96+
# 2. Extract user_id and email directly from the validated token payload
97+
user_id = payload.get("sub")
98+
user_email = payload.get("email") # This is the reliable email from Auth0
99+
87100
whatsapp_number = request.whatsapp_notifications_number.strip() if request.whatsapp_notifications_number else ""
88101
if not whatsapp_number:
89102
update_payload = {
@@ -110,15 +123,15 @@ async def set_whatsapp_notification_number(
110123
}
111124
await mongo_manager.update_user_profile(user_id, update_payload)
112125

113-
# --- NEW: Update Google Sheet ---
126+
# 3. Update Google Sheet using the reliable email from the token
114127
try:
115-
user_profile = await mongo_manager.get_user_profile(user_id)
116-
user_email = user_profile.get("userData", {}).get("personalInfo", {}).get("email")
117128
if user_email:
118129
await update_contact_in_sheet(user_email, whatsapp_number)
130+
else:
131+
logger.warning(f"Could not update Google Sheet for user {user_id} because no email was found in their token.")
119132
except Exception as e:
120-
logger.error(f"Non-critical error: Failed to update Google Sheet for user {user_id} after setting WA number. Error: {e}")
121-
# --- END NEW ---
133+
logger.error(f"Non-critical error: Failed to update Google Sheet for user {user_id}. Error: {e}")
134+
122135
return JSONResponse(content={"message": "WhatsApp notification number updated successfully."})
123136

124137
except ConnectionError as e:
@@ -165,4 +178,4 @@ async def update_profile_data(
165178
return JSONResponse(content={"message": "Profile updated successfully."})
166179
except Exception as e:
167180
logger.error(f"Error updating profile for user {user_id}: {e}", exc_info=True)
168-
raise HTTPException(status_code=500, detail="An unexpected error occurred.")
181+
raise HTTPException(status_code=500, detail="An unexpected error occurred.")

0 commit comments

Comments
 (0)