ReactNative Chatflow Component
npm install react-native-chatflowjavascript
npm install --save react-native-chatflow
`Note: this package requires react-native-linear-gradient. It is part of the dependencies of the package so will be automatically installed, but note that you will need to run the following command to link it as it is a native module:
`javascript
react-native link react-native-linear-gradient
` Basic Usage
It's really easy to get started. Put the following code in one of your components...`javascriptimport ChatFlow from "react-native-chatflow";
import chatScript from "./chatScript.json";
chatScript={chatScript}
backgroundColor={Styles.colours.lightBackground}
`Then you need to include a chat script (in the example above, chatScript.json), which defines what the chat flow will be. An example is shown below:
`
{
"_start": "hello",
"hello": {
"text": "Hello I'm an example bot 👋🏼",
"next": "getName"
},
"getName": {
"text": "First up, what's your name?",
"input": "text",
"placeholder": "Enter your name",
"field": "name",
"next": "favouriteEmoji"
},
"favouriteEmoji": {
"text": "What food do you want?",
"field": "food",
"options": [
{"value": "small", "text": "🥕"},
{"value": "medium", "text": "🍕"},
{"value": "big", "text": "🐔"}
]
}
}
``