OpenMax
Free Trial

One-line host

createChatHost from @openmaxai/chat-openmax/react: takes the OpenMax options and re-exports the provider and list hook.

One-line host

@openmaxai/chat-openmax/react is the one-line entry point for OpenMax: createChatHost takes the config and builds a host; ChatProvider, ConversationScope, useChatSdkConversationList and the types ChatSdkHost, ChatSdkAdapterProfiles and ChatSdkProfileCardActions are re-exported unchanged from @openmaxai/chat-sdk/react and described on @openmaxai/chat-sdk · Host. When connecting to OpenMax, importing from this one entry point is enough. Status and an index of every export are on the Overview.

createChatHost

function createChatHost(config: OpenMaxOneLineConfig): ChatSdkHost;
function createChatHost(config: ChatSdkAdapterHostConfig): ChatSdkHost;

Two call forms: the first takes the OpenMax options, where OpenMaxOneLineConfig is OpenMaxChatConfig plus onUnauthorized?: never, onEvent?: never, cards?: never, profileCardActions?: never and attachments?: never, uploads?: never, resolveUrls?: never, resolveDownloadUrl?: never, and is not exported; the second takes ChatSdkAdapterHostConfig ({ adapter, ... }) and passes it unchanged to createChatHost from @openmaxai/chat-sdk/react.

Given the config, it builds the adapter with createOpenMaxAdapter and passes it, together with storage, instanceKey, locale, ports and markdown, to createChatHost from @openmaxai/chat-sdk/react for assembly.

  • Synchronous. No request is sent and getToken is not called at construction. Until the current user is back, identity.currentUserId() is an empty string; when the data arrives, ChatProvider re-renders.
  • An invalid config throws ChatSdkConfigError synchronously; the rules are under OpenMaxChatConfig.
  • Does not take onUnauthorized. The type rejects it (TypeScript does not compile); a JS caller that passes it gets ChatSdkConfigError thrown synchronously when the host is built, with the fix in the message. When the credentials are gone, the failing call still throws a ChatSdkRequestError with kind unauthorized, realtime stops reconnecting, and the SDK shows "session expired" once through attention.notify. For a callback, use createChatHost({ adapter: createOpenMaxAdapter(config), onUnauthorized }) instead. This is a known gap, see Known gaps and version.
  • Does not take onEvent, handled like onUnauthorized: the type rejects it, and a JS caller that passes it gets ChatSdkConfigError thrown synchronously when the host is built. To receive events, use createChatHost({ adapter: createOpenMaxAdapter(config), onEvent }) instead.
  • Does not take cards, handled like onEvent: the type rejects it, and a JS caller that passes it gets ChatSdkConfigError thrown synchronously when the host is built. A host built from the one-line form never draws business-card buttons; for card capabilities, use the { adapter } form and pass the allowed business operations there: createChatHost({ adapter: createOpenMaxAdapter(config), cards: { isOperationAllowed } }).
  • Does not take profileCardActions, handled like cards: a host built from the one-line form has no profile card; for profile cards, use createChatHost({ adapter: createOpenMaxAdapter(config), profileCardActions }).
  • Keys it does not recognise are ignored, not thrown. In development, when the host first mounts under ChatProvider, each unrecognised key gets one console.error that names it and says where it belongs: attachments, uploads, resolveUrls and resolveDownloadUrl explain that the OpenMax adapter wires attachments from baseUrl and auth itself, and that changing them means the { adapter } form with the adapter's uploads replaced; keys that only the { adapter } form takes, such as routeConversation, point to the { adapter } form; port names point to ports.<name>. It is reported once per host. A bundled production build prints nothing (the message text still ships in the bundle); source used without a bundler counts as development and reports. attachments, uploads, resolveUrls and resolveDownloadUrl are typed never, so neither call form compiles with them; other unrecognised keys in the { adapter } form are reported by createChatHost from @openmaxai/chat-sdk/react.
  • On the host it builds, endpointUrl, authToken and clientId of inboundDelivery are an empty string, undefined and an empty string.

Code that connected to OpenMax with createChatHost from @openmaxai/chat-sdk/react only changes the import path; the config shape is the same. createChatHost from @openmaxai/chat-sdk/react takes only { adapter } and throws ChatSdkConfigError synchronously when given the OpenMax config.