Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Commit b244a7b

Browse files
author
Jerome Houdan
committed
merge master in feature/button
2 parents 0a1926e + ecc87c9 commit b244a7b

File tree

8 files changed

+71
-57
lines changed

8 files changed

+71
-57
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Version 1.0.0 (Jun 21, 2018)
2+
3+
## Description
4+
5+
The first versioned release of the webchat.
6+
Every breaking change, buug fix or improvement will be referenced here.

README.md

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,51 @@ Once you're satisfied with the settings, click on the **SAVE** button. A script
5252

5353
If you want to customize your webchat even more, you can opt for a self-hosted installatiton. Just fork this project to get started!
5454

55+
#### Installation
56+
57+
Clone the repository you forked, and install the dependencies.
58+
59+
```
60+
$> git clone YOUR_REPO_URL
61+
$> cd webchat
62+
$> npm install
63+
```
64+
65+
#### Run in development mode
66+
67+
```
68+
$> npm run start
69+
```
70+
71+
#### Eslint + prettier
72+
73+
```
74+
$> npm run prettier
75+
```
76+
77+
#### Build for production
78+
79+
```
80+
$> npm run build
81+
```
82+
83+
#### Use your webchat
84+
85+
Once you're done, build it and host it.
86+
To use it instead of the default one provided by Recast.AI, you need to set up the Webchat channel in the **CONNECT** tab of your bot.
87+
You'll be using the same script as the default installation, but you have **to replace the src field by your own URL**.
88+
89+
90+
```
91+
<script
92+
src="YOUR_WEBCHAT_URL"
93+
...
94+
></script>
95+
```
96+
5597
### React component
5698
You can import the webchat as a React component like the following example:
57-
```
99+
``` js
58100
import RecastWebchat from 'webchat';
59101

60102
export default class ReactWebchat extends Component {
@@ -115,47 +157,6 @@ this.webchat.clearMessages();
115157
|---|---|
116158
|clearMessages()|Clear all messages in the webchat|
117159

118-
#### Installation
119-
120-
Clone the repository you forked, and install the dependencies.
121-
122-
```
123-
$> git clone YOUR_REPO_URL
124-
$> cd webchat
125-
$> npm install
126-
```
127-
128-
#### Run in development mode
129-
130-
```
131-
$> npm run start
132-
```
133-
134-
#### Eslint + prettier
135-
136-
```
137-
$> npm run prettier
138-
```
139-
140-
#### Build for production
141-
142-
```
143-
$> npm run build
144-
```
145-
146-
#### Use your webchat
147-
148-
Once you're done, build it and host it.
149-
To use it instead of the default one provided by Recast.AI, you need to set up the Webchat channel in the **CONNECT** tab of your bot.
150-
You'll be using the same script as the default installation, but you have **to replace the src field by your own URL**.
151-
152-
153-
```
154-
<script
155-
src="YOUR_WEBCHAT_URL"
156-
...
157-
></script>
158-
```
159160

160161

161162
## Getting started with Recast.AI

lib/index.js

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"progress-bar-webpack-plugin": "^1.10.0",
2727
"prop-types": "^15.6.0",
2828
"query-string": "^5.0.1",
29+
"ramda": "^0.25.0",
2930
"react": "^16.1.1",
3031
"react-dom": "^16.1.1",
3132
"react-redux": "^5.0.6",

src/components/Message/QuickReplies.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class QuickReplies extends Component {
5353
>
5454
<Text content={title} style={style} />
5555

56-
{displayQuickReplies && (
56+
{displayQuickReplies && buttons && !!buttons.length && (
5757
<Slider
5858
arrows={showArrow}
5959
variableWidth

src/containers/Chat/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,11 @@ class Chat extends Component {
138138
}
139139
this._isPolling = true
140140

141-
const { token, channelId, conversationId } = this.props
142141
let shouldPoll = true
143142
let index = 0
144143

145144
do {
146-
const { lastMessageId } = this.props
145+
const { lastMessageId, conversationId, channelId, token } = this.props
147146
let shouldWaitXseconds = false
148147
let timeToSleep = 0
149148
try {

src/reducers/messages.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { handleActions } from 'redux-actions'
2+
import { uniqWith } from 'ramda'
23

34
const initialState = []
45

@@ -19,7 +20,7 @@ export default handleActions(
1920
},
2021

2122
POLL_MESSAGES_SUCCESS: (state, { payload }) => {
22-
return [...state, ...payload.messages]
23+
return uniqWith((m1, m2) => m1.id === m2.id, [...state, ...payload.messages])
2324
},
2425

2526
GET_MESSAGES_SUCCESS: (state, { payload: messages }) => {

src/script.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@ import { store } from 'store'
66
import { getChannelPreferences } from 'actions/channel'
77
import App from 'containers/App'
88

9-
document.body.innerHTML += '<div id="recast-webchat-div"></div>'
10-
const root = document.getElementById('recast-webchat-div')
9+
const idChatDiv = 'recast-webchat-div'
10+
11+
if (!document.getElementById(idChatDiv)) {
12+
document.body.innerHTML += `<div id="${idChatDiv}"></div>`
13+
}
14+
15+
const root = document.getElementById(idChatDiv)
16+
1117
const script = document.currentScript || document.getElementById('recast-webchat')
1218

1319
const channelId = script.getAttribute('channelId')

0 commit comments

Comments
 (0)