ym_flutter_integration 0.0.1 copy "ym_flutter_integration: ^0.0.1" to clipboard
ym_flutter_integration: ^0.0.1 copied to clipboard

outdated

A Flutter plugin for integrating Yellow Messenger chatbots in your flutter application.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:ym_flutter_integration/models/botEvents.dart';
import 'package:ym_flutter_integration/ym_bot_sdk.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        debugShowCheckedModeBanner: false,
        home: Scaffold(
          body: BotPage(),
        ));
  }
}

class BotPage extends StatefulWidget {
  static String routeName = "/BotPage";
  @override
  _BotPageState createState() => _BotPageState();
}

class _BotPageState extends State<BotPage> {
  YmBotSdk ymBotSdk;
  String botId = "x1597301712805";

  @override
  void initState() {
    super.initState();
    ymBotSdk = YmBotSdk();
    ymBotSdk.setConfig(
        context: context,
        botId: botId,
        enableHistory: false,
        enableSpeech: false,
        enableCloseButton: true);
    ymBotSdk.addPayload(key: "Age", value: "22");
  }

  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: Scaffold(
        body: Expanded(
          child: ymBotSdk.getBotWidget(
            botEventListener: (BotEvent botEvent) {
              switch (botEvent.code) {
                case "choosen_other_option":
                  ymBotSdk.closeBot();
                  // ymBotSdk.addPayload(key: "Name", value: "Purush");
                  // ymBotSdk.updatePayload();
                  print("code is ${botEvent.code}, data is ${botEvent.data}");
                  break;
                default:
                  print("No data");
              }
            },
          ),
        ),
      ),
    );
  }
}
7
likes
0
points
5
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin for integrating Yellow Messenger chatbots in your flutter application.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, image_picker, speech_to_text, url_launcher, webview_flutter

More

Packages that depend on ym_flutter_integration

Packages that implement ym_flutter_integration