botika_va 0.1.5 copy "botika_va: ^0.1.5" to clipboard
botika_va: ^0.1.5 copied to clipboard

A new Flutter plugin of botika Virtual Avatar, providing component to send text and then receive response text and video

Botika VA SDK Flutter #

A new Flutter plugin of botika Virtual Avatar, providing component to send text and then receive response text and video

Installation #

To integrate the plugin in your Flutter App, you need to add this plugin to your pubspec.yaml

Code #

import 'package:botika_va/handlers/va_handler.dart';
import 'package:botika_va/models/config.dart';
import 'package:botika_va/models/webhook_model.dart';
import 'package:botika_va/models/anima_model.dart';

class _MyAppState extends State<MyApp> implements BotikaVaHandler {
  BotikaVa botikaVa = BotikaVa();
  VaConfig vaConfig = VaConfig(
    webhookAccessToken: "YOUR_WEBHOOK_ACCESS_TOKEN",
    weebHookId: "WEBHOOK_ID",
    weebHookRecipientId: "YOUR_WEBHOOK_RECEPIENT_ID",
    weebHooksenderId: "YOUR_WEBHOOK_SENDER_ID",
    animaAccessToken: "YOUR_ANIMA_ACCESS_TOKEN",
    animaRequestId: "YOUR_ANIMA_REQUEST_ID",
    animaTemplate: "AVATAR_TEMPLATE",
    animaVoice: "YOUR_ANIMA_VOICE_ID",
    animaLanguage: "YOUR_ANIMA_VOICE_LANGUAGE",
    animaSenderId: "YOUR_ANIMA_SENDER_ID",
    downloadHeaders: const {
      "Authorization": "Bearer YOUR_ANIMA_ACCESS_TOKEN",
      "Cache-Control": "no-cache",
      "Pragma": "no-cache",
      "Accept": "*/*",
      "Accept-Encoding": "gzip, deflate, br",
      "Connection": "keep-alive",
    },
    profilingToken: "YOUR_PROFILING_TOKEN",
    profileAccessToken: "YOUR_PROFILING_ACCESS_TOKEN",
    profileBotId: "YOUR_PROFILING_BOT_ID",

    // set to false this is for internal only
    isInternal: false,

    // set to true, for response with text + audio
    // set to false, for response with text + video
    voiceOnly: true,
  );

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

    botikaVa.addSubscriber("MyController", this);
    botikaVa.init("YOUR_USER_ID", vaConfig);
  }

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

    botikaVa.removeSubscriber("MyController");
    botikaVa.dispose();
  }

  void send() {

    // send message to your VA by using 
    // sendMessage() function
    botikaVa.sendMessage("hello...");
  }

  @override
  void onVaError(String message) {
    // display error message
  }

  @override
  void onVaResponseVoice(MessageModel msg, List<String?> audios) {
    // display message get from : msg.value

    for (String? url in audios) {
      // url of audio
    }
  }

  @override
  void onVaResponse(MessageModel msg, List<DownloadVideoModel> videos) {
    // display message get from : msg.value

    for (DownloadVideoModel r in videos) {
      // get data video by using : r.getUri()
      // header can be obtain from : vaConfig.downloadHeaders!
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
      ),
    );
  }
}

1
likes
0
points
20
downloads

Publisher

unverified uploader

Weekly Downloads

A new Flutter plugin of botika Virtual Avatar, providing component to send text and then receive response text and video

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, flutter_client_sse, http

More

Packages that depend on botika_va