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.

ym_flutter_integration #

Image of Yellowmessenger

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

Overview #

Gives a widget to show chatbot on your mobile application, and listen to the events emitted from the chatbot

Usage #

To use this plugin, add ym_flutter_integration as a dependency in your pubspec.yaml file.

Getting started #

Initialise the YmBotSdk and set the initial configurations

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

 class _BotPageState extends State<BotPage> {
  YmBotSdk ymBotSdk;
  String botId = "<Your botId goes here>";

  @override
  void initState() {
    super.initState();

    ymBotSdk = YmBotSdk();
    ymBotSdk.setConfig(
        context: context,
        botId: botId,
        enableHistory: false,
        enableSpeech: false,
        enableCloseButton: true);
  }
 }

Call getBotWidget() method on the ymBotSdk object to get the chatbot widget

ymBotSdk.getBotWidget(
            botEventListener: (BotEvent botEvent) {
              switch (botEvent.code) {
                case "event1":
                  ymBotSdk.closeBot();
                  print("code is ${botEvent.code}, data");
                  print("is ${botEvent.data}");
                  break;
                default:
                  print("No data");
              }
            },
          ),

Methods #

  • setConfig(...) : To set initial configurations to the chatbot ( Config should be added befioring callign the getBotWidget(...))
  • getBotWidget(...) : To get the chatbot widget
  • closeBot(...) : close the chatbot
  • addPayload(...) : add the payload to the chatbot ( payload is sent to chatbot once the updatePayload is called)
  • updatePayload(...) : to send the added payload to the chatbot
  • clearPayload(...) : To delete all exsting a nd added payloads

SetConfig(...) #

Flags

  • enableHistory : to send the added payload to the chatbot

Example:

String botId = "<Your bot id goes here>";
BuildContext context = <Widget context>;
bool enableHistory = false;
bool enableSpeech = false;
bool enableCloseButton = false;
ymBotSdk.setConfig
(   botId,
    context,
    enableHistory,
    enableSpeech,
    enableCloseButton);

getBotWidget(...) #

Call getBotWidget() method on the ymBotSdk object to get the chatbot widget

Example:

ymBotSdk.getBotWidget(
            botEventListener: (BotEvent botEvent) {
              switch (botEvent.code) {
                case "event1":
                  ymBotSdk.closeBot();
                  print("code is ${botEvent.code}, data");
                  print("is ${botEvent.data}");
                  break;
                default:
                  print("No data");
              }
            },
          ),
7
likes
0
points
11
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