Can't get NPM external module to work in function node

Hi all!
Installed NPM ( to integrate with an external CRM system, but can’t get any data from it.
The function node does an infinite execution and nothing comes back.
I ask the community for help.

n8n - 🔄 Zadarma 1 - Google Chrome 2022-09-14
n8n - 🔄 Zadarma 2 - Google Chrome 2022-09-14

Hi @Roket, the Connection lost error suggests that your n8n server has become unavailable.

Can you check your server logs? Did n8n crash by any chance?

Hey @MutedJam , the Connection lost occurs briefly. Everything is fine with the server.

Is there a reason you are not simply using the HTTP node and normal api calls?
They seem fairly straight forward. Havent checked in depth but seems to be normal api.

I wrote to their technical support, they said that there is standard support only for the specified programming languages.
I tried via node HTTP request and I couldn’t do it(.

Hmm thats odd.
Is there a free trial or anything I could use to test?

@BramKn , Now let me clarify this. I’ll be back soon with an answer.

@BramKn , Let me give you access to the account on which I am currently setting up? There is nothing in this account, this is a new account.

Hi @Roket

I should have some time to look at it tomorrow. If you can send me a private msg with the info I will have a look.


@BramKn Hey, Sent a private message with all the necessary details. Thank you in advance for your help.

1 Like

Hi @Roket

Ok, so I couldn’t get this to work in a short time.
It should be possible, you just have to sign some string which is a bit of a hassle. Especially because the documentation on it is pretty bad.

So it would take a few tries to get this to work.

Hi @BramKn
I realized that it was not possible to get this to work, but I did not understand, could you find the reason?
Can you help me make this work?

It is possible to make it work. It is simply a bit of a hassle, which would take too much time for me to just do in between other things.

You will need to build a string and hash this. This will be used as the authorization.

Hi all, on the actual topic of the npm module it seems you’re using an async function. What happens if you add an await in front of your function, similar to what is described over here?

Also, can you try returning some empty or dummy data at the end, something like return []; should do?

1 Like

Hi @MutedJam
I am not strong in acync-await, so it will be difficult for me to do this.
If I add dummy data to return, then nothing happens. The node hangs in execution.

Sorry to hear that, this sounds like a problem with the respective module then :frowning:

1 Like

Unfortunately, I am not strong in programming and this task is not clear to me from the point of view of your proposed implementation.

There shouldnt be too much programming involved.
The only tricky thing is the authentication, which is a concatenated string that needs to be hashed. This will take some time to figure out as the documentation isn’t super clear on how to do this other than with PHP.
For me this would take too much time to do as a community question → answer.
But there might be others that have experience with this API or similar.

1 Like

In any case, thank you (@MutedJam , @BramKn ) for your attention to my problem.

1 Like

I try also to figure out with zadarma authorisation.

The problem is with the signature, which is generated with this:

The signature is made according to the following algorithm:

  • The array of transmitted data (GET, POST, PUT, DELETE) is sorted by the key name in alphabetical order;
  • The received array forms the query strip (for example, http_build_query function in PHP), example “from=DATEFROM&to=DATETO…”;
  • It is then concatenated as follows: line = method_name request_line md5(request_line), where “method_name” is the request line after the domain (with indication of API version) till the beginning of the parameters list, for example - ‘/v1/sip’
  • The resulting string is hashed by the algorithm sha1 with the secret user key: hash = hash( string, secret_key )
  • And then the hash is encrypted in base64 signature = base64_encode( hash )

Could it possible to generate the signature using crypto node and then pass the authorisaion as a header? " “Authorization: user_key: signature”.

I am trying but I am not sure that I insert the correct values to crypto and I think that generatio needs to be done in two steps. maybe someone knows how to generate the signature in a function?