1. Home
  2. Docs
  3. Developers
  4. Develop custom packages
  5. Overview

Overview

While Convoworks core library defines how the requests are executed, it does not contain real components that you could use. Actual components are defined in Convoworks packages that you have to register in the system and include in your service.

Besides components, in your package you can define intents, entities, expression language functions and templates for services.

The Convoworks package is a class which implements \Convo\Core\Factory\IPackageDefinition interface. Besides it, your package may implement:

  • \Convo\Core\Intent\ISystemIntentRepository if you provide intents
  • \Convo\Core\Intent\ISystemEntityRepository if you provide entities
  • \Convo\Core\Factory\IComponentProvider if you provide components
  • \Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface if you provide expression functions

We strongly suggest that you use \Convo\Core\Factory\AbstractPackageDefinition as your starting point, because it contains some useful implementations you can use and you will be safe in case that interface changes.

When you are registering your package \Convo\Core\Factory\PackageProviderFactory::registerPackage() you will register it with the \Convo\Core\Factory\IPackageDescriptor and by that separation we do not need to instantiate concrete packages until they are needed.

Here is example you can follow to create and use your own package.

  1. Write a package definition class for your package. This class should extend \Convo\Core\Factory\AbstractPackageDefinition and, optionally, implement what ever you need from the following:
    • _initDefintions() if you provide components
    • _initIntents() if you provide intents
    • _initEntities() if you provide entities
    • getFunctions() if you provide expression functions
  2. Write a .json meta file for your package. Make sure your .json meta file and the .php class have the same name. This meta file should consist of the following information:
    • namespace — A prefix that will distinguish your data from the rest. This allows you to have multiple components of the same name spread out across multiple different packages.
    • author — The package’s author. This can be your name, nickname, your company’s name, etc.
    • email — An email that will be displayed on the package list.
    • source_for — An array of strings. Depending on what your package provides, add the following values: “functions”, “intents”, “entities”, “templates”.
  3. Register your package somewhere in the bootsrap process:
    • Check the \Convo\Proto\LoadPackagesMiddleware for the example
    • Use on of the \Convo\Core\Factory\FunctionPackageDescriptor or \Convo\Core\Factory\ClassPackageDescriptor to provide factory for your package