-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add crisp chatbot to allow users for interaction. Create a new crisp chatbot component for this and populate with user info.
- Loading branch information
1 parent
ac86a4e
commit f6911f3
Showing
6 changed files
with
47 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
NEXT_PUBLIC_API_ORIGIN= | ||
NEXT_PUBLIC_Y_PROVIDER_URL= | ||
NEXT_PUBLIC_MEDIA_URL= | ||
NEXT_PUBLIC_THEME=dsfr | ||
NEXT_PUBLIC_THEME=dsfr | ||
NEXT_PUBLIC_CRISP_WEBSITE_ID= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Crisp } from 'crisp-sdk-web'; | ||
import { useEffect } from 'react'; | ||
|
||
import { useAuthStore } from '@/core/auth'; | ||
|
||
const CrispChat = () => { | ||
const { userData } = useAuthStore(); | ||
|
||
useEffect(() => { | ||
const CRISP_WEBSITE_ID = process.env.NEXT_PUBLIC_CRISP_WEBSITE_ID; | ||
if (CRISP_WEBSITE_ID) { | ||
Crisp.configure(CRISP_WEBSITE_ID); | ||
|
||
// Identify user if available | ||
if (userData) { | ||
Crisp.user.setEmail(userData.email); | ||
} | ||
} else { | ||
console.warn('Crisp Website ID is not set'); | ||
} | ||
}, [userData]); | ||
|
||
return null; | ||
}; | ||
|
||
export default CrispChat; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
declare module 'crisp-sdk-web' { | ||
export const Crisp: { | ||
configure: (websiteId: string) => void; | ||
user: { | ||
setEmail: (email: string) => void; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters