quivr/frontend/lib/helpers/intercom/intercom.ts
Antoine Dewez 04d6c3432f
feat(frontend): add a chatbot for users (#2144)
# Description

Please include a summary of the changes and the related issue. Please
also include relevant motivation and context.

## Checklist before requesting a review

Please delete options that are not relevant.

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented hard-to-understand areas
- [ ] I have ideally added tests that prove my fix is effective or that
my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged

## Screenshots (if appropriate):
2024-02-04 22:06:24 -08:00

18 lines
1.1 KiB
TypeScript

/* eslint-disable */
export const APP_ID = process.env.NEXT_PUBLIC_INTERCOM_APP_ID;
// prettier-ignore
export const load = (): void => {
(function(){const w=window;const ic=(w as any).Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',(w as any).intercomSettings);}else{const d=document;const i=function(){i.c(arguments);};i.q=[] as any[];i.c=function(args: any){i.q.push(args);};(w as any).Intercom=i;const l=function(){const s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/' + APP_ID;const x=d.getElementsByTagName('script')[0];x.parentNode?.insertBefore(s, x);};if(document.readyState==='complete'){l();}else if((w as any).attachEvent){(window as any).attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})();
}
// Initializes Intercom
export const boot = (email: string): void => {
(window as any).Intercom &&
(window as any).Intercom("boot", { app_id: APP_ID, email });
};
export const update = (): void => {
window && (window as any).Intercom && (window as any).Intercom("update");
};