# Building a DeepL node for n8n 💬

## Метаданные

- **Канал:** n8n
- **YouTube:** https://www.youtube.com/watch?v=i3CdiPnyI4Y
- **Дата:** 16.03.2021
- **Длительность:** 1:17:06
- **Просмотры:** 1,947
- **Источник:** https://ekstraktznaniy.ru/video/15866

## Описание

In this live stream, we built a DeepL node for n8n with Omar and Tanay.

Resources:
GitHub repository: https://github.com/n8n-io/n8n​
Node creation docs: https://docs.n8n.io/nodes/creating-nodes/create-node.html

## Транскрипт

### <Untitled Chapter 1> []

so hey everyone welcome to our second live stream welcome people so please say hi in the chat and share where you're joining us from would love to know and today i have with me omar who's a senior software engineer at na10 and we'll be building a node for dpl is that right yeah exactly like um the powers of for those who don't know it yet uh dipl is a machine learning based translation system they still don't have a lot a huge coverage for languages but so far they've been doing so good like it's a very promising tool so anytime doesn't offer any integration for this tool yet so why not build it live awesome yeah and omar please tell us a bit more about yourself sure well um well i'm omar i was born in brazil so i just recently moved to berlin and joined natan it's been just five months so i'm pretty new to the team um i joined i moved to berlin four months ago so pretty new in town as well um i studied computer science and i work as like a developer for actually almost 20 years i would say because i started even like before joining college um so yeah like i love programming i'm very nerdy and geeky i love board games computer games and techy stuff so well yeah that's me that's awesome and what are some of your favorite games oh well board games there's one that i really love it's called lords of water deep uh it's a strategy game like resource allocation uh you have to score the most points oh maybe is that my microphone i make some noises everything's fine no okay cool let's go so uh it's a game where you have to select every play that you take have consequences because you have to choose what sort of resources you want to take this turn and if you take a resource others players cannot get it so you have to watch your game together the best resources for your game and also try to harm the other players in some way so it's a very funny way to play this game and you have to score the most points at the end of eight rounds so it's pretty fun and uh well this is the game the first game i bought once i got to germany i had this game in brazil previously so i had to sell it for the moving but then i just got here and i bought a copy because that's a really awesome game uh that's one the one for board games but i also like computer games um i have been very addicted for a while to a game called factorio it's a game where you build a factory the plot is that actually your spaceship crashed on an alien planet and all you have is your pickaxe so you have to start mining iron copper coal and build a factory so you can build a spaceship and leave this planet again but the cool thing about this game is that you have to optimize your factory you have plenty of resource so you have to from iron ores you create iron plates and then you go to gears and then to sticks and other things that you have to assemble so it's like a big puzzle but you have to get things right and optimizing every little step uh so those are the things i like the most like strategy games that have like to burn your brain a little bit nice that's really cool and um speaking of nhn and uh the new creation of a new node we have a couple of translation nodes already like google translates uh we have one for uh ninguan x both created by us truly um so can you share some background around how and why you decided to create a note for d-pad sure like d-pal uh is a tool that i got to know as a friend of mine has told me like well some background story i just moved to germany and in germany we still use a lot of letters so mayo was actually really used a lot and i always needed to write letters and especially write good letters here always formal sense so a friend of mine told me hey for this case like google translate is awesome but try this tool it will be it will surprise you so i decided to try dfl they have a free trial like actually you don't even need an account to do basic translations um but then like i decided to try to solve and it seems really amazing so okay it works fine uh but then i saw that they don't really have a huge coverage i think they cover like 10 or 12 languages so far i'm not sure the name i'm sorry um but like the choice is really promising and then i realized that they are from germany too so that's even better because you can write your texts in english and they can get it translated to german in a very formal aspect so you can write the letters if you need like get in touch with sellers from stuff because i had to furnish an apartment and buy stuff and maybe complain about your uh about stuff not being delivered you know so that's why i decided to try dfl and it was a very positive surprise like it looks really good the tool is really simple to use but at the same time the translations are really high quality and i can say that because although i don't know german i know portuguese and i tried those translations and they are really awesome so that's why i decided to try deep l and well anytime doesn't have a node so let's try building one that's awesome really cool and uh you mentioned like the api provides a couple of different functionalities so what are we going to implement in the live stream today sure yeah so their api provides actually ways to translate text so you can send multiple sentences or just one sentence if you want but you can translate sentences and you can also upload documents for dbl there's one thing actually for this document specifically uh in order to apply for the german visa they requested from me a resume in german so guess what i use the bell for that so it was a way to have a to quickly have a resume in german too so their api provides those two possibilities but for the documents it's a little bit more complicated because you have to upload the document you have to check if the translation has already finished and you have to download the document after finishing so it's a little bit more complicated and tricky um it wouldn't be like so cool to build in the live stream so for today we'll be building only the text translations maybe in the next section we can build the documents part as well so for now only text translations perfect sounds great so shall we take a look at their docs quickly sure i'll be sharing my screen with you to share the docs let me see oh sorry let me just share the screen so you can present it to our viewers okay nice so uh this is the deep l uh documentations actually the home page is this page um it's in portuguese here so um i don't think they have someone that speaks portuguese so probably this was translated using their machine and i can say that this translation is really good like it's not strange when you read it really feels natural so um the main thing that we need to check is like how does the authentication work so all you have to do is you need an authentication key that's all you need and we have already won we requested a staging key from them and well there are some limits so we have an api key that is sandboxed and until it's allowed to do a few requests so like character limit um i don't know how big this number is if it's 100 million it's just a very big number so far we have consumed like over 600 000 characters but we still have a long way to go and well when it comes to translating text their api says you have to call the com api. dpl. com v2 slash translate so this is the end point we'll be using today for parameters we have to send a text this is the required information it's utf encoded string you can tell um dfl the source language but if you do not it tries to understand what the language was and uh so it's an optional parameter but that's something really cool for this first version we will not be sending this and but if we do have time i would like to add this so let's see how the stream goes so considering it's an optional parameter we'll leave it for later um so you also need to send them the

### Target Language [9:49]

target language so those are the languages they support they have german english for britain and the united states and or just plain english for it's an unspecified variant for backwards compatibility they have french italian japanese spanish dutch polish brazilian portuguese and portugal portuguese because they're slightly different russian and chinese so they have a lot of possibilities credit languages here yeah so that means so how many required fields would we have so we need the text that we want to translate and source language would be optional because it's going to auto detect and we need to give the target language so two required fields and then we have an array of optional fields right exactly so that's all we need so i have a small sample request here i'm using postman for this so uh this is their end point slash translate we have uh so let's look at take a look here as it looks better so the text i'm requesting the translation is hello world i'm not saying the source language so it will have to auto detect that and the target language is uh german and if we hit send i have already set the credentials here it says hello so translation is working yeah um so we can change the text for example i like apples and it says cool it's working awesome perfect and uh you're using postman for

### Postman [11:30]

um checking out the api so is that something that they provide or you created uh no they did not provide postmen as a standalone too many developers use this you can simply create requests so it's a very handy tool when you have to test external or third-party services apis uh it allows you to create those requests and it's very complete so uh we can change the parameters here just as an example i can add more information so if i wanted to use the source length i can easily use this here and it's another information that was added as a query string you can also uh if you have a more complex request that you need to create you can use the wrist the request body uh you can see what cookies were transitioned if you need cookies for any sort of request you can also use them you can check the headers both sent and received so it's a very handful tool and i recommend everyone even if you're not a developer because like nowadays all everything is about apis you need to have postman it's a very handy tool perfect and one last question is so the

### Api Key [12:46]

api key so we would be sending that as part of the query string yeah exactly so this is one of the pattern mirrors here it's called alt key and when you use those double brackets in postman it means that it's a variable so you can set variables so if you have for example let's say a staging and a production environment you can use different environments like i have in here so i have for example no environment deep l escritoria which is the word in portuguese for office local production sandbox so you can have multiple environments and in postman you can even have url as a parameter so you can say for example dbl url for example and this is a variable so you can set this as your environment variable and also use it so that's very handy nice and we can also do that with the http request node in edit and maybe a set note for the variables and http request node oh yeah definitely like if you want to build it in na10 like nowadays like currently we don't have this node you can easily create those requests manually sure awesome so can i see everything yeah i see a comment from somebody who mentioned like turns out um dbell added a lot of integrations today that they are that are not in the list yet so that's great to hear yeah so just like to have a look they

### Translating Documents [14:18]

also have the translating documents information here so what we would need is pretty similar you need to send the source language about the document that you're providing this is also optional the target language this one is required so what you want to translate to uh the authorization key the same one that we're using here like their api key uh you can send the file and i think you can send multiple files but i'm not sure and the file name is also optional just like the name of the uploaded file can be used as an alternative to include the file name and the file parts content disposition yeah that's a little bit more technical so you can send the file name here instead of part of the request body got it perfect so dpl is the tool for us that we're gonna create a note for today and how do we get started with creating a node now okay let's get started let's go to the good parts uh so first things first uh you need to have the development environment set up so i already have this right now so we don't spend a lot of time doing this but the basic steps are you need to have a github account or maybe at least have the get client installed on your machine so you can clone the repository so i'm not going through all of this but just giving you some very uh overview about this you need to clone the repository on your machine and there's a little bit of setup uh na10 was written in javascript so in order to run javascript code on your machine you need to have node installed so you need to install node it's pretty easy to install usually so once you have node installed you need to install any tens dependencies because anything relies on other codes to work so you need to install those dependencies so that na10 works because you know it's a huge software nobody writes software from scratch like everything so we use some third-party libraries to help them this and this is not so hard but i will not be spending so much time on here uh there is a very cool link on our website so if you go to docs. nh. io i think tonight i don't know if you have a link for this to our users right now awesome so like here in the reference page you can see um the contribution parts and the setup uh exactly well the link you sent um so you have like a contribution uh setting a page where users can know and understand like how to get the first get started how what are the first steps you can also see all this information here in our github so there is a contributing section let me just find it you have the documentation here and if you check the contributing file here you have all the instructions that i mentioned so basically how to download a

### Download a Repository [17:17]

repository uh what you need to install like you need python you need some more information you need to install learner which is our package manager inside n10 so code repository install the dependencies build the project and then start so i already did all that so we don't spend a lot of time on this and we already have any 10 running here so the latest the last command that i run is npm run start which is this step and it says um na10 is ready on port 5678 so if i head to my browser and open localhost 5678 we have any dance home screen

### Editor Ui [18:04]

cool so now we have the editor ui here awesome so this is known as the editor where we create start creating the workflows so for users that never played with any 10 before uh this is the way you can run it on your machine like there's actually even an easier way to run it in your machine but the way you start creating stuff is that you can easily click either this plus or you can drag from this connection and

### Add New Nodes [18:28]

add new nodes so let's say i want google translate so i can test something you can create the google translate node you would need the credentials so you can see the documentations here and how do you authenticate the service and pretty similar to what we will be doing today is resource we will be using language operation will be to translate text so we want to translate something and i can simply say hello word and translate to english it just did not auto complete yet because i did not add credentials i don't have those right now but this is the way we start a workflow we just add the necessary information and anytime always tells you what is missing so it's pretty easy and there's always the documentation to help you it's really cool so the note that we'll create would also look something like that exactly so it will be another one on this list of nodes that we already have so our the list is pretty big uh we always have people adding new nodes we have a lot of contributors so yeah this list is ever increasing and that's awesome that's true and uh there's one third way to create a new node uh to add a new node to the canvas and that is pressing the tab button so there's a couple of keyboard shirts yeah i learned that recently i know that one aha nice okay cool learning new things every day so i'll share the link for that so we have a page in the documentation as well

### Keyboard Shortcuts [20:08]

for keyboard shortcuts for anything so uh sure before using the keyboard uh that's the place to go to nice i didn't know that one yeah i knew a few of the shortcuts like if i press ctrl or command o for open uh it brings you this modal where you can search for workflows that i have used before taught you this one cool so well okay so this is the basic nhs structure how it works and let's get into the code why not right let's do it okay so once i'm using visual studio code for

### Code Editing [20:49]

code editing and the basic code structure for na10 um sure yes is it better um yeah i'm not sure if it changed can you really um let me see how can i do this because i mean this command and plus it seems to change to you can see my visual studio screen right i can yeah so i just zoomed in here it's kind of big at the moment to me but okay now it does seem a bit bigger yeah okay cool perfect yeah awesome folks if you have any difficulties leading by any chance let us know in the chats and we can rectify that quickly sure yeah thank you okay so um well anytime was divided into smaller packages so it's made it's easier to maintain so uh this is exactly what you'll find when you clone the repository you see the packages folder and this is the one that's like the motion part where the heart of everything lies uh you have the cli command it's the one that's like the roots of nha this is how everything starts so what we did here when we ran na10 start npm run start actually uh we used one of the commands that is described in this cli package the core is where everything that happens under the hood is like the workflow's executions the way information is being saved uh the way na10 manages credentials but the heart of na10 is inside a car package uh the editor ui is the interface we interact with so all the interface that we see here is here in the editor ui uh package so you have like all our view js files because this editor was built using vue. js css files all of this you can find here uh the nodes development is a group of it's a bunch of tools that help you build new nodes but we won't be using this today would be like using the most simple way to build nodes uh the workflow package is the one that helps all things work together because like once you have the bare bones which are in the car package you have the workflows that uh run on top of it and the last one the node space which are all the nodes that we have and this is where we'll be interacting now you can see like especially we'll be working with two folders the credentials and the nodes so these are the ones that are really relevant to us if you open the node you see that the list is huge because it's exactly this list but all those in here and actually those ones too like the triggers they're all here so this is where we'll be uh interacting most so and how does any yeah like feel free to enter your questions in the chat uh love to uh hear what you're thinking about and omar i had a question for you how long

### How Long Does It Take Typically To Create a New Node [24:12]

does it take typically to create a new node rather does it depend on yeah like there are a few uh that's a very cool question because uh for a basic node like dbl we'll be creating now uh i think that up to an hour we can create a node maybe less not sure but that's because we're using like only one operation we're only translating text but let's say if you're like working with trello where you have to manage boards and cards and people and labels and tags i don't know you name it so that takes definitely longer so maybe a day two days uh i don't know because you have to check all the operations test them because like you know here for tfl we're using just one end point one request so that should be pretty it's like maybe an hour i'd say got it so depends on the scope of the api uh also i guess on the documentation of the api right exactly like how complex it is to make those requests so uh if it's a rest api it's a lot simpler but if you have a soap protocol that's way more complex like a lot more verbose information that you have to add so it really adds more complexity and definitely will take longer to develop yeah makes sense so let's start by checking like um i don't want to start from the scratch because well i don't even know every single part of it so i'll start from the google translate note because this one that's that already exists so maybe i'll start with this file so i'll copy this file and now are you reviewing my code on a live stream no don't feel pressed no pressure yeah so which makes a lot of sense because we probably have similarities in terms of you know uh a text that we have to ask for the target language that we asked for exactly so they're pretty similar in the way that they work so why not use something similar and that's something i always say like when people ask us oh how to start creating a node we'll point them to a file because i'll be on it it's pretty self-explanatory the way the nodes work in na10 and we'll just browse it through it real quickly because uh what we have here it's a bunch of imports those actually say to javascript hey i need to understand some things in your structure how you work so please let me use those uh parts of code that you already have so this is what the import does and uh this is just an interface that we won't be using so we can skip that for now and you have the class the main class actually this one is called google translate we'll call it dpl and that's pretty much what we need to implement so you have a description block and i'll just collapse it real quickly just to show how small it is so i'll collapse the description block you have uh this is optional for like um loading things from the third party service we will be using this too to get deep l's supportive languages oh so that's an end point that you'll be requesting to yeah exactly yeah i forgot to mention this one um so that's something i saw yesterday um they have like listing supported languages yeah like slash languages you can get the supported languages so this is like for unloading from dbl the language they support and the execute function which is what's going to happen once this node has to execute and if i collect this it's over like that's really it and like this one is optional and for the description it's just like a bunch of variables that we're going to use so for example uh i'll rename this class to dpl this interface is not being used anywhere and it's related to google so i don't need this here so i can remove this uh this block doesn't exist here so right now because i don't have the generic functions fill yet so i'll just comment this i will also rename this file because it's not google so let me just quickly rename it to dpl. node. ts this is the name we want and now we'll start changing the information here so display name dfl name dbl this is if this is like an internal name like a code to identify this node so it can be all lowered lowercase but just like it was previously google translate so let's use the l with the upper with the capital l we need a load an icon too and i have already prepared this because where did you get it from um there is one hand i think you did told us usually and that's an awesome hint really usually those websites like all websites um i have to open a incognito window because being logged in they don't let me use the home page so here on their main website they have the press information and the coolest thing about the press information is that they have here their logos so you can easily get this one i just resized it so i cropped it because i only want the logo and i resize it to 60 by 60 because this is the size that we want and there you go an easy way to get a logo so instead of just googling that and trying to get an image that's a very easy way to get this one so uh let me see where i left this file it's here we found it so this is the logo projects let me just put it in this right place any tan packages node space um nodes deep l let me see where it is here okay let me paste this file cool so now we have the logo here deep l dot png good um translate data using dl so uh operation and resource this the subtitle is what shows on your nodes under your node actually so let's say i use agile crm so this is the resources contact the operation is get so you see it's showing only get here but in our case we'll be displaying contact column and gets so resource operation and resource name the l the color so how do we get their color another small hack will be checking their own api here and considering i don't know exactly the color they should be using but just like we can change that later but there's an easy trick uh you just go to anywhere to choose the color uh i just opened the developer console uh it's usually the f12 key or in windows it's ctrl shift c for copy and just go to anything that has a color and i'll just click the logo and voila i have your color awesome ta-da okay that should be looking good i hope

### Credentials [32:05]

okay for credentials we'll be using the deep l credential it is required but the authentication will not be a service account this is the type of authentication that we'll be using in this case it's an api key so i'll use this and there's only one method so i don't have another one it's only one possibility okay for our and the other one is for which may be offered api key and or like multiple base drops exactly right like if you have multiple ways to authenticate a service you can add them all here we'll be using only one so it's only api key uh for authentication okay we have only one option which is api key so this is the way it's going to be presented to our user so oops api key so we can remove this block okay the default needs to be one of the options so it's always also going to be api key uh resource uh we can use the same name for now so resource is going to be language which is the operation we're performing the operation will be translate so just the same as the google translate note we won't be changing that right now we can change that in the future but for now just leave it like this and there is the text that needs to be translated so it's one of the feuds oh just let me go back real quick uh this uh is what the node needs as information in order to run so just to recap what we're doing now uh i'm telling that this node requires credentials to authenticate to the deep l api and i'm saying that this node also needs the text so those are actually the fields for the node so i forgot to mention that so just to make clear what we are doing now so we have the text that's going to be translated and it will only be displayed when so this is something cool about nhn the fields can be can have conditions so i'm only displaying the field text when the operation is translated we can use those conditions to show and hide fields whenever needed and there's also yeah we can also actually add resources there so in case um for nodes like hrcrm for instance uh you might have a resource as company and contacts and both of them might have a get operation so in that case you can specify the operation and the resource so the appropriate one shows up exactly like um for example in another iteration for this node the operation could be uh like let's say the resource could be file for example and uh the operation would be upload for example so we can upload a file for translation for dpl you know so this is the way we can create those uh it's a standard na10 to always use those names like resource and operations always when possible so a resource is a contact a company customer something like this and the operation is create delete uh update things like that so this is what we'll be doing cool so we need the text so no changes here the language will be translating to and this is one cool thing uh considering that deep l provides an end point to list the to get the list of available languages we'll be using that too and there so you can specify and tell an intent hey query dbl's api and get the list of languages so we can create a select with the correct options always so we'll be using this would be populated by the result of the api endpoint exactly so we don't have to hard code this is really cool so the language you use for translations uh so the description is let's just review this the language to use for translation of the input text set to one of the language codes listed in this place so no we have to update this a little bit down so and you can use it uh yeah exactly you can use html if you have a big tooltip a long test text you can use like bold uh italic to help our users understand what they have to do here so the language to use for translation of the input text yes so this is the only thing we need actually in this case so uh remember that here it says load options method is get languages and this is exactly the one that is declared here so you have inside this methods variable you have the load options attribute and the get languages function this is the one we'll be implementing to get the uh list of supported languages from deep l okay so right now like this is something i'll completely ignore for now and also like here the execute is something i'm not be i'm not going to use right now because we need the credential file like we added this information up here about the api key and that's something we need to make sure that works so let's go again to um i have already did some a research yesterday and i saw that the zoom crit then chose is very similar because all they need is a jwt token so it's very similar to what we want so what i'll be doing is like copy paste this file again uh one little difference uh the dbl node file as we can see here in the breadcrumbs the dplnode. ts file is inside the dbl folder in the nodes folder and that's very important so the node is located here but the credentials are located in the credentials folder so credentials and the nodes are sibling folders okay so right let's just save as uh oh what do they do oh yeah t l dot crib then shows dot t so just create another file of the same name dbl api um actually we should probably rename this to dbl credentials let's do this oops not delete it's rename okay dbl api dot credentials. ts okay so are the names of the uh files should we probably have b and i in uh lowercase sorry uh yeah makes sense let me just fix this yes because all files are like this so let's keep the same standards good point thank you okay uh so the name that we have used here dbl api is the same one that needs to be here so i just use the l first so that's a small correction i'll use the same name tfl api and the credentials block right um okay so this is i think this is what we need let's just see so here we'll say then update the name to dpl api dfl uh actually i think this is the one that goes to the documentation page so that's what is displayed here uh do you know uh okay so this one for example for agile crm they're using camel case so i'll be using the l like the capital l so we have to choose the same names in the documentations uh display name api key and that's all we need actually cool okay so this is the credentials file so far what we did is we created two files the node file and the credentials file and also i added the image here so those are three files actually that we added to our project now um na10 is already running it was running it's running already so i have to stop anytime i need to build this project ah actually before building i created those new files but nhn doesn't really know why i created them so nh is probably just ignoring those files when we build the project again in order to let anything know about those files that i created i need to link them so that na10 loads this information when it starts a lot of information but bottom line is i need to add this information to the package. json file inside the nodespace directory so you see we have plenty of package. json files this is the one that we want to interact with uh this is a pretty long same level as the notes folder in the credentials folder right exactly so yeah just yeah it is so we have to add the credentials here so we have to use the file name so let me just scroll down they are all in order so you just add it in the place it has to be so deep l api you just should make sure that the naming is correct l api dot credentials uh one important thing to note is that in here you're using j yes and not ts because the firewood editing is ts file and the package json we're using the js file because it will be built into javascript so we add the credentials here and then we scroll down a little bit more and we have another list of nodes so the upper list is for the credentials and the lower basis for the nodes and then same thing like we just find a place where it has to be right here okay and add the correct information so dfl your entity is alphabetically exactly they have to be ordered alphabetically so this is the name dbl. node. js in this case the folder name is dbl okay so yeah that's what we need so we created three files the node credentials and the logo and we changed the package json file now it's time to end the camera and build and hopefully everything should work that's cross fingers now so while it builds i have a question for you omar um what's your favorite note in anything my favorite note ah the one i use the most is the fun node it's all versatile uh i really like the way that you get all the information so all the input information is sent to you uh and you can change the data as you need so you can iterate through all the data that you have received you can change it and pass it forward pass it on to the next nodes by changing all information and one thing i use it a lot is that during the development i sometimes need to any tend to wait a little bit because i want to test something and you need like two or three seconds would be enough but you need to check something happening before conclusion and the function node allows you to do this like small sleep so it allows anytime to halt for a little bit the execution and then come back without consuming resources so that's something i really like so this has been what i've been using the most i know like maybe not the best answer because you would expect me to say hello it's gmail like because this note is like it it's so much about the tolling it provides me but it's one i use a lot like it's during development and even for my own information whenever users from our community ask uh questions like hey i have this information it's in a very different format and i would like to change it because i want it to look like that so how can i do this and the cool thing is that the answer most of the times would be on the function note because you can really change all the information that you want you can filter out information and that's really amazing okay so um yeah we had a few compilation

### Compilation Errors [45:03]

errors and that's because i left some information that wasn't supposed to be there so let's go back to the call and let's before going to the code let's see what the errors we had like cannot find the name google api request yeah it cannot find because we're working in the dbl node there's no google api request that's because i have less some things behind that we need to remove actually we need to change um so let's go down a little bit in the source code okay so this is the one like google api request it's saying that it's wrong why is that uh because it's a function that was not defined so yeah we'll define this function now let me just go back to the google translate node real quick uh we all we have a standard of using a generic functions file that contains uh helpers for the node so i'll copy this file and put it side by side to the node so i'll add this file here so generic functions good uh what do we need here instead of google api requests i'll say dpl api request so this is the function that you'll be using and let's start working with this file shall we because um in the end we did not build the node yet but we have good news because if we get this error it means that nhn was able to see the file it loaded it it tried to build it so the part that we changed in the package. json files was a success it worked fine so we can move forward even though we did not see the node yet we'll see it in a moment i know everyone wants to see me click the tab button and see the node on the list we'll have that in a moment so okay we need the authentication and

### Authentication [46:54]

instead of service account here remember that we change this one for api key so that's what we want

### Authentication Method [47:01]

authentication method uh this is actually like saying hey i need a parameter for this node i need the authentication parameter the zero means for the first position because if we have multiple input data we can have different information for every line and this is the standard value like if you have nothing like if there is nothing provided this is the default that i want uh we will be using this application json uh all the information that came from the request like the method to be called get post to lead no it seems we have lost omar so we just remove this and we never use the trading slash in this case so because this is something that we expect you to provide in here so just like in this example it always starts with a slash so we'll be using like this makes sense omar i think you dropped out for a sec would you mind repeating the last bit sure yeah so uh this is how we're calling the dpl api so this function is the one that actually doing the hard part of actually connecting and making this request and it get it perceives a few parameters some context about the execution i'll just skip that because like it's internal energy and stuff it provides helpers to us uh the method that we'll be calling get post delete for example the resource this is pretty much the url we will be calling so in this case it will be like slash translate um the body if you have a request body for example a json that you want to send with your request the query string information in this case this is the one that the information will be using like we want to use anybody for this case uh if you want to override the full url you can send this and any possible header so this is pretty much what we it receives and this is how we're going to work with it so we create an options object with all the information that we'll be using uh for this request specifically so headers for example will be a content type application json the method that we'll be calling the request body the query string that was provided to us um uri that we'll be calling so in this case uh we're using api. dpl. com and we do not add the trailing slash here because you provide this when you call the function and uh we are saying that json is true because everything we're sending and receiving can be treated as json objects make sense makes a lot of sense cool awesome okay so what do we have here uh we're checking if the headers keys exist like if it has any value if not we are removing this like actually i'm sorry we're checking if the headers that were sent to the function contain an information and if they do we are merging those headers to the ones that we already have here same thing for the body so actually there is no body here so if there is no if the body is empty we just delete this information because it's not needed and there's the authentication part we only have one method which is api key but anyway we'll just we're still going oh no okay so it seems tomorrow's system is frozen again so we're gonna wait for pit for him to come back and while we do that um if you have any questions please feel free to share them in the chat we'd be really happy to answer and another thing i'd love to know is what is your favorite note in nhn and omar mentioned function nodes so we have some documentation on that as well and how the internal data structure looks like uh it's a very versatile node you can use javascript in it to model the data so let's say if you're getting data in an array format or a format that it should be different um as how you want to show it so you can use the function node to transform the data into something that is suitable for your specific needs um for me i think um it's a tough question like i've been working with a lot of nodes recently

### The Http Request Node [51:58]

probably it is the http request node uh that we talked about really briefly at the beginning of this live stream and what was interesting about it for me is if there is a service for which there isn't a node in anything so that's a deep l and let's say you do not know how to uh write typescript or javascript and you still want to be able to use it from the new workflow what you can do is you can use it you can enter the api url you can add the api key as either expressions in nhn or uh you can hard code it as well we also it supports a couple of different authentication types like api key or uh oauth and so on and you can still make queries to that endpoint and get data from it so uh we have been like writing to a lot of different apis because um the things that i'm working on uh require calls to a lot of different apis and a lot of times it doesn't make sense to write a note for them uh one of the examples is cocktail db api and i like using it for demos because it gives data of random cocktails it gives recipes it gives uh like what kind of ingredients it has is it alcoholic it's not alcoholic it also gives a nice thumbnail and um yeah i can call it using um the http request note and uh yeah you can then use the data which comes just in format again and uh share it forward okay so i am let's wait for a few minutes for omar to join in and while he joins i am curious to know if you have any questions till now um any questions about the structure and i see omar joined in okay i'm gonna add him in yeah i'm just asking if um people have any questions cool i'm sorry i had disconnection issues i think i was talking for the last five minutes probably alone oh no worries i don't know how long i was offline i think the last thing we saw was you're explaining about the headers and like the body and so on that you're sending out the generic functions okay cool so i'll be sharing my screen again and okay so can you people see my screen yes all right awesome so uh what we did in this file um so just quick recap created this function called deep uh dll api request which is the one that will be doing the real talk to dpl api uh we set up a few things the headers the method the request method uh the request body if you have like a json information that needs to be sent the query string for example the ones that we used here on postman this is all query string because of this question mark um uri that will be calling and uh just uh telling our library that everything is json so the input and the output are json information and well there's a bit more code here um if they're uh we're actually checking if the headers were sent and merging those to the existing ones uh the body is also being used here to request body so if you have any information we are using it otherwise you just remove it from the object we get the authentication so i don't think i don't know if you people saw me doing this but i have already changed those okay cool okay and well we basically have a file that should be working fine now those dependencies are not being used so we can remove those and let me just get back here real quick and let's uncomment those so we have the generic functions but instead of google api request we'll use this other one so i just changed all at once so this should be building now because now we have used all the correct naming for variables so let's give it a try perfect and on an average like how long does it take to for a bill to complete well actually my laptop is taking a lot longer than usual it's probably tired this laptop's with me for over four years live stream um yeah maybe but like this laptop is getting really odd and hard but uh on my desktop computer which is an okay computer it's like it's not super high end um it usually takes about 15 to 20 seconds something like this like hardly more than a minute even if my computer is really busy like i have a bunch of tabs open and stuff running on the background it's so usually really quick and another tip that you can use uh there's another command instead of npm run build uh we have to use build for the first times because we have to like get the basic files working so that n810 says okay i have built once but after you did this you can use the npm around the watch and npn will be checking files for changes and rebuilding that so it's a lot faster because you don't have to rebuild the project always so you only you have to what you have to do is to restart the na10 process so during development it saves a lot of time to you nice that's really handy yeah we'll be using this in a moment like once we get this first build working we can try using the watch command and you can see it in action that's really cool so let's yeah go ahead sorry uh like i was just giving some background like why you're doing this um it's because like uh i don't know if we said this on the live i don't think so uh tomorrow we'll be having a hack nation day on n810 yeah that's exactly what i was saying as well so yeah we do um internal hackathons on automation related topics and i think the last one we had was in december i believe um and now we have tomorrow and uh what we do is like we usually go one of two ways so we use na10 to either build a new product or something that solves a problem or we try to automate some internal business process with it and as fate would have it omar and i were teamed up for this time and we've been talking a lot about internal processes but one of the things that we hadn't really in common was you know we are both new to germany we have been trying to learn german and like i've been doing a lot of different uh trying in terms of apps and so on i think one of the things that we both felt uh was common was uh you know we lack context of information you know um you can read so much oh then i went to school is five years old you know that kind of content so we've been thinking about how can we uh get relevant content and reinforce our learning during working as well so we've been looking to do some chat ops and language learning so for that purpose we are building the deep end node exactly so our goal is to like create a node because well first it's cool creating new nodes is always cool and challenging you always learn new things and it's another uh it's another translation option and the cool thing is that uh when using deep l uh let me just open a new tab here and then cognitol tab where my why my computer is starting the watch command so while we were talking um i just ran the end camera and start because we successfully built the project hooray so no more errors like building and i also run the npm run watch so what we have now is that this other tab of my terminal is watching for file changes so whenever i do and i make any change to those files it's automatically building and all i have to do is restart this process which is a lot quicker it's a lot faster than restarting everything uh there's also an option like npm run dev but let's just leave it for another day that's too much so uh the cool thing about this uh website for example is the hello world thing for example uh you can click the words and see like it got lots of possibilities for translations and that's the cool thing that uses machine learning under the hood so if someone knows a little bit about it and people will be correcting the translations made it improves over time and the transitions get better always so that's something i find real quick really cool about this okay so let's see it in action d l oh my god it's here let's see if how it's working so create new api okay i will need to add the credentials here so yeah just a second while i add the credentials let you know here you're ready yeah sure it takes just a second all right it's safe okay cool we can get back online perfect so uh let's see what's happening now the translate 2 did not work so let's see if we have anything in the chair minimum and yes we do have some information here so let's see what happened here when we try to get so no does not have credentials it said 404 undefined so let's see why because we were trying to get the list of uh supported languages here but remember that we did not change this code we simply ignored it and there we go like this one doesn't exist on deep l so their api says that in order to get uh the list of supportive languages you have to call the joint is this it's not this url it's here oh this is the usage and here languages so this is the one that you use so this is probably the reason that the request has failed um so once i do this if you see like at my clock it's 548 it has already built the project so all we have to do is simply ctrl c here and just restart it so it's a lot faster than building the whole project from scratch you just have to restart it real quick it takes like 5 or 10 seconds to do that instead of rebuilding everything so it works a lot better um so here we are let me just refresh my screen real quick and see how it goes so here l the credentials are already here and not yet why does it happen let's see and here it's still returning 404 what did they do wrong https api. l. com language so um let's try this one here and see if it's right uh maybe um still not found what's happening did i get the wrong url that's announced also a possibility oh you have to send type equals target ah still 404 language oh yeah it's languages and type equals right so this is the one all right so let's fix this so languages and we have to send another uh another variable here so what we did is that we have sent the method as a get the resource as slash languages the body is going to be empty so we just use an empty object here and we need to send the query string here so we'll be using type equals targets so this should be it and let's see what happens she should be working out oh we're almost out of time because i said one hour gotta make it really gotta hurry a little bit more so we can finish in our expected time no let's go and then all right just going to refresh this one real quick and here tpl okay and the credential oops did not work widen up because now the information that i'm reading is invalid so in here it's probably it says referring to google translates how it returns information right exactly so you can simply use languages here as the result so languages will be this array of information and what we want is for each language here on this array the name will be dot name and the value will be language exactly so this is language here cool so this should work now all right keeping the fingers crossed oh yeah we're going one step at a time but we're getting we're making progress for each step so yeah all right so let me just save this one so i can easily refresh this one and see it working fine oh nice there we go so let's see german and hello world okay so if we click the execute it's still not going to work properly because we did not implement the execute function so let's not waste time and work on it already so what we do here is that we're going to fix like language is the same thing that was used so um the resources language and the operation is translate so this won't change uh we're getting the text premiere awesome we're getting to translate two which is the language we want to translate to instead of post i'll be using get in here and let me just check the your the other one that we used here previously like this request so we are having to we'll be using slash translate right so it's a slash translate and uh let me see okay call uh this is the body so the body is something that we won't be using because we're assembling all information as a query string and i'll use source length so source length is translate to and we're using text oh it's just text equals to text yeah exactly and then let's see the results for this one because this is very important there is an a translations property so we want the resource about translations uh the first one is an array and we only want the first option here so it's translations index zero so this is what we want so let's just restart na10 real quick and see if it works should be working now i think let's see fingers crossed always close all right so let's say let's just save this one and let's execute this let's just check the terminal if there is anything here okay uh google translate a response value for target length not supported so let's see what we did here uh how do one thing that i like doing is that i need to debug what's happening in this options thing object here so what i'm going to do is that i'm gonna console. like actually just here console. log options so that we don't expose our api key but this is probably yet let's just check if i made any mistake on typo while it restarts but i don't think so source length equals to translate to okay maybe i'm using the wrong name here let me just make sure that this is correct so it's language yeah seems to be right okay let's see now so let's change to german i just changed to make sure that any 10 is using the correct names and let's see now you should also probably remove the two uppercase right but the two uppercase oh it shouldn't affect it yeah because actually the true uppercase thing isn't the name not the value but now that we added this to our terminal we can see what was used here so type target is being used so this one is to get the oh i'm using source link and not target length this is what i did wrong so it's okay we were showcasing how to add additional exactly oh yeah so that's it there we go should work fine now because that's one thing that i like adding those console log messages because they really help you so you can go back to the terminal and see what's happening under the hood and you can easily diagnose anything that's happening that is weird so let me just refresh this one real quick just to make sure that we have an updated version okay and check we're fine now let's see there we go so it said that it detected shark language in english and it translated to german and let's try like um japanese do you know japanese unfortunately not me neither but let's see what comes out well yeah i think it works i hope so it seems like hello world to me in japanese okay so like we made it like in time they're like their next steps here naturally like we can add this like source language to hint uh deep l about it it's not so hard to do um usually in na10 in order to reduce the complexity for users that are using the node for the first time uh we put those additional foods like s additional options let me see if this one has yeah like additional fields so we can add like source language and this drop-down list for our dpl mode and that would be helpful um there's also another improvement that we could make for example um let me just make another translation here uh let me just get any translation here um it all supports that we send multiple sentences at once so like i like apples and text equals hello world for example so we can send text twice and it will translate them correctly so it says and hello so uh those are optimizations that we could do but i'm trying to make it as simple as possible so people can easily replicate this but there's always room for improvement and uh well maybe in the next session we could do this yeah for sure uh so i'll stop sharing my screen oh it seems like we have lost omar again okay let's oh omar are you still there oh okay i have removed your screen can you hear me yes perfectly fine cool um yeah thank you so much this was great and uh like great to see uh the dbl note come to life that we can finally use in our project tomorrow and i think we gotta make that another live stream where we can then share what we build during the hackmation tomorrow our second hack version yeah it's gonna be great uh it was fun coding really as you can see like um i know how jpl uh api works but building this node was like we all we did this live and it's very simple and very easy to create you just think naturally some programming skills but even if you're not like proficient in programming if you know how to make api calls you can easily copy and paste information maybe it's going to take a little bit longer but definitely you can easily create notes for natan yeah for sure and i think omar and i can stay back for maybe three minutes so in case you have any questions it would be great if you could drop them in the chat and we can then address them for you and um yeah so also like i must say that uh it comes with a warning creating notes for nhn is very addictive next time like now what happened like after i created my first notes every time i see a cool api or a cool product the first thing that comes to my mind is oh my god how do i find the access key and so on and create a note for it on edit and so it's a lot of fun yeah definitely like every product i sign up or every product i see i always say oh do they have an apn can we create it that's right yeah exactly and um yeah like um yesterday we create um created our first webinar so in case you are interested in checking that out it's on youtube our youtube channel and uh we use a platform called demo and the cool thing about it has apis so we love api so you know we've been using uh for automating a lot of things in our webinar uh the dna node as well so yeah it's a lot of fun okay so in case we don't have any questions now um i will drop a link in the chat to our community so we have a really active community at community. net. io so if you have any questions if you're building your first node uh or maybe your nth node uh feel free to join in say hi and ask any questions like we'll get back to you very soon yeah thank you so much omar for joining us today no problem thank you for inviting me uh it was really pleasant to build this node with you and share this with our users and uh just like tonight i said check your community forums we have really active and lovely people there always have willing to help it's a really good environment yeah and uh you know we're all learners there so um don't hesitate to ask any questions because uh definitely if something isn't clear it's either like we have to make improvements to the product or to the documentation so don't worry uh ask away any questions that you might have yeah maybe i can solve something using the function node to help you it will be a pleasure yeah all right then thank you so much all for attending and we hope that you found this useful and we will upload this on our youtube channel after this as well so have a nice rest of your day thank you so much and bye
