chatsasa_livechat 1.0.5
chatsasa_livechat: ^1.0.5 copied to clipboard
A live-chat customer support flutter sdk
ChatSasa Live-Chat SDK #
Welcome to the ChatSasa Flutter SDK. This SDK allows you to easily integrate ChatSasa's live chat functionality into your Flutter mobile applications.
Getting started #
For you to start using Chatsasa Live chat SDK you need an admin/agent account and an organisation for maning the incoming messages.
Here are the steps to get you started.
- Sign up in Chatsasa.
- Create an Organisation.
- Create a Customer Support Widget
- Create a Customer Support Channel
- Link a Customer Support Channel to a Widget (Go to your widget and click Edit)
- Copy and pass the
widgetIdto the Flutter SDK
Add dependency #
Add this to your package's pubspec.yaml file, use the latest version.
dependencies:
chatsasa_livechat: ^latest_version
You should then run flutter packages get
Changelog #
Check out the changelog on pub.flutter-io.cn to see the latest changes in the package.
Initialization #
Initialize the ChatSasa SDK in your main.dart file:
import 'package:flutter/material.dart';
import 'package:chatsasa_flutter_sdk/chatsasa_flutter_sdk.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
var chatSDK = ChatSasaLiveChat();
chatSDK.initSDK();
runApp(const MyApp());
}
Usage #
To launch the chat widget, use the following code in your main widget file:
You need to pass the user details under the AppUserModel. UserIdentifier field is mandatory. Launch the Chat Widget by providing the widgetId and the appUserModel.
import 'package:flutter/material.dart';
import 'package:chatsasa_flutter_sdk/chatsasa_flutter_sdk.dart';
import 'package:chatsasa_livechat/src/presentation/chat/widget_info.dart';
import 'package:chatsasa_livechat/src/presentation/common/app_user_model.dart';
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key,});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
var appUser = AppUserModel(
name: 'Joe',
email: 'joe@gmail.com',
userIdentifier: 'joe@gmail.com',
);
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.blue,
title: Text(
"Live Chat Example",
style: const TextStyle(color: Colors.white),
),
),
body: Center(
child: Container(),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => WidgetHome(
widgetId: "YOUR_WIDGET_UUID", // Replace with your widget UUID
appUserModel: appUser
)));
},
tooltip: 'launch live chat',
child: const Icon(Icons.chat_bubble_outline),
),
);
}
}
Example App #
This repository includes a fully functional example app with setup instructions. The example is available under the example folder.