@tenfold/client-sdk
v1.0.0-alpha.104
Published
Typescript type definitions for client-side integration libraries
Downloads
205
Readme
Tenfold Client SDK
This repo contains typescript types and definitions to help guiding client side integration development. As integrations will be developed as standalone typescript libraries, they will not have access to Tenfold's source code, and this SDK should act as a bridge between the two parties. The interfaces exposed here will provide information about the methods that expected by the Tenfold App, what parameters each method will receive and what is the return type expected for each.
One important thing to notice is that the types exposed by this repo is a mix of types that are exclusive to client integrations and types re-exported by other libraries. The reason for re-exporting them is to simplify development purpose and not force developers to add multiple libraries in your package json when only interested in type definitions.
The Client Integration Descriptor
The client integration descriptor is the core of the integration. The ClientIntegrationDescriptor type is what is exported by your library and represents the concrete instance that is consumed by the Tenfold app. It is the contract that is used by Tenfold App and the integration to talk to each other. While this section will not go into specific details of each method that needs to be implemented by the integration descriptor (you can see it in the JSDocs in the ClientIntegrationDescriptor itself), it will provide a high level overview of how the integration happens. In summary,
- Tenfold App will use information about the user/customer using the app to know what integrations to instantiate
- The integration will be dynamically loaded and will provide an instance of
ClientIntegrationDescriptor
- Tenfold App will create an instance of a container of dependencies and will invoke the optional method
onBindDependencies
in the integration to optionally bind more dependencies in the container (see the Dependency Injection section below) - Tenfold App will invoke the various methods of the integration descriptor with the relevant parameters, plus the injector created in the previous step
Dependency Injection
For details regarding Dependency Injection such as how to use it, what information is available out of the box in the projected injector, etc, see the dependency-injection guide.
Integration aspects
The integration being developed needs to take care of two fundamental aspects:
Passing commands from the Tenfold app over to the provider: This is handled by the adaptors that will be implemented by the integration. The methods on each adaptor will be invoked by the Tenfold App in different occasions with different parameters, and usually represent an action taken by the agent (such as an interaction control - answer, transfer, hangup, etc). See Adaptors for an in-depth explanation on how adaptors work and how they should behave
Passing incoming data from the provider to Tenfold: your integration code should handle any events published by the provider, transform those events by the formatted required by Tenfold and forward those events to the Tenfold App. See Events for a thorough explanation on that.
Other relevant aspects to keep in mind while creating your integration are:
- It's important that the integration descriptor returned by your integration is the default export of the entry point of your package
- Be mindful that your integration will be used in a front end context, which means that it will be downloaded in end-user's browser, so bundle sizes are very important. Be mindful of the dependencies you add in your library and keep an eye for libraries that can leverage on tree-shaking. A very good example is comparing lodash with lodash-es, where the later one can be tree-shaked and the first one can't.
- As you develop your integration, please keep in mind error handling. The ask is to handle errors internally to the integration as best as possible, and convert integration errors to Tenfold Errors to give us most context possible about an error, with a type that can be directly consumed by Tenfold.
Client Integration example
For an example on how to use the client sdk, see https://github.com/tenfold/client-integration-template