createFromFile method

Future<Bot> createFromFile({
  1. String? intents,
  2. String? flow,
  3. String? metadata,
})

Creates a bot from config files.

Each argument is a path to a .json, .yaml or .yml file. The metadata file may contain name, description, industry, webhook_url, webhook_trigger_intents and visible_on_community.

Implementation

Future<Bot> createFromFile({
  String? intents,
  String? flow,
  String? metadata,
}) async {
  final intentsMap = intents == null ? null : await _readConfigFile(intents);
  final flowMap = flow == null ? null : await _readConfigFile(flow);
  final meta =
      metadata == null ? const {} : (await _readConfigFile(metadata) ?? {});

  return createBot(
    name: meta['name'] as String? ?? 'put name here',
    description: meta['description'] as String?,
    industry: meta['industry'] as String?,
    webhookUrl: meta['webhook_url'] as String?,
    webhookTriggerIntents:
        (meta['webhook_trigger_intents'] as List?)?.cast<String>(),
    visibleOnCommunity: meta['visible_on_community'] as bool?,
    intents: intentsMap,
    flow: flowMap,
  );
}