Starting an AI Agent
Starting an agent within your Web application involved calling the profound.ai.startAgent() API and passing a configuration object parameter. For example:
profound.ai.startAgent({ agent: "HR.agent.json", heading: "HR Assistant", greeting: "How can I help?" });
After an agent is started, you can use various methods of profound.ai.agent to control it. For example:
profound.ai.agent.hide(); // Hide the agent profound.ai.agent.show(); // Show the agent
It is also possible to manage multiple instances of an agent by using the profound.ai.Chat class. For example:
// Show 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();
Configuration Properties
agent
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
init(config)
Initializes the chat UI with the given configuration.
show()
Displays the chat UI.
hide()
Hides the chat UI.
add(info)
Adds a message to the chat UI.
clear()
Clears the chat messages.
setTheme(newTheme)
Sets the theme of the chat UI.
setBrandColor(newBrandColor)
Sets the brand color of the chat UI.
send()
Sends the message from the prompt box.
poll()
Polls the server for responses.
showLoader(loaderMessage)
Displays the loading animation.
hideLoader()
Hides the loading animation.
isLoading()
Checks if the loader is currently displayed.
destroy()
Destroys the chat UI and cleans up resources.