Skip to main content

Demo

This is used by default to demonstrate the component's capabilities without connecting to any APIs.

demo

Set this to true or define an object with properties to remove the initial setup guidance message.
response is used to override the default demo response with a custom one. It can either be a Response object or a function that returns a Response object.
The following properties are used to toggle elements to showcase their design without making any user actions:
displayErrors is used to display error messages.
displayLoading is used to display various loading spinners.
displayFileAttachmentContainer is used to display the element that encapsulates all of the files to be sent on the next message.

Base Example

<deep-chat demo="true"></deep-chat>

Custom Response Example

chatElementRef.demo = {
response: (message) => {
const options = ['rock', 'paper', 'scissors'];
const userOption = message.text?.toLocaleLowerCase();
const aiOption = options[Math.floor(Math.random() * 3)];
let response = `I guessed ${aiOption}. `;
if (userOption === aiOption) response += 'Draw';
else if (userOption === 'rock') response += aiOption === 'paper' ? 'I win!' : 'You win!';
else if (userOption === 'paper') response += aiOption === 'scissors' ? 'I win!' : 'You win!';
else if (userOption === 'scissors') response += aiOption === 'rock' ? 'I win!' : 'You win!';
else response = 'Guess either Rock, Paper or Scissors';
return {text: response};
},
};

Types

DemoErrors

  • Type: {default?: boolean, service?: boolean, speechToText?: boolean}

Display various error messages. This is mainly used to showcase the override capabilities in errorMessages.
default displays a default component error.
service is an API error.
speechToText is a speech to text issue error.

<deep-chat demo='{"displayErrors": {"service": true}}'></deep-chat>

DemoLoading

  • Type: {
         message?: boolean,
         history?: {full?: boolean, small?: boolean}
    }

Display various loading spinners.
message is a loading spinner inside a message bubble.
history is a loading spinner that is displayed when messages are being loading via loadHistory. full is a spinner that covers the entire chat message window on the initial load. small is displayed when there are messages already present inside the chat. If full is set to true and messages are added, the chat will automatically display the small spinner.

<deep-chat demo='{"displayLoading": {"message": true, "history": {"small": true}}}'></deep-chat>