Si tienes una aplicación React Native, puedes agregar el widget de chat en vivo de Chatwoot y hablar con tus visitantes en tiempo real. Esto se puede hacer en 3 simples pasos usando el plugin de Chatwoot.
Paso 1. Crea una bandeja de entrada de sitio web en Chatwoot
Por favor, consulta esta guía para obtener instrucciones detalladas sobre cómo configurar una bandeja de entrada de sitio web en Chatwoot.
Paso 2. Agrega el plugin a tu proyecto
Agrega uno de los siguientes plugins a tu proyecto.
yarn add @chatwoot/react-native-widget
o
npm install --save @chatwoot/react-native-widget --save
Esta librería depende de react-native-webview y async-storage. Por favor, sigue las instrucciones proporcionadas en la documentación.
Instalación en iOS
Si estás utilizando versiones de React Native > 60.0, es relativamente sencillo.
cd ios && pod install
Paso 3. Úsalo de la siguiente manera
Reemplaza websiteToken y baseUrl con los valores correspondientes.
import React, { useState } from 'react';
import { StyleSheet, View, SafeAreaView, TouchableOpacity, Text } from 'react-native';
import ChatWootWidget from '@chatwoot/react-native-widget';
const App = () => {
const [showWidget, toggleWidget] = useState(false);
const user = {
identifier: 'john@gmail.com',
name: 'John Samuel',
avatar_url: '',
email: 'john@gmail.com',
identifier_hash: '',
};
const customAttributes = { accountId: 1, pricingPlan: 'paid', status: 'active' };
const websiteToken = 'WEBSITE_TOKEN';
const baseUrl = 'CHATWOOT_INSTALLATION_URL';
const locale = 'en';
return (
<SafeAreaView style={styles.container}>
<View>
<TouchableOpacity style={styles.button} onPress={() => toggleWidget(true)}>
<Text style={styles.buttonText}>Abrir widget</Text>
</TouchableOpacity>
</View>
{
showWidget&&
<ChatWootWidget
websiteToken={websiteToken}
locale={locale}
baseUrl={baseUrl}
closeModal={() => toggleWidget(false)}
isModalVisible={showWidget}
user={user}
customAttributes={customAttributes}
/>
}
</SafeAreaView>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
button: {
height: 48,
marginTop: 32,
paddingTop: 8,
paddingBottom: 8,
backgroundColor: '#1F93FF',
borderRadius: 8,
borderWidth: 1,
borderColor: '#fff',
justifyContent: 'center',
},
buttonText: {
color: '#fff',
textAlign: 'center',
paddingLeft: 10,
fontWeight: '600',
fontSize: 16,
paddingRight: 10,
},
});
export default App;
Y... Listo. Consulta el ejemplo completo aquí.