Skip to content

Commit

Permalink
merge master in feature/button
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerome Houdan committed Jul 18, 2018
2 parents 0a1926e + ecc87c9 commit b244a7b
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 57 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Version 1.0.0 (Jun 21, 2018)

## Description

The first versioned release of the webchat.
Every breaking change, buug fix or improvement will be referenced here.
85 changes: 43 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,51 @@ Once you're satisfied with the settings, click on the **SAVE** button. A script

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

#### Installation

Clone the repository you forked, and install the dependencies.

```
$> git clone YOUR_REPO_URL
$> cd webchat
$> npm install
```

#### Run in development mode

```
$> npm run start
```

#### Eslint + prettier

```
$> npm run prettier
```

#### Build for production

```
$> npm run build
```

#### Use your webchat

Once you're done, build it and host it.
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.
You'll be using the same script as the default installation, but you have **to replace the src field by your own URL**.


```
<script
src="YOUR_WEBCHAT_URL"
...
></script>
```

### React component
You can import the webchat as a React component like the following example:
```
``` js
import RecastWebchat from 'webchat';

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

#### Installation

Clone the repository you forked, and install the dependencies.

```
$> git clone YOUR_REPO_URL
$> cd webchat
$> npm install
```

#### Run in development mode

```
$> npm run start
```

#### Eslint + prettier

```
$> npm run prettier
```

#### Build for production

```
$> npm run build
```

#### Use your webchat

Once you're done, build it and host it.
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.
You'll be using the same script as the default installation, but you have **to replace the src field by your own URL**.


```
<script
src="YOUR_WEBCHAT_URL"
...
></script>
```


## Getting started with Recast.AI
Expand Down
18 changes: 9 additions & 9 deletions lib/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"progress-bar-webpack-plugin": "^1.10.0",
"prop-types": "^15.6.0",
"query-string": "^5.0.1",
"ramda": "^0.25.0",
"react": "^16.1.1",
"react-dom": "^16.1.1",
"react-redux": "^5.0.6",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Message/QuickReplies.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class QuickReplies extends Component {
>
<Text content={title} style={style} />

{displayQuickReplies && (
{displayQuickReplies && buttons && !!buttons.length && (
<Slider
arrows={showArrow}
variableWidth
Expand Down
3 changes: 1 addition & 2 deletions src/containers/Chat/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,11 @@ class Chat extends Component {
}
this._isPolling = true

const { token, channelId, conversationId } = this.props
let shouldPoll = true
let index = 0

do {
const { lastMessageId } = this.props
const { lastMessageId, conversationId, channelId, token } = this.props
let shouldWaitXseconds = false
let timeToSleep = 0
try {
Expand Down
3 changes: 2 additions & 1 deletion src/reducers/messages.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { handleActions } from 'redux-actions'
import { uniqWith } from 'ramda'

const initialState = []

Expand All @@ -19,7 +20,7 @@ export default handleActions(
},

POLL_MESSAGES_SUCCESS: (state, { payload }) => {
return [...state, ...payload.messages]
return uniqWith((m1, m2) => m1.id === m2.id, [...state, ...payload.messages])
},

GET_MESSAGES_SUCCESS: (state, { payload: messages }) => {
Expand Down
10 changes: 8 additions & 2 deletions src/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ import { store } from 'store'
import { getChannelPreferences } from 'actions/channel'
import App from 'containers/App'

document.body.innerHTML += '<div id="recast-webchat-div"></div>'
const root = document.getElementById('recast-webchat-div')
const idChatDiv = 'recast-webchat-div'

if (!document.getElementById(idChatDiv)) {
document.body.innerHTML += `<div id="${idChatDiv}"></div>`
}

const root = document.getElementById(idChatDiv)

const script = document.currentScript || document.getElementById('recast-webchat')

const channelId = script.getAttribute('channelId')
Expand Down

0 comments on commit b244a7b

Please sign in to comment.