Skip to content

Commit

Permalink
feat(internal): allow integration object as prop
Browse files Browse the repository at this point in the history
  • Loading branch information
nzambello committed Jan 3, 2025
1 parent 7c0a290 commit 63b3f0f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ const App = () => (
| ---------------------------------- | -------------- | ------------------------------------------- | --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `memoriName` | \* (see below) | `string` | | Name of the Memori |
| `ownerUserName` | \* (see below) | `string` | | Username of the Memori owner |
| `memoriID` | \* (see below) | `string` | | ID of the Memori (agent) |
| `memoriID` | \* (see below) | `string` | | ID of the Memori (agent) |
| `ownerUserID` | \* (see below) | `string` | | ID of the Memori owner |
| `tenantID` | ✔️ | `string` | | Tenant ID, example: "aisuru.com" or "app.memorytwin.com" |
| `sessionID` | | `string` | | Initial Session ID, UUID which refers to the session to the Memori and identifies a conversation and its permissions (giver, receiver, anonymous). A session would be started autonomously with the params set, but if you have an existing and valid sessionID you can pass it as already opened one. Use this at your risk, as session recovery might break or start session as anon user. In most cases, you shoudn't use this prop. |
| `authToken` | | `string` | | Authentication token from user login, needed for giver sessions to upload assets |
| `integrationID` | | `string` | | Integration ID, UUID which refers to the public page layout |
| `integration` | | `Integration` | | Integration object |
| `secretToken` | | `string` | | Secret token, the password of a private or secret Memori |
| `height` | | `string` | "100%" | Height of the Memori |
| `showShare` | | `bool` | `true` | Show the share button |
Expand All @@ -89,7 +90,7 @@ const App = () => (
| `enableAudio` | | `boolean` | `true` | Enable audio output. Defaults to true if otherwise indicated by props or integration config. |
| `defaultSpeakerActive` | | `boolean` | `true` | Default value for the speaker activation |
| `disableTextEnteredEvents` | | `boolean` | `false` | Disable MemoriTextEntered events listeners for `typeMessage` functions, useful to avoid issues with multiple widgets in page. |
| `useMathFormatting` | | `boolean` | `false` | Apply math formatting to the messages, defaults to false if otherwise indicated by props or integration config. |
| `useMathFormatting` | | `boolean` | `false` | Apply math formatting to the messages, defaults to false if otherwise indicated by props or integration config. |
| `AZURE_COGNITIVE_SERVICES_TTS_KEY` | | `string` | | Azure Cognitive Services TTS key, used to generate the audio of the Memori and for STT recognition |
| `layout` | | `string` | | Layout of the Memori, can be "FULLPAGE" (default), "CHAT", "WEBSITE_ASSISTANT", "TOTEM", "HIDDEN_CHAT" or "ZOOMED_FULL_BODY". see [below](#layouts) |
| `customLayout` | | `React.FC<LayoutProps>` | | Custom layout component, see [below](#custom-layout) |
Expand Down
18 changes: 12 additions & 6 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
DialogState,
Memori as IMemori,
Tenant,
Integration,
} from '@memori.ai/memori-api-client/dist/types';
import memoriApiClient from '@memori.ai/memori-api-client';

Expand All @@ -15,7 +16,6 @@ import { VisemeProvider } from './context/visemeContext';

import { Toaster } from 'react-hot-toast';
import { getTenant } from './helpers/tenant';
import { installMathJax } from './helpers/utils';

import i18n from './i18n';
import { useTranslation } from 'react-i18next';
Expand All @@ -26,6 +26,7 @@ export interface Props {
memoriID?: string | null;
ownerUserName?: string | null;
ownerUserID?: string | null;
integration?: Integration;
integrationID?: string;
tenantID: string;
secretToken?: string;
Expand Down Expand Up @@ -91,6 +92,7 @@ const Memori: React.FC<Props> = ({
ownerUserID,
memoriName,
memoriID,
integration,
integrationID,
tenantID,
secretToken,
Expand Down Expand Up @@ -269,11 +271,14 @@ const Memori: React.FC<Props> = ({
showContextPerLine={showContextPerLine}
showLogin={showLogin ?? memori?.enableDeepThought}
showUpload={showUpload}
integration={memori?.integrations?.find(i =>
integrationID
? i.integrationID === integrationID
: !!i.publish && i.type === 'LANDING_EXPERIENCE'
)}
integration={
integration ??
memori?.integrations?.find(i =>
integrationID
? i.integrationID === integrationID
: !!i.publish && i.type === 'LANDING_EXPERIENCE'
)
}
initialContextVars={context}
initialQuestion={initialQuestion}
authToken={authToken}
Expand Down Expand Up @@ -321,6 +326,7 @@ Memori.propTypes = {
ownerUserName: PropTypes.string,
ownerUserID: PropTypes.string,
integrationID: PropTypes.string,
integration: PropTypes.any,
tenantID: PropTypes.string.isRequired,
secretToken: PropTypes.string,
sessionID: PropTypes.string,
Expand Down

0 comments on commit 63b3f0f

Please sign in to comment.