Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

It is also possible to manage multiple instances of an agent by using the profound.ai.Chat class. For example:

Code Block
languagejs
// StartShow the Sales Assistant initially
const salesAgent = new profound.ai.Chat();
salesAgent.init({
  agent: "sales.agent.json",
  heading: "Sales Assistant"
});
salesAgent.show();

// Now, hide the Sales Assistant and show the Support Assistant
salesAgent.hide();
const supportAgent = new profound.ai.Chat();
supportAgent.init({
  agent: "support.agent.json",
  heading: "Support Assistant"
});
supportAgent.show();

...

Specifies the server-side definition file for the AI Agent. The file should end in “.agent.json”.

server

URL of the server.

theme

The theme of the chat UI (e.g., "light" or "dark").

brandColor

The brand color used in the chat UI.

container

The DOM element where the chat UI will be appended.

closeButton

Boolean indicating if the close button is present.

closeTitle

Title text for the close button.

sendTitle

Title text for the send button

promptPlaceHolder

Placeholder text for the prompt box

heading

Heading text for the chat UI

greeting

Greeting message in the chat UI.

pollInterval

Time interval for polling in milliseconds.

loaderMessage

Default message displayed by the loader.

data

Additional data to be sent with messages.

Methods

show()

Makes the assistant visible.

  1. init: Initializes the chat UI with the given configuration.

  2. show: Displays the chat UI.

  3. hide: Hides the chat UI.

  4. add: Adds a message to the chat UI.

  5. clear: Clears the chat messages.

  6. setTheme: Sets the theme of the chat UI.

  7. setBrandColor: Sets the brand color of the chat UI.

  8. send: Sends the message from the prompt box.

  9. poll: Polls the server for responses.

  10. showLoader: Displays the loading animation.

  11. hideLoader: Hides the loading animation.

  12. isLoading: Checks if the loader is currently displayed.

  13. destroy: Destroys the chat UI and cleans up resources.