-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(webchat-v2): added documentation for webchat v2 (#293)
- Loading branch information
1 parent
da0c469
commit 6cadd61
Showing
53 changed files
with
949 additions
and
158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,5 @@ out | |
pages/api-documentation/index.mdx | ||
.vercel | ||
.env*.local | ||
.ignore.me.* | ||
.ignore.me.* | ||
lefthook.yml |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import Construction from '@assets/construction.svg' | ||
|
||
type Props = {} | ||
|
||
export const ComingSoon = ({}: Props) => { | ||
return ( | ||
<div className='flex justify-center items-center flex-col mt-10'> | ||
<h3 className='text-3xl'>Coming Soon</h3> | ||
<p className='text-gray-400'>This section is under construction.</p> | ||
<div> | ||
<Construction className='h-40 w-40' /> | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import Execution from "@assets/execution.svg"; | ||
import CloseDown from "@assets/close-down.svg"; | ||
import OpenInWindow from "@assets/open-in-window.svg"; | ||
import { useState } from "react"; | ||
|
||
type Props = { | ||
title?: string; | ||
message?: string; | ||
example: string; | ||
preload?: boolean; | ||
file?: string | ||
}; | ||
|
||
export const Demo = ({ example, message, title, file = 'src/App.tsx', preload = true }: Props) => { | ||
const [showDemo, setShowDemo] = useState(false); | ||
|
||
const src = `https://stackblitz.com/github/botpress/documentation-examples/tree/master/examples/${example}?embed=1&hideNavigation=1&view=both&file=${encodeURIComponent(file)}`; | ||
|
||
return ( | ||
<> | ||
{showDemo && ( | ||
<div | ||
className="top-0 bottom-0 right-0 left-0 fixed bg-gray-900 w-screen h-screen animate-[scaleout_300ms_ease] z-20" | ||
style={{ animationFillMode: "forwards" }} | ||
/> | ||
)} | ||
<div | ||
className={`fixed left-0 right-0 top-0 bottom-0 z-40 ${ | ||
showDemo ? "" : "invisible" | ||
}`} | ||
onClick={() => setShowDemo(true)} | ||
> | ||
<div className="w-full h-full relative"> | ||
<div className="absolute bottom-0 left-0 right-0 flex justify-center mb-4"> | ||
<button | ||
className="rounded-full w-10 h-10 bg-red-600 hover:bg-red-700 text-white shadow-md" | ||
onClick={(e) => { | ||
e.stopPropagation(); | ||
setShowDemo(false); | ||
}} | ||
> | ||
<CloseDown className="h-6 w-10" /> | ||
</button> | ||
</div> | ||
{(preload || showDemo) && ( | ||
<iframe src={src} className="w-full h-full" /> | ||
)} | ||
</div> | ||
</div> | ||
|
||
<div | ||
className="h-20 transition-all cursor-pointer m-4 mt-8 mb-0 hover:shadow-sm hover:scale-105 p-2 border rounded border-blue-100 bg-white hover:border-blue-400 group" | ||
onClick={() => setShowDemo(true)} | ||
> | ||
<div className="flex justify-center items-center relative"> | ||
<> | ||
<Execution className="h-14 w-14 mr-4" /> | ||
<div> | ||
<h3 className="text-xl">{title ?? "Live Demo"}</h3> | ||
<p className="text-gray-400 text-sm m-0"> | ||
{message ?? "Click to see a live demo"} | ||
</p> | ||
</div> | ||
<a | ||
href={src} | ||
className="absolute top-0 right-0 p-2 bg-gray-100 hover:bg-gray-200 group-hover:visible invisible" | ||
onClick={(e) => e.stopPropagation()} | ||
target="_blank" | ||
> | ||
<OpenInWindow className="h-4 w-4" /> | ||
</a> | ||
</> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Document</title> | ||
</head> | ||
|
||
<body> | ||
<script src="https://cdn.botpress.cloud/webchat/v2/inject.js"></script> | ||
<script src="https://mediafiles.botpress.cloud/26a83f89-ace1-4045-92ba-95b836f75669/webchat/v2/config.js"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"quick-start": "Quick Start", | ||
"embedded": "Embedded Webchat", | ||
"theming": "Theming", | ||
"react": "React Library", | ||
"javascript-client": "Javascript Client", | ||
"api": "Webchat Api", | ||
"examples": "Examples" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { ComingSoon } from '@components/ComingSoon' | ||
|
||
# Webchat Api | ||
|
||
<ComingSoon /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Steps } from 'nextra/components' | ||
|
||
# Embedded Webchat | ||
|
||
Using the embedded webchat is a great way to provide a seamless experience for your users. The embedded webchat can be added to your website or application by adding a few lines of code to your HTML. This is the easiest way to integrate the webchat with your website or application. | ||
|
||
<Steps> | ||
|
||
### Step 1: Get the Embed Code | ||
|
||
![webchat-embed-config](/docs/content/webchat/embed-config.png) | ||
|
||
### Step 2: Add the Embed Code to Your Website | ||
|
||
```html {8-9} | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>My Webchat</title> | ||
</head> | ||
<body> | ||
[...] | ||
<script src="https://cdn.botpress.cloud/webchat/v2/inject.js"></script> | ||
<script src="https://mediafiles.botpress.cloud/52345432-5432543-5435-435545434/webchat/v2/config.js"></script> | ||
</body> | ||
</html> | ||
``` | ||
|
||
</Steps> | ||
|
||
<div className='relative h-[500px] flex'> | ||
|
||
<div> | ||
### Voilà! | ||
|
||
You've integrated the webchat with your website or application. | ||
|
||
Here's an overview of what the embedded webchat looks like. | ||
|
||
Are you looking to use the webchat as a full-page application? Check out the [react library](react). | ||
</div> | ||
|
||
<div className='w-[260px] flex-none'> | ||
<img src="/docs/content/webchat/demo.png" alt="demo" /> | ||
</div> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { Demo } from '@components/Demo' | ||
|
||
# Using Javascript with Embedded | ||
|
||
The embedded Webchat allows you to interact with the widget using JavaScript. This API is available on the `window` object as `window.botpress`. | ||
|
||
<Demo example="webchat-embed-controls" title="Webchat Embed Controls" file="index.html" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Demo } from '@components/Demo' | ||
|
||
# Examples | ||
|
||
This is a collection of examples that demonstrate how to use the Webchat in various scenarios. | ||
|
||
<div className="grid grid-cols-2"> | ||
<Demo example="webchat-react-demo" title="Webchat Demo" preload={false} /> | ||
<Demo example="webchat-react-custom-message" title="Custom Message" preload={false} /> | ||
<Demo example="webchat-embed-controls" title="Embedded Controls" file="index.html" preload={false} /> | ||
<Demo example="webchat-embed-custom-trigger" title="Custom Trigger" file="index.html" preload={false} /> | ||
</div> |
Oops, something went wrong.