Channles:
- Generic model
- Skack Block kit model
We use TypeScript, and all types are described, full documentation you can find: https://onereach.gitlab.io/platform/transform-channels/index.html
In Browser using unpkg:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Channel transfromer. Browser + UNPKG</title>
</head>
<body>
<script src="https://unpkg.com/@onereach/channel-transformer@latest/dist/channel-transformer.umd.min.js"></script>
<script>
var slackDataModel = {
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "This is a mrkdwn section block :ghost: *this is bold*, and ~this is crossed out~, and <https://google.com|this is a link>"
}
}
]
}
// Transform Slack data model to Generic model
var genericModel = channelTransformer.transformSlackToGeneric(slackDataModel);
// Transfrom back from Generic model to Slack data model
var slackModel = channelTransformer.transformGenericToSlack(genericModel);
console.log(genericModel, slackModel);
</script>
</body>
</html>
ES6
npm i @onereach/channel-transformer
import {
transformSlackToGeneric,
transformGenericToSlack
} from '@onereach/channel-transformer';
Node.js
npm i @onereach/channel-transformer
const {
transformSlackToGeneric,
transformGenericToSlack
} = require('@onereach/channel-transformer');
const slackDataModel = {
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "This is a mrkdwn section block :ghost: *this is bold*, and ~this is crossed out~, and <https://google.com|this is a link>"
}
}
]
}
// Transform Slack data model to Generic model
const genericModel = transformSlackToGeneric(slackDataModel);
// Transfrom back from Generic model to Slack data model
const slackModel = transformGenericToSlack(genericModel);
console.log(genericModel, slackModel);
Developing: ✅ Tests for Slack -> Generic -> Slack ✅ Export types ✅ Can be imported in any js env
- Microsoft Teams channel
- Zoom channel
Sample: Microsoft Teams and Slack
- Microsoft Teams Adaptive Cards data model 👉 transform to default data model 👉 transform from default data model to Slack Block kit data model
- Slack Block kit data model 👉 transform to default data model 👉 transform from default data model to Microsoft Teams Adaptive Cards data model
All data soted in Array of Object. Each object have three required and only possible properties:
- type - type is unic name of field
- props - all settings, states and so on of field
- children - Array of Objects dependent elements
Sample:
[
{
type: 'section',
props: {
variableName: '...',
column: 2,
value: ''
},
children: []
},
{
type: 'input',
props: {
value: '',
required: true
},
children: []
}
]
Small html app for transfroming data from Slack to Genric > https://content-assets.onereach.ai/apps/channel-transformer-app/0.0.3/index.html
Before runnning dev mode install latest node.js and nvm then use command nvm use
- Create new brnach
- Copy structure of anu channel (Slack, Web) in
./src/channels
- Export main functions to
./src/
- Create script in package.json, take for example already created channels
- Slack -> Generic -> Slack. Command
npm run test:slack