diff --git a/packages/backend/src/apps/vtiger-crm/assets/favicon.svg b/packages/backend/src/apps/vtiger-crm/assets/favicon.svg
new file mode 100644
index 00000000..0d95870c
--- /dev/null
+++ b/packages/backend/src/apps/vtiger-crm/assets/favicon.svg
@@ -0,0 +1,925 @@
+
+
+
diff --git a/packages/backend/src/apps/vtiger-crm/auth/index.js b/packages/backend/src/apps/vtiger-crm/auth/index.js
new file mode 100644
index 00000000..03536e69
--- /dev/null
+++ b/packages/backend/src/apps/vtiger-crm/auth/index.js
@@ -0,0 +1,44 @@
+import verifyCredentials from './verify-credentials.js';
+import isStillVerified from './is-still-verified.js';
+
+export default {
+ fields: [
+ {
+ key: 'username',
+ label: 'Username',
+ type: 'string',
+ required: true,
+ readOnly: false,
+ value: null,
+ placeholder: null,
+ description: 'Email address of your Vtiger CRM account',
+ clickToCopy: false,
+ },
+ {
+ key: 'accessKey',
+ label: 'Access Key',
+ type: 'string',
+ required: true,
+ readOnly: false,
+ value: null,
+ placeholder: null,
+ description: 'Access Key of your Vtiger CRM account',
+ clickToCopy: false,
+ },
+ {
+ key: 'domain',
+ label: 'Domain',
+ type: 'string',
+ required: true,
+ readOnly: false,
+ value: null,
+ placeholder: null,
+ description:
+ 'For example: acmeco.od1 if your dashboard url is https://acmeco.od1.vtiger.com. (Unfortunately, we are not able to offer support for self-hosted instances at this moment.)',
+ clickToCopy: false,
+ },
+ ],
+
+ verifyCredentials,
+ isStillVerified,
+};
diff --git a/packages/backend/src/apps/vtiger-crm/auth/is-still-verified.js b/packages/backend/src/apps/vtiger-crm/auth/is-still-verified.js
new file mode 100644
index 00000000..6663679a
--- /dev/null
+++ b/packages/backend/src/apps/vtiger-crm/auth/is-still-verified.js
@@ -0,0 +1,8 @@
+import verifyCredentials from './verify-credentials.js';
+
+const isStillVerified = async ($) => {
+ await verifyCredentials($);
+ return true;
+};
+
+export default isStillVerified;
diff --git a/packages/backend/src/apps/vtiger-crm/auth/verify-credentials.js b/packages/backend/src/apps/vtiger-crm/auth/verify-credentials.js
new file mode 100644
index 00000000..eddc779a
--- /dev/null
+++ b/packages/backend/src/apps/vtiger-crm/auth/verify-credentials.js
@@ -0,0 +1,32 @@
+import crypto from 'crypto';
+
+const verifyCredentials = async ($) => {
+ const params = {
+ operation: 'getchallenge',
+ username: $.auth.data.username,
+ };
+
+ const { data } = await $.http.get('/webservice.php', { params });
+
+ const accessKey = crypto
+ .createHash('md5')
+ .update(data.result.token + $.auth.data.accessKey)
+ .digest('hex');
+
+ const body = {
+ operation: 'login',
+ username: $.auth.data.username,
+ accessKey,
+ };
+
+ const { data: result } = await $.http.post('/webservice.php', body);
+
+ const response = await $.http.get('/restapi/v1/vtiger/default/me');
+
+ await $.auth.set({
+ screenName: `${response.data.result?.first_name} ${response.data.result?.last_name}`,
+ sessionName: result.result.sessionName,
+ });
+};
+
+export default verifyCredentials;
diff --git a/packages/backend/src/apps/vtiger-crm/common/add-auth-header.js b/packages/backend/src/apps/vtiger-crm/common/add-auth-header.js
new file mode 100644
index 00000000..52de16ea
--- /dev/null
+++ b/packages/backend/src/apps/vtiger-crm/common/add-auth-header.js
@@ -0,0 +1,15 @@
+const addAuthHeader = ($, requestConfig) => {
+ const { data } = $.auth;
+
+ if (data?.username && data?.accessKey) {
+ requestConfig.headers['Content-Type'] = 'application/x-www-form-urlencoded';
+ requestConfig.auth = {
+ username: data.username,
+ password: data.accessKey,
+ };
+ }
+
+ return requestConfig;
+};
+
+export default addAuthHeader;
diff --git a/packages/backend/src/apps/vtiger-crm/common/set-base-url.js b/packages/backend/src/apps/vtiger-crm/common/set-base-url.js
new file mode 100644
index 00000000..a0dcffe1
--- /dev/null
+++ b/packages/backend/src/apps/vtiger-crm/common/set-base-url.js
@@ -0,0 +1,10 @@
+const setBaseUrl = ($, requestConfig) => {
+ const domain = $.auth.data.domain;
+ if (domain) {
+ requestConfig.baseURL = `https://${domain}.vtiger.com`;
+ }
+
+ return requestConfig;
+};
+
+export default setBaseUrl;
diff --git a/packages/backend/src/apps/vtiger-crm/index.js b/packages/backend/src/apps/vtiger-crm/index.js
new file mode 100644
index 00000000..50ce24c0
--- /dev/null
+++ b/packages/backend/src/apps/vtiger-crm/index.js
@@ -0,0 +1,17 @@
+import defineApp from '../../helpers/define-app.js';
+import addAuthHeader from './common/add-auth-header.js';
+import setBaseUrl from './common/set-base-url.js';
+import auth from './auth/index.js';
+
+export default defineApp({
+ name: 'Vtiger CRM',
+ key: 'vtiger-crm',
+ iconUrl: '{BASE_URL}/apps/vtiger-crm/assets/favicon.svg',
+ authDocUrl: 'https://automatisch.io/docs/apps/vtiger-crm/connection',
+ supportsConnections: true,
+ baseUrl: '',
+ apiBaseUrl: '',
+ primaryColor: '39a86d',
+ beforeRequest: [setBaseUrl, addAuthHeader],
+ auth,
+});
diff --git a/packages/docs/pages/.vitepress/config.js b/packages/docs/pages/.vitepress/config.js
index 04d3fdcf..35d2846f 100644
--- a/packages/docs/pages/.vitepress/config.js
+++ b/packages/docs/pages/.vitepress/config.js
@@ -305,7 +305,7 @@ export default defineConfig({
collapsed: true,
items: [
{ text: 'Actions', link: '/apps/removebg/actions' },
- { text: 'Connection', link: '/apps/removebg/connection' }
+ { text: 'Connection', link: '/apps/removebg/connection' },
],
},
{
@@ -448,6 +448,12 @@ export default defineConfig({
{ text: 'Connection', link: '/apps/typeform/connection' },
],
},
+ {
+ text: 'Vtiger CRM',
+ collapsible: true,
+ collapsed: true,
+ items: [{ text: 'Connection', link: '/apps/vtiger-crm/connection' }],
+ },
{
text: 'Webhooks',
collapsible: true,
diff --git a/packages/docs/pages/apps/vtiger-crm/connection.md b/packages/docs/pages/apps/vtiger-crm/connection.md
new file mode 100644
index 00000000..101b8760
--- /dev/null
+++ b/packages/docs/pages/apps/vtiger-crm/connection.md
@@ -0,0 +1,13 @@
+# Vtiger CRM
+
+:::info
+This page explains the steps you need to follow to set up the Vtiger CRM connection in Automatisch. If any of the steps are outdated, please let us know!
+:::
+
+1. Go to the [link](https://www.vtiger.com/) and create an account.
+2. Go to **My Preferences** of your account.
+3. Copy **Access Key** value from Vtiger CRM to Automatisch.
+4. Fill **Username** field as your Vtiger CRM account email on Automatisch.
+5. Fill **Domain** field as if your dashboard url is `https://acmeco.od1.vtiger.com`, paste `acmeco.od1` to the field on Automatisch.
+6. Click **Submit** button on Automatisch.
+7. Congrats! Vtiger CRM connection is created.
diff --git a/packages/docs/pages/public/favicons/vtiger-crm.svg b/packages/docs/pages/public/favicons/vtiger-crm.svg
new file mode 100644
index 00000000..0d95870c
--- /dev/null
+++ b/packages/docs/pages/public/favicons/vtiger-crm.svg
@@ -0,0 +1,925 @@
+
+
+