Create custom node with custom credentails


i want the value of ={{$credentials.webhookUrl}} to be dynamically set based on the selected option from the webhookUrl list

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

n8n version:1.39.1

Database (default: SQLite):SQLite
n8n EXECUTIONS_PROCESS setting (default: own, main):default: own, main
Running n8n via (Docker, npm, n8n cloud, desktop app):npm
Operating system:Ubuntu 20.04 LTS

and i’m looking to dynamically retrieve the selected value of the webhookUrl option and use it as a key in the request body.

Hey @Kawther_Bensalem,

Welcome to the community :cake:

Have you tried taking a look at some of the nodes like AWS to see how we handle this there? Is this also in your node file or your credenital file as the code you are using doesn’t look familiar to me.

hello ,Thank you for replying to me
iwant to dynamically set the key in the body parameters to get the selected options in webhookUrl, instead of using a static parameter (the code provided is for custom credentials in JavaScript).
I need the test of the credentials to be triggered automatically with the POST method. Additionally, the body should include a dynamic key, using an expression instead of a static value.
Is it clear now?
For more details, these are the credentials.

Hey @Kawther_Bensalem,

That still isn’t that clear, Where is the webhookUrl coming from is it another call you need to make to another service?

The webhookUrl field in the credentials is simply a select list for the key parameters in the body of the test request. Here is an example code:

this.test = {
    request: {
        baseURL: '={{"$credentials.subdomain}}',
        url: 'register_make_webhook',
        method: 'POST',
        body: {
            '={{$credentials.WebhookUrl}}': '={{$credentials.WebhookUrl}}', 
        },
        auth: {
            username: '={{$credentials.username}}',
            password: '={{$credentials.password}}',
        },
    },
};

Wait so are you trying to register a webhook in a credential test?

Yes, that’s correct.

I don’t know the API you are using but personally I wouldn’t do that, If you check our existing webhook nodes we have 3 methods used to create, check and delete webhooks as webhook urls are normally generated based on the workflow.

Is there a specific reason why you are doing this?

I’m checking the default webhook in n8n, but that’s not the case. It’s okay, and thank you for your assistance.

i have another question ,I want to ask if it’s possible to retrieve the production webhook URL and display it in the custom field within my customized credentials?

Hey @Kawther_Bensalem,

You probably wouldn’t be able to display it in the credenital as the URL is generated in the node itself. Don’t use the Webhook node as your example as that works in a different way instead check out any of the trigger nodes that use webhooks like AcuitySchedulingTrigger that will give you an idea of how to make a webhook trigger node.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.