Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
282b2374a2 |
@@ -0,0 +1,3 @@
|
||||
import listOrganizations from './list-organizations/index.js';
|
||||
|
||||
export default [listOrganizations];
|
@@ -0,0 +1,23 @@
|
||||
export default {
|
||||
name: 'List organizations',
|
||||
key: 'listOrganizations',
|
||||
|
||||
async run($) {
|
||||
const organizations = {
|
||||
data: [],
|
||||
};
|
||||
|
||||
const { data } = await $.http.get('/bigin/v2/org');
|
||||
|
||||
if (data.org) {
|
||||
for (const org of data.org) {
|
||||
organizations.data.push({
|
||||
value: org.id,
|
||||
name: org.company_name,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return organizations;
|
||||
},
|
||||
};
|
@@ -2,6 +2,8 @@ import defineApp from '../../helpers/define-app.js';
|
||||
import addAuthHeader from './common/add-auth-header.js';
|
||||
import auth from './auth/index.js';
|
||||
import setBaseUrl from './common/set-base-url.js';
|
||||
import triggers from './triggers/index.js';
|
||||
import dynamicData from './dynamic-data/index.js';
|
||||
|
||||
export default defineApp({
|
||||
name: 'Bigin By Zoho CRM',
|
||||
@@ -14,4 +16,6 @@ export default defineApp({
|
||||
supportsConnections: true,
|
||||
beforeRequest: [setBaseUrl, addAuthHeader],
|
||||
auth,
|
||||
triggers,
|
||||
dynamicData,
|
||||
});
|
||||
|
@@ -0,0 +1,3 @@
|
||||
import newContacts from './new-contacts/index.js';
|
||||
|
||||
export default [newContacts];
|
@@ -0,0 +1,89 @@
|
||||
import Crypto from 'crypto';
|
||||
import defineTrigger from '../../../../helpers/define-trigger.js';
|
||||
|
||||
export default defineTrigger({
|
||||
name: 'New contacts',
|
||||
key: 'newContacts',
|
||||
type: 'webhook',
|
||||
description: 'Triggers when a new contact is created.',
|
||||
arguments: [
|
||||
{
|
||||
label: 'Organization',
|
||||
key: 'organizationId',
|
||||
type: 'dropdown',
|
||||
required: true,
|
||||
description: '',
|
||||
variables: false,
|
||||
source: {
|
||||
type: 'query',
|
||||
name: 'getDynamicData',
|
||||
arguments: [
|
||||
{
|
||||
name: 'key',
|
||||
value: 'listOrganizations',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
async run($) {
|
||||
const dataItem = {
|
||||
raw: $.request.body,
|
||||
meta: {
|
||||
internalId: Crypto.randomUUID(),
|
||||
},
|
||||
};
|
||||
|
||||
$.pushTriggerItem(dataItem);
|
||||
},
|
||||
|
||||
async testRun($) {
|
||||
const organizationId = $.step.parameters.organizationId;
|
||||
|
||||
const sampleEventData = {
|
||||
ids: ['111111111111111111'],
|
||||
token: null,
|
||||
module: 'Contacts',
|
||||
operation: 'insert',
|
||||
channel_id: organizationId,
|
||||
server_time: 1708426963120,
|
||||
query_params: {},
|
||||
resource_uri: `${$.auth.data.apiDomain}/bigin/v1/Contacts`,
|
||||
affected_fields: [],
|
||||
};
|
||||
|
||||
const dataItem = {
|
||||
raw: sampleEventData,
|
||||
meta: {
|
||||
internalId: sampleEventData.channel_id,
|
||||
},
|
||||
};
|
||||
|
||||
$.pushTriggerItem(dataItem);
|
||||
},
|
||||
|
||||
async registerHook($) {
|
||||
const organizationId = $.step.parameters.organizationId;
|
||||
|
||||
const payload = {
|
||||
watch: [
|
||||
{
|
||||
channel_id: organizationId,
|
||||
notify_url: $.webhookUrl,
|
||||
events: ['Contacts.create'],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
await $.http.post('/bigin/v2/actions/watch', payload);
|
||||
|
||||
await $.flow.setRemoteWebhookId(organizationId);
|
||||
},
|
||||
|
||||
async unregisterHook($) {
|
||||
await $.http.delete(
|
||||
`/bigin/v2/actions/watch?channel_ids=${$.flow.remoteWebhookId}`
|
||||
);
|
||||
},
|
||||
});
|
@@ -37,6 +37,7 @@ export default defineConfig({
|
||||
collapsible: true,
|
||||
collapsed: true,
|
||||
items: [
|
||||
{ text: 'Triggers', link: '/apps/bigin-by-zoho-crm/triggers' },
|
||||
{ text: 'Connection', link: '/apps/bigin-by-zoho-crm/connection' },
|
||||
],
|
||||
},
|
||||
|
12
packages/docs/pages/apps/bigin-by-zoho-crm/triggers.md
Normal file
12
packages/docs/pages/apps/bigin-by-zoho-crm/triggers.md
Normal file
@@ -0,0 +1,12 @@
|
||||
---
|
||||
favicon: /favicons/bigin-by-zoho-crm.svg
|
||||
items:
|
||||
- name: New contacts
|
||||
desc: Triggers when a new contact is created.
|
||||
---
|
||||
|
||||
<script setup>
|
||||
import CustomListing from '../../components/CustomListing.vue'
|
||||
</script>
|
||||
|
||||
<CustomListing />
|
@@ -2,6 +2,7 @@
|
||||
|
||||
The following integrations are currently supported by Automatisch.
|
||||
|
||||
- [Bigin By Zoho CRM](/apps/bigin-by-zoho-crm/triggers)
|
||||
- [Carbone](/apps/carbone/actions)
|
||||
- [DeepL](/apps/deepl/actions)
|
||||
- [Delay](/apps/delay/actions)
|
||||
|
Reference in New Issue
Block a user