Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
b3d2a1167c | ||
![]() |
43c34fcb7b |
@@ -0,0 +1,217 @@
|
|||||||
|
import defineAction from '../../../../helpers/define-action.js';
|
||||||
|
|
||||||
|
export default defineAction({
|
||||||
|
name: 'Create contact',
|
||||||
|
key: 'createContact',
|
||||||
|
description: 'Creates a new contact.',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
label: 'Contact Owner',
|
||||||
|
key: 'contactOwnerId',
|
||||||
|
type: 'dropdown',
|
||||||
|
required: false,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
source: {
|
||||||
|
type: 'query',
|
||||||
|
name: 'getDynamicData',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'key',
|
||||||
|
value: 'listContactOwners',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'First Name',
|
||||||
|
key: 'firstName',
|
||||||
|
type: 'string',
|
||||||
|
required: false,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Last Name',
|
||||||
|
key: 'lastName',
|
||||||
|
type: 'string',
|
||||||
|
required: true,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Title',
|
||||||
|
key: 'title',
|
||||||
|
type: 'string',
|
||||||
|
required: false,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Email',
|
||||||
|
key: 'email',
|
||||||
|
type: 'string',
|
||||||
|
required: false,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Company ID',
|
||||||
|
key: 'companyId',
|
||||||
|
type: 'dropdown',
|
||||||
|
required: false,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
source: {
|
||||||
|
type: 'query',
|
||||||
|
name: 'getDynamicData',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'key',
|
||||||
|
value: 'listCompanies',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Mobile',
|
||||||
|
key: 'mobile',
|
||||||
|
type: 'string',
|
||||||
|
required: false,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Email Opt Out',
|
||||||
|
key: 'emailOptOut',
|
||||||
|
type: 'dropdown',
|
||||||
|
required: false,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
options: [
|
||||||
|
{ label: 'True', value: true },
|
||||||
|
{ label: 'False', value: false },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Tags',
|
||||||
|
key: 'tags',
|
||||||
|
type: 'dynamic',
|
||||||
|
required: false,
|
||||||
|
description: '',
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
label: 'Tag',
|
||||||
|
key: 'tag',
|
||||||
|
type: 'string',
|
||||||
|
required: false,
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Description',
|
||||||
|
key: 'description',
|
||||||
|
type: 'string',
|
||||||
|
required: false,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Mailing Street',
|
||||||
|
key: 'mailingStreet',
|
||||||
|
type: 'string',
|
||||||
|
required: false,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Mailing City',
|
||||||
|
key: 'mailingCity',
|
||||||
|
type: 'string',
|
||||||
|
required: false,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Mailing State',
|
||||||
|
key: 'mailingState',
|
||||||
|
type: 'string',
|
||||||
|
required: false,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Mailing Country',
|
||||||
|
key: 'mailingCountry',
|
||||||
|
type: 'string',
|
||||||
|
required: false,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Mailing Zip',
|
||||||
|
key: 'mailingZip',
|
||||||
|
type: 'string',
|
||||||
|
required: false,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
const {
|
||||||
|
contactOwnerId,
|
||||||
|
firstName,
|
||||||
|
lastName,
|
||||||
|
title,
|
||||||
|
email,
|
||||||
|
companyId,
|
||||||
|
mobile,
|
||||||
|
emailOptOut,
|
||||||
|
tags,
|
||||||
|
description,
|
||||||
|
mailingStreet,
|
||||||
|
mailingCity,
|
||||||
|
mailingState,
|
||||||
|
mailingCountry,
|
||||||
|
mailingZip,
|
||||||
|
} = $.step.parameters;
|
||||||
|
|
||||||
|
const allTags = tags.map((tag) => ({
|
||||||
|
name: tag.tag,
|
||||||
|
}));
|
||||||
|
|
||||||
|
const body = {
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
Owner: {
|
||||||
|
id: contactOwnerId,
|
||||||
|
},
|
||||||
|
Account_Name: {
|
||||||
|
id: companyId,
|
||||||
|
},
|
||||||
|
First_Name: firstName,
|
||||||
|
Last_Name: lastName,
|
||||||
|
Title: title,
|
||||||
|
Email: email,
|
||||||
|
Mobile: mobile,
|
||||||
|
Email_Opt_Out: emailOptOut,
|
||||||
|
Tag: allTags,
|
||||||
|
Description: description,
|
||||||
|
Mailing_Street: mailingStreet,
|
||||||
|
Mailing_City: mailingCity,
|
||||||
|
Mailing_State: mailingState,
|
||||||
|
Mailing_Country: mailingCountry,
|
||||||
|
Mailing_Zip: mailingZip,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
const { data } = await $.http.post(`/bigin/v2/Contacts`, body);
|
||||||
|
|
||||||
|
$.setActionItem({
|
||||||
|
raw: data[0],
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
@@ -0,0 +1,3 @@
|
|||||||
|
import createContact from './create-contact/index.js';
|
||||||
|
|
||||||
|
export default [createContact];
|
@@ -1,3 +1,5 @@
|
|||||||
|
import listCompanies from './list-companies/index.js';
|
||||||
import listOrganizations from './list-organizations/index.js';
|
import listOrganizations from './list-organizations/index.js';
|
||||||
|
import listContactOwners from './list-contact-owners/index.js';
|
||||||
|
|
||||||
export default [listOrganizations];
|
export default [listCompanies, listOrganizations, listContactOwners];
|
||||||
|
@@ -0,0 +1,39 @@
|
|||||||
|
export default {
|
||||||
|
name: 'List companies',
|
||||||
|
key: 'listCompanies',
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
const companies = {
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
const params = new URLSearchParams({
|
||||||
|
page: 1,
|
||||||
|
pageSize: 200,
|
||||||
|
fields: 'Account_Name',
|
||||||
|
});
|
||||||
|
|
||||||
|
let next = false;
|
||||||
|
do {
|
||||||
|
const { data } = await $.http.get('/bigin/v2/Accounts', { params });
|
||||||
|
|
||||||
|
if (data.info.more_records) {
|
||||||
|
params.page = params.page + 1;
|
||||||
|
next = true;
|
||||||
|
} else {
|
||||||
|
next = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.data) {
|
||||||
|
for (const account of data.data) {
|
||||||
|
companies.data.push({
|
||||||
|
value: account.id,
|
||||||
|
name: account.Account_Name,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while (next);
|
||||||
|
|
||||||
|
return companies;
|
||||||
|
},
|
||||||
|
};
|
@@ -0,0 +1,39 @@
|
|||||||
|
export default {
|
||||||
|
name: 'List contact owners',
|
||||||
|
key: 'listContactOwners',
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
const contactOwners = {
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
const params = {
|
||||||
|
type: 'AllUsers',
|
||||||
|
page: 1,
|
||||||
|
pageSize: 200,
|
||||||
|
};
|
||||||
|
|
||||||
|
let next = false;
|
||||||
|
do {
|
||||||
|
const { data } = await $.http.get('/bigin/v2/users', params);
|
||||||
|
|
||||||
|
if (data.users.length === params.pageSize) {
|
||||||
|
next = true;
|
||||||
|
params.page = params.page + 1;
|
||||||
|
} else {
|
||||||
|
next = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.users) {
|
||||||
|
for (const user of data.users) {
|
||||||
|
contactOwners.data.push({
|
||||||
|
value: user.id,
|
||||||
|
name: user.full_name,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while (next);
|
||||||
|
|
||||||
|
return contactOwners;
|
||||||
|
},
|
||||||
|
};
|
@@ -4,6 +4,7 @@ import auth from './auth/index.js';
|
|||||||
import setBaseUrl from './common/set-base-url.js';
|
import setBaseUrl from './common/set-base-url.js';
|
||||||
import triggers from './triggers/index.js';
|
import triggers from './triggers/index.js';
|
||||||
import dynamicData from './dynamic-data/index.js';
|
import dynamicData from './dynamic-data/index.js';
|
||||||
|
import actions from './actions/index.js';
|
||||||
|
|
||||||
export default defineApp({
|
export default defineApp({
|
||||||
name: 'Bigin By Zoho CRM',
|
name: 'Bigin By Zoho CRM',
|
||||||
@@ -18,4 +19,5 @@ export default defineApp({
|
|||||||
auth,
|
auth,
|
||||||
triggers,
|
triggers,
|
||||||
dynamicData,
|
dynamicData,
|
||||||
|
actions,
|
||||||
});
|
});
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
import newCalls from './new-calls/index.js';
|
import newCalls from './new-calls/index.js';
|
||||||
import newCompanies from './new-companies/index.js';
|
import newCompanies from './new-companies/index.js';
|
||||||
import newContacts from './new-contacts/index.js';
|
import newContacts from './new-contacts/index.js';
|
||||||
|
import newProducts from './new-products/index.js';
|
||||||
import newTasks from './new-tasks/index.js';
|
import newTasks from './new-tasks/index.js';
|
||||||
|
|
||||||
export default [newCalls, newCompanies, newContacts, newTasks];
|
export default [newCalls, newCompanies, newContacts, newProducts, newTasks];
|
||||||
|
@@ -0,0 +1,89 @@
|
|||||||
|
import Crypto from 'crypto';
|
||||||
|
import defineTrigger from '../../../../helpers/define-trigger.js';
|
||||||
|
|
||||||
|
export default defineTrigger({
|
||||||
|
name: 'New products',
|
||||||
|
key: 'newProducts',
|
||||||
|
type: 'webhook',
|
||||||
|
description: 'Triggers when a new product 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: 'Products',
|
||||||
|
operation: 'insert',
|
||||||
|
channel_id: organizationId,
|
||||||
|
server_time: 1708426963120,
|
||||||
|
query_params: {},
|
||||||
|
resource_uri: `${$.auth.data.apiDomain}/bigin/v1/Products`,
|
||||||
|
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: ['Products.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}`
|
||||||
|
);
|
||||||
|
},
|
||||||
|
});
|
@@ -38,6 +38,7 @@ export default defineConfig({
|
|||||||
collapsed: true,
|
collapsed: true,
|
||||||
items: [
|
items: [
|
||||||
{ text: 'Triggers', link: '/apps/bigin-by-zoho-crm/triggers' },
|
{ text: 'Triggers', link: '/apps/bigin-by-zoho-crm/triggers' },
|
||||||
|
{ text: 'Actions', link: '/apps/bigin-by-zoho-crm/actions' },
|
||||||
{ text: 'Connection', link: '/apps/bigin-by-zoho-crm/connection' },
|
{ text: 'Connection', link: '/apps/bigin-by-zoho-crm/connection' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
12
packages/docs/pages/apps/bigin-by-zoho-crm/actions.md
Normal file
12
packages/docs/pages/apps/bigin-by-zoho-crm/actions.md
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
---
|
||||||
|
favicon: /favicons/bigin-by-zoho-crm.svg
|
||||||
|
items:
|
||||||
|
- name: Create contact
|
||||||
|
desc: Creates a new contact.
|
||||||
|
---
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import CustomListing from '../../components/CustomListing.vue'
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<CustomListing />
|
@@ -7,6 +7,8 @@ items:
|
|||||||
desc: Triggers when a new company is created.
|
desc: Triggers when a new company is created.
|
||||||
- name: New contacts
|
- name: New contacts
|
||||||
desc: Triggers when a new contact is created.
|
desc: Triggers when a new contact is created.
|
||||||
|
- name: New products
|
||||||
|
desc: Triggers when a new product is created.
|
||||||
- name: New tasks
|
- name: New tasks
|
||||||
desc: Triggers when a new task is created.
|
desc: Triggers when a new task is created.
|
||||||
---
|
---
|
||||||
|
Reference in New Issue
Block a user