Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Programmatically start chat #77

Open
tmyers101 opened this issue Jun 16, 2023 · 2 comments
Open

Programmatically start chat #77

tmyers101 opened this issue Jun 16, 2023 · 2 comments

Comments

@tmyers101
Copy link

This is more of a question. Is there a way to programmatically start a chat in the React Chat Widget? I want to start a chat when a user clicks on a button that I created.

@danielahristova
Copy link

Has been proposed here #71 , guess it's not a thing yet

@umitalp
Copy link

umitalp commented Jul 29, 2023

Seems like the it updates the visibility of the widget when the prop is changed here

Maybe changing the visibility prop of the LiveChatWidget will help, something like;

import { FunctionComponent, useState } from 'react';
import { LiveChatWidget, WidgetState, useWidgetIsReady } from '@livechat/widget-react';

const LiveChatWidgetSection: FunctionComponent = () => {
    const isWidgetReady = useWidgetIsReady();
    const [liveChatWidgetVisibility, setLiveChatWidgetVisibility] = useState<WidgetState['visibility']>('hidden');

    if (!isWidgetReady) {
        return null;
    }

    return (
        <>
            <button onClick={() => setLiveChatWidgetVisibility('maximized')}>
                Change LiveChat Widget Visibility
            </button>
            <LiveChatWidget
                license='your_license_here'
                visibility={liveChatWidgetVisibility}
            />
        </>
    );
};

export default LiveChatWidgetSection;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants