New node building and the node not appear im workflow

No
// The execute method will go here
async country(this: ILoadOptionsFunctions): Promise<any> {
const returnData: any = ;

	const optionsForCountries: OptionsWithUri = {
		headers: {
			Accept: 'application/json',
		},
		method: 'GET',
		uri: 'https://rest.clicksend.com/v3/countries',
		json: true,
	};

	const countriesResponse = await this.helpers.request(optionsForCountries);
	console.log(countriesResponse);
	for (const country of countriesResponse.data) {
		returnData.push({
			name: country.value,
			value: country.code,
		});
	}

	return returnData;
}
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
	let responseData;
	const returnData = [];
	const from = this.getNodeParameter('from', 0) as string;
	const to = this.getNodeParameter('to', 0) as string;
	const message = this.getNodeParameter('message', 0) as string;
	// Make HTTP request according to https://developers.clicksend.com/docs/rest/v3/
	const options: OptionsWithUri = {
		headers: {
			Accept: 'application/json',
		},
		method: 'POST',
		body: {
			messages: [
				{
					from: from,
					to: to,
					body: message,
					source: 'n8n',
				},
			],
		},
		uri: `https://rest.clicksend.com/v3/sms/send`,
		json: true,
	};
	responseData = await this.helpers.requestWithAuthentication.call(this, 'clickSendApi', options);
	returnData.push(responseData);

	// Map data to n8n data structure
	return [this.helpers.returnJsonArray(returnData)];
}

I am not sure what is going on with the formatting but you need to put the loadOption function itself into the nodes methods like we do with other nodes.

can we put more than one function into the nodes methods place

Hey @Waqas_Shaukat,

You can indeed, If you check some other nodes you can see how. The Active Campaign node is the first in the list that does this but you can also check things like Slack as well if you wanted other examples.

Hi John i was build a Node In n8n that is working fine.but now i enhance the functionallity of Node like we want to add Trigger as well. before this our Node have only 7 Action that is working as we want but now i added one trigger using our webhook service. i create a new file in node directory and also write the whole code that is require for a trigger node there is no error in coding but when i build the node and run the n8n start the browser opened but the trigger is not available.

Hey @Waqas_Shaukat,

Did you add the trigger node to the package.json?

yes i did

Are you able to share the link to your github repository which would make this a lot quicker?

Hey @Jon
Now I am able to see trigger node in N8N workflow dashboard. trigger node successfully create webhook in our platform and also delete when we delete node from workflow. but when our platform send post request in n8n The trigger does not work if the webhook sends data to the URL. And the execution is not even starting. This is my complete code.

/* eslint-disable n8n-nodes-base/node-filename-against-convention */
import type {
IHookFunctions,
IWebhookFunctions,
IDataObject,
INodeType,
INodeTypeDescription,
IWebhookResponseData,
} from ‘n8n-workflow’;
import { OptionsWithUri } from ‘request-promise-native’;

export class FriendGridTrigger implements INodeType {
description: INodeTypeDescription = {
displayName: ‘ClickSend Trigger’,
name: ‘clicksendTrigger’,
icon: ‘file:clickSend.svg’,
group: [‘trigger’],
version: 1,
description: ‘Handle ClickSend events via webhooks’,
defaults: {
name: ‘ClickSend Trigger’,
},
inputs: ,
outputs: [‘main’],
credentials: [
{
name: ‘clickSendApi’,
required: true,
},
],
webhooks: [
{
name: ‘default’,
httpMethod: ‘POST’,
responseMode: ‘onReceived’,
path: ‘webhook’,
},
],
properties: [
{
displayName: ‘Rule Name’,
name: ‘rule_name’,
type: ‘string’,
default: “”,
description:‘Write a Rule Name’,

		}

	],
};


webhookMethods = {
	default: {
		async checkExists(this: IHookFunctions): Promise<boolean> {
			const webhookData = this.getWorkflowStaticData('node');
			if (webhookData.webhookId === undefined) {
				return false;
			}
			try {
				const options: OptionsWithUri = {
					headers: {
						Accept: 'application/json',
					},
					method: 'GET',
					uri: `https://rest.clicksend.com/v3/automations/sms/inbound/${webhookData.webhookId}`,
					json: true,
				};
				await this.helpers.requestWithAuthentication.call(this, 'clickSendApi', options);
			} catch (error) {
				return false;
			}
			return true;
		},
		async create(this: IHookFunctions): Promise<boolean> {
			const webhookUrl = this.getNodeWebhookUrl('default') as string;
			const webhookData = this.getWorkflowStaticData('node');
			const rule = this.getNodeParameter('rule_name', []) as string[];
			let responseData;
			const options: OptionsWithUri = {
				headers: {
					Accept: 'application/json',
				},
				method: 'POST',
				body: {
					message_search_type: 1,
					message_search_term: 0,
					action_address: webhookUrl,
					dedicated_number: '*',
					rule_name: rule,
					action: 'URL',
					enabled: 1,
					webhook_type: 'json',
				},
				uri: `https://rest.clicksend.com/v3/automations/sms/inbound`,
				json: true,
			};
			responseData = await this.helpers.requestWithAuthentication.call(
				this,
				'clickSendApi',
				options,
			);
			webhookData.webhookId = responseData.data.inbound_rule_id;
			return true;
		},
		async delete(this: IHookFunctions): Promise<boolean> {
			const webhookData = this.getWorkflowStaticData('node');
			try {
				const options: OptionsWithUri = {
					headers: {
						Accept: 'application/json',
					},
					method: 'DELETE',
					uri: `https://rest.clicksend.com/v3/automations/sms/inbound/${webhookData.webhookId}`,
					json: true,
				};
				await this.helpers.requestWithAuthentication.call(this, 'clickSendApi', options);
			}  catch (error) {
				return false;
			}
			delete webhookData.webhookId;
			return true;
		},
	},
};

async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
	const req = this.getRequestObject();
	return {
		workflowData: [this.helpers.returnJsonArray(req.body as IDataObject[])],
	};
}

}

Hey @Waqas_Shaukat,

Rather than sharing the code like that can you share a github repository or similar it makes things a lot easier. What is the webhook url that is being registered in ClickSend is it still localhost?

Hey @Jon
My GitHub repository is private so that’s why. yes the webhook url is still localhost.


and same URL register in clicksend

Hey @Waqas_Shaukat,

I think I know what the problem is here, ClickSend is probably not able to connect to your n8n instance as chances are you don’t have ClickSend and n8n running on the same maching so this means when clicksend resolves localhost it will be pointing to 127.0.0.1 not your machine running n8n.

Can you try setting the WEBHOOK_URL for your n8n instance and make sure the networking routing and A record is in place (or you can use a tunnel like ngrok) and that should then get it working.

Hey @Jon
You are right I used Ngrok and now it is working. Does it get resolved automatically, when I deploy my node to n8n community? Now my node is complete and I have tested all the functionality now my next goal is to deploy it to community node for public user.

Hey @Waqas_Shaukat,

The url will be automatically be picked up so as long as n8n is correctly configured it will be all good.

Hey @Jon
Can you please help me with another problem that my client wants to run node on his local machine which I build. but can’t find the n8n folder in the user folder. they install and run this command npm install n8n -g several times but the n8n folder Not Found.

Hey @Waqas_Shaukat,

They might need to make sure they are running n8n as the same user but I would recommend that they use Docker as the installation is more reliable when it comes to packages.

hey @Jon
they use same user but they need to found .n8n folder in their machine where he can run node locally.
how they Install the node into local n8n instance:

Hey @Waqas_Shaukat,

The .n8n folder will always be in the same folder, typically this is ~/.n8n where this actually is depends on the user and the OS. It is worth noting that it will be a hidden folder that is normally in the users home directory.