figochat 1.0.0
figochat: ^1.0.0 copied to clipboard
FigoChat SDK for Flutter. Chat with a Figo AI assistant, with voice messages and file uploads.
FigoChat SDK for Flutter #
Chat with a Figo AI assistant from your Flutter app: text chat, voice messages (speech to text) and file uploads (with OCR for images), themed with your brand color.
Install #
flutter pub add figochat
or in pubspec.yaml:
dependencies:
figochat: ^1.0.0
Permissions #
iOS — ios/Runner/Info.plist:
<key>NSMicrophoneUsageDescription</key>
<string>Record voice messages for chat.</string>
Android — android/app/src/main/AndroidManifest.xml:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.INTERNET" />
<queries>
<intent><action android:name="android.intent.action.VIEW" /><data android:scheme="https" /></intent>
</queries>
macOS (if used) — enable Audio Input, Outgoing Connections and User Selected File (read-only) in the entitlements.
Voice notes are disabled on Flutter web; text and file uploads work there. For live agent messages on web, add the Pusher script to web/index.html: <script src="https://js.pusher.com/8.4.0/pusher.min.js"></script>.
Use #
import 'package:figochat/figochat.dart';
// once, e.g. after the user signs in
FigoChat.initialize(
apiKey: 'YOUR_API_KEY',
assistantId: 'YOUR_ASSISTANT_ID',
fullName: 'Ada Lovelace',
emailAddress: 'ada@example.com',
mobilePhone: '+2348012345678',
primaryColor: '#F97316',
// optional
title: 'Support',
welcomeMessage: 'Hi Ada! How can I help you today?',
);
// full-screen chat
FigoChat.open(context);
// or embed it anywhere
const FigoChatView(onClose: null)
initialize options #
| Option | Required | Description |
|---|---|---|
apiKey |
✓ | API key from the Figo AI dashboard |
assistantId |
✓ | Assistant to chat with |
fullName |
✓ | Signed-in user's name |
emailAddress |
✓ | Signed-in user's email |
mobilePhone |
✓ | Signed-in user's phone, international format |
primaryColor |
✓ | Hex brand color, e.g. #F97316 |
baseUrl |
Defaults to https://api.figolabs.ai |
|
title |
Header title, default Chat |
|
welcomeMessage |
First assistant message | |
threadId |
Resume an earlier conversation | |
maxFiles |
Files per message, default 5 | |
maxFileSizeMB |
Default 10 | |
autoSendVoice |
Send transcription immediately (default) or put it in the input | |
timeout |
Default 2 minutes |
FigoChatView parameters #
onClose, showHeader, placeholder, enableVoice, enableAttachments, onError.
Other calls #
FigoChat.threadId; // save it to resume later via initialize(threadId: ...)
FigoChat.resetConversation(); // next message starts a new thread
FigoChat.logout(); // clear config on sign-out
// Build your own UI
final reply = await FigoChat.client.sendMessage('Hello');
final text = await FigoChat.client.transcribe(audioBytes);
final urls = await FigoChat.client.uploadFiles([FigoUploadFile(name: 'receipt.jpg', bytes: bytes)]);
All errors are FigoChatException with a code (401, 49, TIMEOUT, NETWORK, …). The chat screen never shows these technical messages to users. It shows friendly text instead, such as "Chat isn't available right now. Please try again later." for a bad key, no credits or a plan limit, and "You seem to be offline…" for network problems. onError still receives the full technical error for your logs. Apps with their own UI can use friendlyMessage(error).
Example #
cd example && flutter run --dart-define=FIGO_API_KEY=... --dart-define=FIGO_ASSISTANT_ID=...
Without the defines the chat still opens, and messages fail with the friendly "Chat isn't available right now" text.
iOS build note #
If pod install fails with an error mentioning XCLocalSwiftPackageReference, your CocoaPods is older than your Flutter's Swift Package Manager support. Update CocoaPods, or turn the integration off in your app's pubspec.yaml (the example does this):
flutter:
config:
enable-swift-package-manager: false
Live agent messages #
After the first reply, the chat subscribes to the Pusher channel named after the conversation's thread id. Messages a live agent sends from Tawk.to, Zoho SalesIQ or FreshChat appear on the left, like assistant replies. The Pusher key and cluster come from GET /api/v1/realtime/config. They're kept encrypted in memory with FigoCrypto (AES-256 with a random per-session key) and decrypted only when subscribing.
API key security #
The API key ships inside the mobile app, so anyone who unpacks the app can read it and call every API-key endpoint, spending the company's credits. Create a dedicated key for the SDK in the Figo AI dashboard, give it an expiry, and rotate it if it leaks. For stronger protection, have your own backend issue short-lived keys and pass them to initialize after sign-in.