Adding Zoho books to Zoho CRM node

My team and I plan to work on adding zoho books into the zoho node we have in n8n.

There are few things we couldn’t understand. If some one from community help us out then it would be great.

Questions:

  1. Should this be a separate node? I think both are related to Zoho so I thought of extending the existing one
  2. How is the token being managed in current Zoho CRM nodes for leads?
    After the oAuth app is connected there is a request which we need to make to get the token and that token will be used for further requests. That’s what I understood from Zoho’s docs. I might be wrong.
    In the current node I couldn’t find any logic to take and manage the token. Please let me know how to manage this.

Thanks in advance.

  1. Should this be a separate node? I think both are related to Zoho so I thought of extending the existing one

Yes, it should be a separated node. Zoho CRM and Zoho Books are two completely different products. The good thing it’s that you can reuse a lot of the code from the Zoho CRM node.

How is the token being managed in current Zoho CRM nodes for leads?

All the OAuth2 workflow is handled for you, even refreshing the token. You have to use the method this.helpers.requestOAuth2 to send the requests.

Let me know if you have further questions.

Love the initiative, @Arpit! Supporting Zoho Books would make n8n better for everyone :+1:

3 „Gefällt mir“

Hello,

Zoho books is an important part of Zoho, is there a plan for a Zoho book node?

1 „Gefällt mir“

Any plan to integrate zoho books? It is getting critically important for me.

1 „Gefällt mir“

We did made that but by the time we were done there were lot of changes related to icon in n8n so didn’t bothered to made an PR. also we are facing another problem. ZOHO has API calling limit. which is being triggered in our use case. so after certain requests (10K or 25K, I am not sure) our workflows are failing.

I am adding the code here. Feel free to test it and make a PR to main repo.

file: packages/nodes-base/nodes/Zoho/ZohoBooks.node.json

{
	"node": "n8n-nodes-base.zohoBooks",
	"nodeVersion": "1.0",
	"codexVersion": "1.0",
	"categories": [
		"Communication",
		"Sales"
	],
	"resources": {
		"credentialDocumentation": [
			{
				"url": "https://docs.n8n.io/credentials/zoho"
			}
		],
		"primaryDocumentation": [
			{
				"url": ""
			}
		]
	}
}

file: packages/nodes-base/nodes/Zoho/ZohoBooks.node.ts

import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
import { IExecuteFunctions } from 'n8n-core';

import { zohoApiRequest } from './GenericFunctions';

const moment = require('moment');



export class ZohoBooks implements INodeType {
	description: INodeTypeDescription = {
		displayName: 'Zoho Book',
		name: 'zohoBooks',
		icon: 'file:zohoCrm.png',
		subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
		group: ['input'],
		version: 1,
		description: 'Consume Zoho Books API.',
		defaults: {
			name: 'Zoho Books',
			color: '#CE2232',
		},
		inputs: ['main'],
		outputs: ['main'],
		credentials: [
			{
				name: 'zohoOAuth2Api',
				required: true,
			},
		],
		properties: [
			{
				displayName: 'Resource',
				name: 'resource',
				type: 'options',
				options: [
					{
						name: 'Invoice',
						value: 'invoice',
					},
				],
				default: 'invoice',
				description: 'The resource to operate on.',
			},
			{
				displayName: 'Operation',
				name: 'operation',
				type: 'options',
				displayOptions: {
					show: {
						resource: [
							'invoice',
						],
					},
				},
				options: [
					{
						name: 'Get All',
						value: 'getAll',
						description: 'List all the invoices',
					},
					{
						name: 'Get an invoice',
						value: 'get',
						description: 'Get one invoice',
					},
				],
				default: 'getAll',
				description: 'The operation to perform.',
			},
			{
				displayName: 'Organization Id',
				name: 'organization_id',
				type: 'string',
				default: '',
				description: 'Organization id to get data from.',
				required: true,
			},
			{
				displayName: 'Date',
				name: 'dateOfInvoice',
				type: 'dateTime',
				default: '',
				description: 'Date of invoices which you want to retrieve.',
				displayOptions: {
					show: {
						operation: [
							'getAll',
						],
					},
				},
			},
			{
				displayName: 'Invoice Id',
				name: 'invoice_id',
				type: 'string',
				default: '',
				description: 'Invoice id which you want to get.',
				displayOptions: {
					show: {
						operation: [
							'get',
						],
					},
				},
			},
		],
	};

	async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
		let returnData: IDataObject[] = [];

		const resource = this.getNodeParameter('resource', 0) as string;
		const operation = this.getNodeParameter('operation', 0) as string;
		const organizationId = this.getNodeParameter('organization_id', 0) as string;


		if (resource === 'invoice') {
			if (operation === 'getAll') {
				const uri = `https://books.zoho.in/api/v3/invoices`;
				let hasMore = true;
				const dateOfInvoice = this.getNodeParameter('dateOfInvoice', 0) as string;

				const qs: IDataObject = {
					organization_id: organizationId,
					date: dateOfInvoice ? moment(dateOfInvoice).format('YYYY-MM-DD') : dateOfInvoice,
					page: 1,
					per_page: 200,
				};


				while (hasMore) {
					const { invoices, page_context: { has_more_page } } = await zohoApiRequest.call(this, 'GET', '', {}, qs, uri);
					returnData = [...returnData, ...invoices];
					hasMore = has_more_page;
					if (typeof (qs.page) === 'number') {
						qs.page++;
					}
				}


			} else if (operation === 'get') {

				const invoiceId = this.getNodeParameter('invoice_id', 0) as string;

				const qs: IDataObject = {
					organization_id: organizationId,
				};

				const uri = `https://books.zoho.in/api/v3/invoices/${invoiceId}`;
				returnData = await zohoApiRequest.call(this, 'GET', '', {}, qs, uri);
			}
		}


		return [this.helpers.returnJsonArray(returnData)];
	}
}

add the "dist/nodes/Zoho/ZohoBooks.node.js", in packages/nodes-base/package.json and then you should be good to go.

If there is any error feel free to reach out to me. do mention me (github username vasani-arpit) in PR if you make one so that I can check/review.

2 „Gefällt mir“

any updates on the Zoho Books native node? or is it possible someone to make a community node for that?

Oh… This was 4 years ago @karmaworks

I think most of those has been made official. have you checked here Best apps & software integrations | n8n

What are you looking for?