Add Activepieces integration for workflow automation

- Add Activepieces fork with SmoothSchedule custom piece
- Create integrations app with Activepieces service layer
- Add embed token endpoint for iframe integration
- Create Automations page with embedded workflow builder
- Add sidebar visibility fix for embed mode
- Add list inactive customers endpoint to Public API
- Include SmoothSchedule triggers: event created/updated/cancelled
- Include SmoothSchedule actions: create/update/cancel events, list resources/services/customers

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
poduck
2025-12-18 22:59:37 -05:00
parent 9848268d34
commit 3aa7199503
16292 changed files with 1284892 additions and 4708 deletions

View File

@@ -0,0 +1,18 @@
{
"extends": ["../../../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}

View File

@@ -0,0 +1,7 @@
# pieces-mattermost
This library was generated with [Nx](https://nx.dev).
## Running lint
Run `nx lint pieces-mattermost` to execute the lint via [ESLint](https://eslint.org/).

View File

@@ -0,0 +1,4 @@
{
"name": "@activepieces/piece-mattermost",
"version": "0.3.13"
}

View File

@@ -0,0 +1,51 @@
{
"name": "pieces-mattermost",
"$schema": "../../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "packages/pieces/community/mattermost/src",
"projectType": "library",
"targets": {
"build": {
"executor": "@nx/js:tsc",
"outputs": [
"{options.outputPath}"
],
"options": {
"outputPath": "dist/packages/pieces/community/mattermost",
"tsConfig": "packages/pieces/community/mattermost/tsconfig.lib.json",
"packageJson": "packages/pieces/community/mattermost/package.json",
"main": "packages/pieces/community/mattermost/src/index.ts",
"assets": [
"packages/pieces/community/mattermost/*.md",
{
"input": "packages/pieces/community/mattermost/src/i18n",
"output": "./src/i18n",
"glob": "**/!(i18n.json)"
}
],
"buildableProjectDepsInPackageJsonType": "dependencies",
"updateBuildableProjectDepsInPackageJson": true
},
"dependsOn": [
"^build",
"prebuild"
]
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": [
"{options.outputFile}"
]
},
"prebuild": {
"executor": "nx:run-commands",
"options": {
"cwd": "packages/pieces/community/mattermost",
"command": "bun install --no-save --silent"
},
"dependsOn": [
"^build"
]
}
},
"tags": []
}

View File

@@ -0,0 +1,31 @@
{
"Open-source, self-hosted Slack alternative": "Open-Source, selbst gehostete Slack Alternative",
"Workspace URL": "URL des Arbeitsbereiches",
"Bot Token": "Bot Token",
"The workspace URL of the Mattermost instance (e.g https://activepieces.mattermost.com)": "Die URL des Arbeitsbereiches der Mattermost Instanz (z.B. https://activepieces.mattermost.com)",
"The bot token to use to authenticate": "Der Bot-Token zum Authentifizieren",
"\n**Workspace URL**: The url of mattermost instance (e.g `https://activepieces.mattermost.com`)\n\n**Bot Token**: Obtain it from settings > integrations > bot accounts > add bot account\n": "\n**Workspace URL**: Die Url der wichtigsten Instanz (z.B. `https://activepieces.mattermost. om`)\n\n**Bot Token**: Erhalte es über Einstellungen > Integrationen > Bot Accounts > Bot Account\n",
"Send Message": "Nachricht senden",
"Custom API Call": "Eigener API-Aufruf",
"Send a message to a Mattermost channel": "Sende eine Nachricht an einen Mattermost Channel",
"Make a custom API call to a specific endpoint": "Einen benutzerdefinierten API-Aufruf an einen bestimmten Endpunkt machen",
"Channel ID": "Kanal-ID",
"Message Text": "Nachrichtentext",
"Method": "Methode",
"Headers": "Kopfzeilen",
"Query Parameters": "Abfrageparameter",
"Body": "Körper",
"Response is Binary ?": "Antwort ist binär?",
"No Error on Failure": "Kein Fehler bei Fehler",
"Timeout (in seconds)": "Timeout (in Sekunden)",
"The channel to send the message to, get that ID by clicking on info near start call butto": "Der Kanal, an den die Nachricht gesendet wird, holt diese ID durch Klicken auf Informationen in der Nähe des Startanrufs",
"The text of the message to send": "Der Text der Nachricht",
"Authorization headers are injected automatically from your connection.": "Autorisierungs-Header werden automatisch von Ihrer Verbindung injiziert.",
"Enable for files like PDFs, images, etc..": "Aktivieren für Dateien wie PDFs, Bilder, etc..",
"GET": "ERHALTEN",
"POST": "POST",
"PATCH": "PATCH",
"PUT": "PUT",
"DELETE": "LÖSCHEN",
"HEAD": "HEAD"
}

View File

@@ -0,0 +1,31 @@
{
"Open-source, self-hosted Slack alternative": "Alternativa de código abierto y autosuficiente Slack",
"Workspace URL": "URL del espacio de trabajo",
"Bot Token": "Bot Token",
"The workspace URL of the Mattermost instance (e.g https://activepieces.mattermost.com)": "La URL del espacio de trabajo de la instancia de Mattermost (por ejemplo, https://activepieces.mattermost.com)",
"The bot token to use to authenticate": "El token de bot a usar para autenticar",
"\n**Workspace URL**: The url of mattermost instance (e.g `https://activepieces.mattermost.com`)\n\n**Bot Token**: Obtain it from settings > integrations > bot accounts > add bot account\n": "\n**Workspace URL**: The url of mattermost instance (e.g `https://activepieces.mattermost.com`)\n\n**Bot Token**: Obtain it from settings > integrations > bot accounts > add bot account\n",
"Send Message": "Enviar mensaje",
"Custom API Call": "Llamada API personalizada",
"Send a message to a Mattermost channel": "Enviar un mensaje a un canal de Mattermost",
"Make a custom API call to a specific endpoint": "Hacer una llamada API personalizada a un extremo específico",
"Channel ID": "ID del canal",
"Message Text": "Texto del mensaje",
"Method": "Método",
"Headers": "Encabezados",
"Query Parameters": "Parámetros de consulta",
"Body": "Cuerpo",
"Response is Binary ?": "¿Respuesta es binaria?",
"No Error on Failure": "No hay ningún error en fallo",
"Timeout (in seconds)": "Tiempo de espera (en segundos)",
"The channel to send the message to, get that ID by clicking on info near start call butto": "El canal al que enviar el mensaje, obtener esa ID haciendo clic en la información cerca de empezar la llamada butto",
"The text of the message to send": "El texto del mensaje a enviar",
"Authorization headers are injected automatically from your connection.": "Las cabeceras de autorización se inyectan automáticamente desde tu conexión.",
"Enable for files like PDFs, images, etc..": "Activar para archivos como PDFs, imágenes, etc.",
"GET": "RECOGER",
"POST": "POST",
"PATCH": "PATCH",
"PUT": "PUT",
"DELETE": "BORRAR",
"HEAD": "LIMPIO"
}

View File

@@ -0,0 +1,31 @@
{
"Open-source, self-hosted Slack alternative": "Source ouverte, alternative Slack auto-hébergée",
"Workspace URL": "URL de l'espace de travail",
"Bot Token": "Bot Token",
"The workspace URL of the Mattermost instance (e.g https://activepieces.mattermost.com)": "L'URL de l'espace de travail de l'instance la plus importante (par exemple https://activepieces.mattermost.com)",
"The bot token to use to authenticate": "Le jeton de bot à utiliser pour s'authentifier",
"\n**Workspace URL**: The url of mattermost instance (e.g `https://activepieces.mattermost.com`)\n\n**Bot Token**: Obtain it from settings > integrations > bot accounts > add bot account\n": "\n**URL de l'espace de travail** : L'url de l'instance la plus importante (par exemple `https://activepieces.mattermost. om`)\n\n**Token Bot**: Obtenez-le à partir des paramètres > intégrations > comptes bot > ajouter compte bot\n",
"Send Message": "Envoyer un message",
"Custom API Call": "Appel API personnalisé",
"Send a message to a Mattermost channel": "Envoyer un message à un canal Mattermost",
"Make a custom API call to a specific endpoint": "Passez un appel API personnalisé à un point de terminaison spécifique",
"Channel ID": "ID du canal",
"Message Text": "Texte du message",
"Method": "Méthode",
"Headers": "En-têtes",
"Query Parameters": "Paramètres de requête",
"Body": "Corps",
"Response is Binary ?": "La réponse est Binaire ?",
"No Error on Failure": "Aucune erreur en cas d'échec",
"Timeout (in seconds)": "Délai d'attente (en secondes)",
"The channel to send the message to, get that ID by clicking on info near start call butto": "Le canal vers lequel envoyer le message, obtenez cet ID en cliquant sur les informations près de commencer l'appel mais à",
"The text of the message to send": "Le texte du message à envoyer",
"Authorization headers are injected automatically from your connection.": "Les en-têtes d'autorisation sont injectés automatiquement à partir de votre connexion.",
"Enable for files like PDFs, images, etc..": "Activer pour les fichiers comme les PDFs, les images, etc.",
"GET": "OBTENIR",
"POST": "POSTER",
"PATCH": "PATCH",
"PUT": "EFFACER",
"DELETE": "SUPPRIMER",
"HEAD": "HEAD"
}

View File

@@ -0,0 +1,31 @@
{
"Open-source, self-hosted Slack alternative": "オープンソース、自己ホストの Slack 代替アプリ",
"Workspace URL": "ワークスペースの URL",
"Bot Token": "Bot Token",
"The workspace URL of the Mattermost instance (e.g https://activepieces.mattermost.com)": "Mattermostインスタンスのワークスペース URL (例: https://activeeces.mattermost.com)",
"The bot token to use to authenticate": "認証に使用するボットトークン",
"\n**Workspace URL**: The url of mattermost instance (e.g `https://activepieces.mattermost.com`)\n\n**Bot Token**: Obtain it from settings > integrations > bot accounts > add bot account\n": "\n**Workspace URL**: The url of mattermost instance (e.g `https://activepieces.mattermost.com`)\n\n**Bot Token**: Obtain it from settings > integrations > bot accounts > add bot account\n",
"Send Message": "メッセージを送信",
"Custom API Call": "カスタムAPI通話",
"Send a message to a Mattermost channel": "Mattermostチャンネルにメッセージを送信する",
"Make a custom API call to a specific endpoint": "特定のエンドポイントへのカスタム API コールを実行します。",
"Channel ID": "チャンネル ID",
"Message Text": "メッセージ テキスト",
"Method": "方法",
"Headers": "ヘッダー",
"Query Parameters": "クエリパラメータ",
"Body": "本文",
"Response is Binary ?": "応答はバイナリですか?",
"No Error on Failure": "失敗時にエラーはありません",
"Timeout (in seconds)": "タイムアウト(秒)",
"The channel to send the message to, get that ID by clicking on info near start call butto": "メッセージを送信するチャンネルで、通話開始前の情報をクリックしてIDを取得します。",
"The text of the message to send": "送信するメッセージのテキスト",
"Authorization headers are injected automatically from your connection.": "認証ヘッダは接続から自動的に注入されます。",
"Enable for files like PDFs, images, etc..": "PDF、画像などのファイルを有効にします。",
"GET": "取得",
"POST": "POST",
"PATCH": "PATCH",
"PUT": "PUT",
"DELETE": "削除",
"HEAD": "頭"
}

View File

@@ -0,0 +1,31 @@
{
"Open-source, self-hosted Slack alternative": "Open-source, zelf gehoste Slack alternatief",
"Workspace URL": "URL van werkruimte",
"Bot Token": "Bot Token",
"The workspace URL of the Mattermost instance (e.g https://activepieces.mattermost.com)": "De werkruimte URL van het Mattermost instance (bijv. https://activepieces.matter.com)",
"The bot token to use to authenticate": "De bot token om te gebruiken om te verifiëren",
"\n**Workspace URL**: The url of mattermost instance (e.g `https://activepieces.mattermost.com`)\n\n**Bot Token**: Obtain it from settings > integrations > bot accounts > add bot account\n": "\n**Workspace URL**: De url van matterest instantie (bijv. `https://activepieces.matterst. om`)\n\n**Bot Token**: Verkrijg het vanuit instellingen > integraties > bot accounts > voeg bot account toe\n",
"Send Message": "Verstuur bericht",
"Custom API Call": "Custom API Call",
"Send a message to a Mattermost channel": "Stuur een bericht naar een Mattermost kanaal",
"Make a custom API call to a specific endpoint": "Maak een aangepaste API call naar een specifiek eindpunt",
"Channel ID": "Kanaal ID",
"Message Text": "Bericht Tekst",
"Method": "Methode",
"Headers": "Kopteksten",
"Query Parameters": "Query parameters",
"Body": "Lichaam",
"Response is Binary ?": "Antwoord is binair?",
"No Error on Failure": "Geen fout bij fout",
"Timeout (in seconds)": "Time-out (in seconden)",
"The channel to send the message to, get that ID by clicking on info near start call butto": "Het kanaal om het bericht naar te verzenden, haal dat ID door in de buurt van begin te klikken op informatie",
"The text of the message to send": "De tekst van het te verzenden bericht",
"Authorization headers are injected automatically from your connection.": "Autorisatie headers worden automatisch geïnjecteerd vanuit uw verbinding.",
"Enable for files like PDFs, images, etc..": "Inschakelen voor bestanden zoals PDF's, afbeeldingen etc..",
"GET": "KRIJG",
"POST": "POSTE",
"PATCH": "BEKIJK",
"PUT": "PUT",
"DELETE": "VERWIJDEREN",
"HEAD": "HOOFD"
}

View File

@@ -0,0 +1,31 @@
{
"Open-source, self-hosted Slack alternative": "Alternativa de Slack auto-hospedada",
"Workspace URL": "URL do Workspace",
"Bot Token": "Bot Token",
"The workspace URL of the Mattermost instance (e.g https://activepieces.mattermost.com)": "A URL da área de trabalho da instância Mattermost (por exemplo, https://activepieces.mattermost.com)",
"The bot token to use to authenticate": "O token do bot para autenticação",
"\n**Workspace URL**: The url of mattermost instance (e.g `https://activepieces.mattermost.com`)\n\n**Bot Token**: Obtain it from settings > integrations > bot accounts > add bot account\n": "\n**URL do espaço de trabalho**: A URL da instância principal (por exemplo, `https://activepieces.mattermost. om`)\n\n**Token do Bot **: obtenha-o em configurações > integrações > contas bot > adicione conta bot\n",
"Send Message": "Enviar mensagem",
"Custom API Call": "Chamada de API personalizada",
"Send a message to a Mattermost channel": "Enviar uma mensagem para um canal Mattermost",
"Make a custom API call to a specific endpoint": "Faça uma chamada de API personalizada para um ponto de extremidade específico",
"Channel ID": "ID do canal",
"Message Text": "Texto da Mensagem",
"Method": "Método",
"Headers": "Cabeçalhos",
"Query Parameters": "Parâmetros da consulta",
"Body": "Conteúdo",
"Response is Binary ?": "A resposta é binária ?",
"No Error on Failure": "Nenhum erro no Failure",
"Timeout (in seconds)": "Tempo limite (em segundos)",
"The channel to send the message to, get that ID by clicking on info near start call butto": "O canal para enviar a mensagem, obter o documento de identidade clicando na informação próxima à chamada inicial, ou seja, na lista",
"The text of the message to send": "O texto da mensagem a ser enviada",
"Authorization headers are injected automatically from your connection.": "Os cabeçalhos de autorização são inseridos automaticamente a partir da sua conexão.",
"Enable for files like PDFs, images, etc..": "Habilitar para arquivos como PDFs, imagens, etc..",
"GET": "OBTER",
"POST": "POSTAR",
"PATCH": "COMPRAR",
"PUT": "COLOCAR",
"DELETE": "EXCLUIR",
"HEAD": "CABEÇA"
}

View File

@@ -0,0 +1,30 @@
{
"Mattermost": "Самая важная",
"Open-source, self-hosted Slack alternative": "Альтернатива с открытым исходным кодом, самохостинг",
"Workspace URL": "URL рабочей области",
"Bot Token": "Bot Token",
"The workspace URL of the Mattermost instance (e.g https://activepieces.mattermost.com)": "URL рабочей области экземпляра Mattermost (например https://activepieces.mattermost.com)",
"The bot token to use to authenticate": "Токен бота, используемый для аутентификации",
"\n**Workspace URL**: The url of mattermost instance (e.g `https://activepieces.mattermost.com`)\n\n**Bot Token**: Obtain it from settings > integrations > bot accounts > add bot account\n": "\n**URL-адрес рабочей области**: URL-адрес самой важной копии (например, `https://activepieces.mattermost. om`)\n\n**Bot Token**: Получите его в настройках > интеграции > учетные записи бота > добавить учетную запись бота\n",
"Send Message": "Отправить сообщение",
"Custom API Call": "Пользовательский вызов API",
"Send a message to a Mattermost channel": "Отправить сообщение наиболее важному каналу",
"Make a custom API call to a specific endpoint": "Сделать пользовательский API вызов к определенной конечной точке",
"Channel ID": "ID канала",
"Message Text": "Текст сообщения",
"Method": "Метод",
"Headers": "Заголовки",
"Query Parameters": "Параметры запроса",
"Body": "Тело",
"No Error on Failure": "Нет ошибок при ошибке",
"Timeout (in seconds)": "Таймаут (в секундах)",
"The channel to send the message to, get that ID by clicking on info near start call butto": "Канал для отправки сообщения, чтобы получить этот идентификатор, нажав на информацию вблизи начала вызова butto",
"The text of the message to send": "Текст сообщения для отправки",
"Authorization headers are injected automatically from your connection.": "Заголовки авторизации включаются автоматически из вашего соединения.",
"GET": "ПОЛУЧИТЬ",
"POST": "ПОСТ",
"PATCH": "ПАТЧ",
"PUT": "ПОКУПИТЬ",
"DELETE": "УДАЛИТЬ",
"HEAD": "HEAD"
}

View File

@@ -0,0 +1,31 @@
{
"Open-source, self-hosted Slack alternative": "Open-source, self-hosted Slack alternative",
"Workspace URL": "Workspace URL",
"Bot Token": "Bot Token",
"The workspace URL of the Mattermost instance (e.g https://activepieces.mattermost.com)": "The workspace URL of the Mattermost instance (e.g https://activepieces.mattermost.com)",
"The bot token to use to authenticate": "The bot token to use to authenticate",
"\n**Workspace URL**: The url of mattermost instance (e.g `https://activepieces.mattermost.com`)\n\n**Bot Token**: Obtain it from settings > integrations > bot accounts > add bot account\n": "\n**Workspace URL**: The url of mattermost instance (e.g `https://activepieces.mattermost.com`)\n\n**Bot Token**: Obtain it from settings > integrations > bot accounts > add bot account\n",
"Send Message": "Send Message",
"Custom API Call": "Custom API Call",
"Send a message to a Mattermost channel": "Send a message to a Mattermost channel",
"Make a custom API call to a specific endpoint": "Make a custom API call to a specific endpoint",
"Channel ID": "Channel ID",
"Message Text": "Message Text",
"Method": "Method",
"Headers": "Headers",
"Query Parameters": "Query Parameters",
"Body": "Body",
"Response is Binary ?": "Response is Binary ?",
"No Error on Failure": "No Error on Failure",
"Timeout (in seconds)": "Timeout (in seconds)",
"The channel to send the message to, get that ID by clicking on info near start call butto": "The channel to send the message to, get that ID by clicking on info near start call butto",
"The text of the message to send": "The text of the message to send",
"Authorization headers are injected automatically from your connection.": "Authorization headers are injected automatically from your connection.",
"Enable for files like PDFs, images, etc..": "Enable for files like PDFs, images, etc..",
"GET": "GET",
"POST": "POST",
"PATCH": "PATCH",
"PUT": "PUT",
"DELETE": "DELETE",
"HEAD": "HEAD"
}

View File

@@ -0,0 +1,30 @@
{
"Mattermost": "Mattermost",
"Open-source, self-hosted Slack alternative": "Open-source, self-hosted Slack alternative",
"Workspace URL": "Workspace URL",
"Bot Token": "Bot Token",
"The workspace URL of the Mattermost instance (e.g https://activepieces.mattermost.com)": "The workspace URL of the Mattermost instance (e.g https://activepieces.mattermost.com)",
"The bot token to use to authenticate": "The bot token to use to authenticate",
"\n**Workspace URL**: The url of mattermost instance (e.g `https://activepieces.mattermost.com`)\n\n**Bot Token**: Obtain it from settings > integrations > bot accounts > add bot account\n": "\n**Workspace URL**: The url of mattermost instance (e.g `https://activepieces.mattermost.com`)\n\n**Bot Token**: Obtain it from settings > integrations > bot accounts > add bot account\n",
"Send Message": "Send Message",
"Custom API Call": "Custom API Call",
"Send a message to a Mattermost channel": "Send a message to a Mattermost channel",
"Make a custom API call to a specific endpoint": "Make a custom API call to a specific endpoint",
"Channel ID": "Channel ID",
"Message Text": "Message Text",
"Method": "Method",
"Headers": "Headers",
"Query Parameters": "Query Parameters",
"Body": "Body",
"No Error on Failure": "No Error on Failure",
"Timeout (in seconds)": "Timeout (in seconds)",
"The channel to send the message to, get that ID by clicking on info near start call butto": "The channel to send the message to, get that ID by clicking on info near start call butto",
"The text of the message to send": "The text of the message to send",
"Authorization headers are injected automatically from your connection.": "Authorization headers are injected automatically from your connection.",
"GET": "GET",
"POST": "POST",
"PATCH": "PATCH",
"PUT": "PUT",
"DELETE": "DELETE",
"HEAD": "HEAD"
}

View File

@@ -0,0 +1,31 @@
{
"Open-source, self-hosted Slack alternative": "Open-source, self-hosted Slack alternative",
"Workspace URL": "Workspace URL",
"Bot Token": "Bot Token",
"The workspace URL of the Mattermost instance (e.g https://activepieces.mattermost.com)": "The workspace URL of the Mattermost instance (e.g https://activepieces.mattermost.com)",
"The bot token to use to authenticate": "The bot token to use to authenticate",
"\n**Workspace URL**: The url of mattermost instance (e.g `https://activepieces.mattermost.com`)\n\n**Bot Token**: Obtain it from settings > integrations > bot accounts > add bot account\n": "\n**Workspace URL**: The url of mattermost instance (e.g `https://activepieces.mattermost.com`)\n\n**Bot Token**: Obtain it from settings > integrations > bot accounts > add bot account\n",
"Send Message": "Send Message",
"Custom API Call": "自定义 API 呼叫",
"Send a message to a Mattermost channel": "Send a message to a Mattermost channel",
"Make a custom API call to a specific endpoint": "将一个自定义 API 调用到一个特定的终点",
"Channel ID": "Channel ID",
"Message Text": "Message Text",
"Method": "方法",
"Headers": "信头",
"Query Parameters": "查询参数",
"Body": "正文内容",
"Response is Binary ?": "Response is Binary ?",
"No Error on Failure": "失败时没有错误",
"Timeout (in seconds)": "超时(秒)",
"The channel to send the message to, get that ID by clicking on info near start call butto": "The channel to send the message to, get that ID by clicking on info near start call butto",
"The text of the message to send": "The text of the message to send",
"Authorization headers are injected automatically from your connection.": "授权头自动从您的连接中注入。",
"Enable for files like PDFs, images, etc..": "Enable for files like PDFs, images, etc..",
"GET": "获取",
"POST": "帖子",
"PATCH": "PATCH",
"PUT": "弹出",
"DELETE": "删除",
"HEAD": "黑色"
}

View File

@@ -0,0 +1,55 @@
import { createCustomApiCallAction } from '@activepieces/pieces-common';
import {
PieceAuth,
Property,
createPiece,
} from '@activepieces/pieces-framework';
import { PieceCategory } from '@activepieces/shared';
import { sendMessage } from './lib/actions/send-message';
const markdownDescription = `
**Workspace URL**: The url of mattermost instance (e.g \`https://activepieces.mattermost.com\`)
**Bot Token**: Obtain it from settings > integrations > bot accounts > add bot account
`;
export const mattermostAuth = PieceAuth.CustomAuth({
description: markdownDescription,
required: true,
props: {
workspace_url: Property.ShortText({
displayName: 'Workspace URL',
description:
'The workspace URL of the Mattermost instance (e.g https://activepieces.mattermost.com)',
required: true,
}),
token: Property.ShortText({
displayName: 'Bot Token',
description: 'The bot token to use to authenticate',
required: true,
}),
},
});
export const mattermost = createPiece({
displayName: 'Mattermost',
description: 'Open-source, self-hosted Slack alternative',
logoUrl: 'https://cdn.activepieces.com/pieces/mattermost.png',
minimumSupportedRelease: '0.30.0',
categories: [PieceCategory.COMMUNICATION],
authors: ["kishanprmr","MoShizzle","khaledmashaly","abuaboud"],
auth: mattermostAuth,
actions: [
sendMessage,
createCustomApiCallAction({
baseUrl: (auth) =>auth ?
(auth.props.workspace_url) + '/api/v4' : '',
auth: mattermostAuth,
authMapping: async (auth) => ({
Authorization: `Bearer ${(auth ).props .token}`,
}),
}),
],
triggers: [],
});

View File

@@ -0,0 +1,57 @@
import { createAction, Property } from '@activepieces/pieces-framework';
import {
AuthenticationType,
httpClient,
HttpError,
HttpMethod,
} from '@activepieces/pieces-common';
import { mattermostAuth } from '../..';
export const sendMessage = createAction({
auth: mattermostAuth,
name: 'send_message',
displayName: 'Send Message',
description: 'Send a message to a Mattermost channel',
props: {
channel_id: Property.ShortText({
displayName: 'Channel ID',
description:
'The channel to send the message to, get that ID by clicking on info near start call butto',
required: true,
}),
text: Property.LongText({
displayName: 'Message Text',
description: 'The text of the message to send',
required: true,
}),
},
async run(context) {
// Remove trailing slash from workspace URL
const baseUrl = context.auth.props.workspace_url.replace(/\/$/, '');
try {
return await httpClient.sendRequest({
url: `${baseUrl}/api/v4/posts`,
method: HttpMethod.POST,
authentication: {
type: AuthenticationType.BEARER_TOKEN,
token: context.auth.props.token,
},
body: {
channel_id: context.propsValue.channel_id,
message: context.propsValue.text,
},
});
} catch (e: HttpError | unknown) {
if (e instanceof HttpError) {
const httpError = e as HttpError;
console.log(httpError);
if (httpError?.response.status === 403) {
throw new Error(
'Please make sure you have the correct bot token and channel ID.'
);
}
}
throw e;
}
},
});

View File

@@ -0,0 +1,16 @@
{
"extends": "../../../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
}
],
"compilerOptions": {
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
}
}

View File

@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"outDir": "../../../../dist/out-tsc",
"declaration": true,
"types": ["node"]
},
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"],
"include": ["src/**/*.ts"]
}