-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrate Crisp chatbot for immediate user support access. This enables real-time interaction, enhancing user experience by providing quick assistance.
- Loading branch information
1 parent
ac86a4e
commit 9232643
Showing
7 changed files
with
62 additions
and
1 deletion.
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
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,43 @@ | ||
import { Crisp } from 'crisp-sdk-web'; | ||
import { useEffect } from 'react'; | ||
|
||
import { User } from '@/core'; | ||
|
||
const isCrispConfigured = (): boolean => { | ||
return typeof window !== 'undefined' && !!window.$crisp; | ||
}; | ||
|
||
export const initializeSupportSession = (user: User) => { | ||
if (!isCrispConfigured()) { | ||
return; | ||
} | ||
Crisp.setTokenId(user.id); | ||
Crisp.user.setEmail(user.email); | ||
}; | ||
|
||
export const terminateSupportSession = () => { | ||
if (!isCrispConfigured()) { | ||
return; | ||
} | ||
Crisp.session.reset(); | ||
}; | ||
|
||
/** | ||
* Configure Crisp chat for real-time support across all pages. | ||
*/ | ||
export const useSupport = () => { | ||
useEffect(() => { | ||
const CRISP_WEBSITE_ID = process.env.NEXT_PUBLIC_CRISP_WEBSITE_ID; | ||
|
||
if (!CRISP_WEBSITE_ID) { | ||
console.warn('Crisp Website ID is not set'); | ||
return; | ||
} | ||
if (isCrispConfigured()) { | ||
return; | ||
} | ||
Crisp.configure(CRISP_WEBSITE_ID); | ||
}, []); | ||
|
||
return null; | ||
}; |
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