Introduction to models

If you understand the basics of creating your own connectors, we can take a deep dive into another topic - models. A model is an abstraction over individual apps and services. It provides both interfaces for how the data looks like, and methods for the communication itself. We always find the best way to communicate with the application, which could be REST API, XML files, working with a database, and more... Every app or service has its own model which is provided as a standalone npm package and has its own reference package with all information needed.

In this example, we will use the Slack model. You can import it by running the following command inside your terminal:

$ yarn add @xomlo/xomlo-models-slack

All models are provided as a class which could be used like this:

import { functions } from "@xomlo/xomlo-sdk";
import { Slack } from "@xomlo/xomlo-models-slack";

functions.main(async () => {
    const slack = new Slack(...);
});

Then you can use all methods specified in the reference. For example:

const slack = new Slack(...);
await slack.sendMessage('channel', 'Hello world!');

Last updated