Conversational UI Overview

Conversational UI components bridge the gap between the Web and the next-generation natural language applications.

The Conversational UI package delivers the KendoReact Chat component which allows the user to participate in chat sessions with other users or with chat bots.

Basic Usage

The following example demonstrates the Chat Component in action.

import React from 'react';
import ReactDOM from 'react-dom';
import { Chat } from '@progress/kendo-react-conversational-ui';


class App extends React.Component {
    constructor(props) {
        super(props);
        this.user = {
            id: 1,
            avatarUrl: "https://via.placeholder.com/24/008000/008000.png"
        };
        this.bot = {
            id: 0
        };
        this.state = {
            messages: [
                {
                    author: this.bot,
                    suggestedActions: [ {
                        type: 'reply',
                        value: 'Oh, really?'
                    }, {
                        type: 'reply',
                        value: 'Thanks, but this is borring.'
                    } ],
                    timestamp: new Date(),
                    text: 'Hello, this is a demo bot. I don`t do much, but I can count symbols!'
                }
            ]
        };
    }

    addNewMessage = (event) => {
        let botResponce = Object.assign({},event.message );
        botResponce.text = this.countReplayLength(event.message.text);
        botResponce.author = this.bot;
        this.setState((prevState) => {
            return { messages: [ ...prevState.messages, event.message ] };
        });
        let that = this;
        setTimeout(function() {
            that.setState((prevState) => {
                return { messages: [ ...prevState.messages, botResponce ] };
            });
        },1000);
    };

    countReplayLength = (question) => {
        let length = question.length;
        let answer = question + " contains exactly " + length + " symbols.";
        return answer;
    }


    render() {
        return (
            <div>
                <Chat user={this.user}
                    messages={this.state.messages}
                    onMessageSend={this.addNewMessage}
                    width={400}>
                </Chat>
            </div>
        );
    }
}

ReactDOM.render(
    <App />,
    document.querySelector('my-app')
);

Installation

  1. Download and install the package. Use Node.js v5.0.0 or later.

    npm install --save @progress/kendo-react-conversational-ui @progress/kendo-react-buttons @progress/kendo-react-intl
  2. Once installed, import the package module.

    // ES2015 module syntax
    import { Chat } from '@progress/kendo-react-conversational-ui';
    // CommonJS format
    const { Chat } = require('@progress/kendo-react-conversational-ui');
  3. You are required to install one of the Kendo UI themes to style your components. For more information on how to add the styles, refer to the article on getting started.

Dependencies

The Conversational UI package requires you to install the following peer dependencies in your application:

  • react
  • react-dom
  • @progress/kendo-react-buttons
  • @progress/kendo-react-intl

Functionality and Features

In this article