Skip to main content

figochat 1.0.0 copy "figochat: ^1.0.0" to clipboard
figochat: ^1.0.0 copied to clipboard

FigoChat SDK for Flutter. Chat with a Figo AI assistant, with voice messages and file uploads.

example/lib/main.dart

import 'package:figochat/figochat.dart';
import 'package:flutter/material.dart';

// Run with: flutter run --dart-define=FIGO_API_KEY=... --dart-define=FIGO_ASSISTANT_ID=...
// Without them the chat still opens and messages fail, which is handy for checking the UI.
const _apiKey = String.fromEnvironment('FIGO_API_KEY');
const _assistantId = String.fromEnvironment('FIGO_ASSISTANT_ID');

void main() {
  String? setupError;
  try {
    FigoChat.initialize(
      apiKey: _apiKey.isEmpty ? 'missing-api-key' : _apiKey,
      assistantId: _assistantId.isEmpty ? 'missing-assistant-id' : _assistantId,
      fullName: 'Ada Lovelace',
      emailAddress: 'ada@example.com',
      mobilePhone: '+2348012345678',
      primaryColor: '#F97316',
      title: 'Support',
      welcomeMessage: 'Hi Ada! How can I help you today?',
    );
  } on FigoChatException catch (e) {
    setupError = e.message;
  }
  runApp(ExampleApp(setupError: setupError));
}

class ExampleApp extends StatelessWidget {
  const ExampleApp({super.key, this.setupError});

  final String? setupError;

  @override
  Widget build(BuildContext context) {
    final warning = setupError ?? (_apiKey.isEmpty ? 'No FIGO_API_KEY set: messages will fail.' : null);
    return MaterialApp(
      title: 'FigoChat example',
      home: Builder(
        builder: (context) => Scaffold(
          appBar: AppBar(title: const Text('My App')),
          body: Center(
            child: Padding(
              padding: const EdgeInsets.all(24),
              child: Column(mainAxisSize: MainAxisSize.min, children: [
                const Text('FigoChat Flutter SDK example'),
                if (warning != null)
                  Padding(
                    padding: const EdgeInsets.only(top: 12),
                    child: Text(warning, textAlign: TextAlign.center, style: const TextStyle(color: Color(0xFFB3261E))),
                  ),
              ]),
            ),
          ),
          floatingActionButton: setupError != null
              ? null
              : FloatingActionButton.extended(
                  onPressed: () => FigoChat.open(context),
                  icon: const Icon(Icons.chat_bubble_outline),
                  label: const Text('Chat with us'),
                ),
        ),
      ),
    );
  }
}
0
likes
140
points
--
downloads

Documentation

API reference

Publisher

unverified uploader

FigoChat SDK for Flutter. Chat with a Figo AI assistant, with voice messages and file uploads.

Homepage

Topics

#chat #ai #chatbot #sdk #customer-support

License

MIT (license)

Dependencies

cross_file, file_picker, flutter, http, http_parser, path_provider, pointycastle, pusher_channels_flutter, record, url_launcher

More

Packages that depend on figochat