genius-chat-expo
v1.0.2
Published
Digital Genius Chat Expo Module
Downloads
266
Maintainers
Readme
genius-chat-expo
Digital Genius Chat Expo Module
Installation in managed Expo projects
For managed Expo projects, please follow the installation instructions in the API documentation for the latest stable release. If you follow the link and there is no documentation available then this library is not yet usable within managed projects — it is likely to be included in an upcoming Expo SDK release.
Installation in bare React Native projects
For bare React Native projects, you must ensure that you have installed and configured the expo
package before continuing.
Add the package to your npm dependencies
npm install genius-chat-expo
Configure for iOS
Run npx pod-install
after installing the npm package.
Configure for Android
No additional setup necessary.
Example
export default function App() {
useEffect(() => {
const onWidgetEmbedded = DGChatModule.addOnWidgetEmbeddedListener(()=>{
DGChatModule.launchWidget();
});
return () => onWidgetEmbedded.remove();
}, []);
DGChatModule.showDGChatView(
"your_widget_id",
"your_environment",
{"generalSettings":{ "isChatLauncherEnabled" : true}, "locale" : "en-US"}, // optional custom configs
"crm_platform", // optional
"crm_version", // optional
);
return (
<View style={styles.container}>
<Text>Hello</Text>
</View>
);
}
Additional Methods
You can use a set of additional methods to interact directly with Chat Widget. These methods are lised as a part of DGChatModule
.
The sendMessage
method allows the customer to programmatically send a message on the user behalf. This method is not available once the user is handed over to a crm:
function sendMessage(message: string)
The sendSystemMessage method allows the customer to programmatically send a system message to system. This method is only available after the chat has been embeded:
function sendSystemMessage(payload: object)
For example:
sendSystemMessage({
"name" : "auth_token",
"payload" : "your_jwt_token",
})
The launchWidget
method allows the customer to programmatically launch the widget:
function launchWidget()
The initProactiveButtons
method allows the customer to programmatically trigger the proactive buttons to display:
function initProactiveButtons(questions: Array<string>, answers: Array<string>)
The hideDGChatView
method allows customer to hide the chat view:
function hideDGChatView()
See full methods list for more details.