A Step-by-Step Guide to implementing AI in your app with n8n
Tags: ai, api, aiautomation, n8n
Published: 2023-02-08 15:48:34

*In this tutorial, we'll show you how to integrate Eden AI's [Invoice parser,](http://www.edenai.co/feature/ocr-invoice?referral=integrate-invoice-parser-n8n) [Language detection](http://www.edenai.co/feature/language-detection?referral=integrate-invoice-parser-n8n) and [Translation](http://www.edenai.co/feature/machine-translation?referral=integrate-invoice-parser-n8n) API into your app using n8n. But there is a limitless amount of possible workflows ([Image tagging](https://www.edenai.co/feature/object-detection?referral=integrate-invoice-parser-n8n), [Explicit content detection](http://www.edenai.co/feature/explicit-content-detection?referral=integrate-invoice-parser-n8n), [Text analysis](https://www.edenai.co/technologies/text?referral=integrate-invoice-parser-n8n), etc), so we suggest you also try your own!*

‍

NOTE: to follow through with this tutorial, you'll first need to [get your 🔑API key on Eden AI for FREE!](https://app.edenai.run/user/register?referral=integrate-invoice-parser-n8n)

‍

## **What is n8n?**

n8n is an automation tool for no-coders, allowing us to easily create and automate workflows using a large variety of services like google services, aws, http requests, slack etc.

![https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/63e116a69ea907ad0970c14e_EIUAtbR4YhNWWPcE0cwWU4FuQTWrTSB3TwXEdDg52dhDaLWlqJOtcWIdPd6vKfVtduAufhlgtL9VuS6tnJyM4zqjsjk1rqFq7Xi1Y1iKqSM5goD4QvjAuKSZ-YRihqpTogcWN3hmKP05rAqXwBdlbEs.png](https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/63e116a69ea907ad0970c14e_EIUAtbR4YhNWWPcE0cwWU4FuQTWrTSB3TwXEdDg52dhDaLWlqJOtcWIdPd6vKfVtduAufhlgtL9VuS6tnJyM4zqjsjk1rqFq7Xi1Y1iKqSM5goD4QvjAuKSZ-YRihqpTogcWN3hmKP05rAqXwBdlbEs.png)

‍

## **Demo 1 | How to add invoice parsing to your app with n8n?**

‍

### **Before we start, what is Invoice Parsing?**

Just like [Receipt](https://www.edenai.co/post/top-10-ocr-receipt-parser-api?referral=integrate-invoice-parser-n8n) and [Resume](https://www.edenai.co/post/top-10-ocr-resume-parser-api?referral=integrate-invoice-parser-n8n) Parsing, Invoice Parsing is a tool powered by [OCR](https://www.edenai.co/post/analyze-easily-document-files-with-ai-optical-character-recognition-ocr?referral=integrate-invoice-parser-n8n) to extract and digitalize meaningful data, [Computer Vision](https://www.edenai.co/post/best-computer-vision-apis?referral=integrate-invoice-parser-n8n) to identify structure of the document, and [NLP](https://www.edenai.co/post/best-natural-language-processing-apis?referral=integrate-invoice-parser-n8n) techniques to pin down the fields. Invoice parser technology extracts key information from an invoice (.pdf, .png or .jpg format) such as the invoice ID, total amount due, invoice date, customer name, etc.

![Invoice Parsing results on Eden AI](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vh4klplbb2crd58mcn2u.png)

Invoice parser APIs help ensure data accuracy by avoiding errors that can occur during manual data extraction. Then, this information can be used for a variety of purposes and makes it easier to generate reports or export data to other applications and is often used in conjunction with other business management applications.

**[Try Eden AI for FREE](https://app.edenai.run/user/register?referral=integrate-invoice-parser-n8n)**

Bear in mind that your final invoice parsing workflow will look like this:

![https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/63e11b358476712d272f67bf_brUCKSpDWIvuONMzpbjuy1znghhzB31kXyW7DAQimDXBQEJce94XfMsqrFM6D7A0VOUeX2Ro4-HxqZaBbWXGUzPC5IvkEtgzZgV1uwLE7AK8o5dapVPjGgp2S77CzvDmMER5Sqe0FQyPVN5eG2GguUU.png](https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/63e11b358476712d272f67bf_brUCKSpDWIvuONMzpbjuy1znghhzB31kXyW7DAQimDXBQEJce94XfMsqrFM6D7A0VOUeX2Ro4-HxqZaBbWXGUzPC5IvkEtgzZgV1uwLE7AK8o5dapVPjGgp2S77CzvDmMER5Sqe0FQyPVN5eG2GguUU.png)

1. **Send a message** to Telegram bot
2. **Process the file** on Eden AI
3. **Send the response** in a file (JSON) on telegram
4. If error happens: send the error message on telegram

‍

Each step of the workflow will be taken care of by a "node". The first node is called a trigger node, so let's start with the telegram trigger node.

NOTE: if you are trying n8n locally you will need to use the --tunnel option in your docker run command (see: https://github.com/n8n-io/n8n/blob/master/docker/images/n8n/README.md)


### **1. Set up a Telegram Trigger**

First, you need to search for the Telegram trigger node in the search bar and configure it:

![https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/63e11b360fe0871729cc3a23_ZwTCCuUAissEE7U7hrDFATXcrTCqJPuD5dovYPsZK-5UPF5YpZkCdvjx2myyHve9xU8UrpzC2wI2V8DjhTM4c5xJ_yfBIR6FrOq7dt1erbb6BkfVvX7ViyWugiPZM2hOtk-Aqx078A7AMECs9WayCYo.png](https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/63e11b360fe0871729cc3a23_ZwTCCuUAissEE7U7hrDFATXcrTCqJPuD5dovYPsZK-5UPF5YpZkCdvjx2myyHve9xU8UrpzC2wI2V8DjhTM4c5xJ_yfBIR6FrOq7dt1erbb6BkfVvX7ViyWugiPZM2hOtk-Aqx078A7AMECs9WayCYo.png)


Use your bot access key as credentials, and choose "Message" as the node trigger so that your workflow will be triggered each time you send a message to your bot.

To make it, download incoming files, in the "Additional Field" Category choose "Download Images/Files".


### **2. Set up an HTTP request**

The next node is the "HTTP Request" node. It will serve to make a request to Eden AI with the file received from Telegram.

The node should have the following configuration for Credentials:

![https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/63e11b36aa9365c580c24e63_u4RlUqaPUkLcHwC6aGMVYFieTT6O6v2O5j2aGRGiwl_pK03WBYajWafy1h0bWWJk_wgnG5n4irInktfJFG97HaBl2_InwuRj4xDR-AIRg7aRpqcSx0xbTuy2lCFz8893PPnPIYI9hZneeK0nuEZEf0g.png](https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/63e11b36aa9365c580c24e63_u4RlUqaPUkLcHwC6aGMVYFieTT6O6v2O5j2aGRGiwl_pK03WBYajWafy1h0bWWJk_wgnG5n4irInktfJFG97HaBl2_InwuRj4xDR-AIRg7aRpqcSx0xbTuy2lCFz8893PPnPIYI9hZneeK0nuEZEf0g.png)
‍

#### **In Header Auth account:**

Choose “authorization” for Name and “Bearer <your api key>” for Value

(We suggest you use your Sandbox API key to test your workflow first)


#### **Body Configuration:**

![https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/63e11b36ea96732ebfb01b9c_nNV38BpceIsNSzyCiUKy1zUKlfyqFhLHyQe2PVeAsvUhdDKHUiel-mslx3ZwLW0bmYw_mPNY8wtonarD1Yq7JTivCCToHc4rLCD2CjCwjsZzMRVxzQDpZSQwHYC4lShcv6Ti-iK2cdVPHnWwau7mnO8.png](https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/63e11b36ea96732ebfb01b9c_nNV38BpceIsNSzyCiUKy1zUKlfyqFhLHyQe2PVeAsvUhdDKHUiel-mslx3ZwLW0bmYw_mPNY8wtonarD1Yq7JTivCCToHc4rLCD2CjCwjsZzMRVxzQDpZSQwHYC4lShcv6Ti-iK2cdVPHnWwau7mnO8.png)

‍

Use  “n8n binary data” to select the file from the previous node and use it as a parameter.

You can already try your workflow and see the result from http request as JSON  data!

‍
### **3. Send back via Telegram**

Now, you just need to take the JSON data and send it via Telegram. But a file needs to be in binary, not in JSON format. So we use a new node "Move binary data" and configure it to move from JSON to binary.

![https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/63e11b36fb676111205b0ef4_b-9r2ve9-o6lKw1Iyko4SxIQjaemp2G4y8XOeR5GZMyDdM6OSyUe6duMUx335dtBr3_Q3bAzopQaufBXgW5Y7kgE82sz7bbwGf4redDXG8brPHbMl6-As6x31vyqdaM315znBcbdfjxbzeuhkAas_-8.png](https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/63e11b36fb676111205b0ef4_b-9r2ve9-o6lKw1Iyko4SxIQjaemp2G4y8XOeR5GZMyDdM6OSyUe6duMUx335dtBr3_Q3bAzopQaufBXgW5Y7kgE82sz7bbwGf4redDXG8brPHbMl6-As6x31vyqdaM315znBcbdfjxbzeuhkAas_-8.png)

‍
Finally, you can use the Telegram node (not the same as "Telegram trigger node") to send a message with the file using your chat id:

![https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/63e11b3610805013eb3d0b58_KA9mrGd1UdYoW95HDAYK4o5JkufKwHojepI8iTxoc-iuJMMN6pMAbK8PzmyqyY3vVTs1kd2_T4brr4l7xPWniWpClGkmB-moop6cfr_gPEkogSGQeFoaE8xsfMfJBmM-WOhu5GMm1MCiNjHVyQzdUnQ.png](https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/63e11b3610805013eb3d0b58_KA9mrGd1UdYoW95HDAYK4o5JkufKwHojepI8iTxoc-iuJMMN6pMAbK8PzmyqyY3vVTs1kd2_T4brr4l7xPWniWpClGkmB-moop6cfr_gPEkogSGQeFoaE8xsfMfJBmM-WOhu5GMm1MCiNjHVyQzdUnQ.png)


### **4. Optional: Error handling**

If an error happens, it is better to be notified instead of getting no response at all. For this purpose, there is an "Error trigger node" that you can use. It will be triggered whenever an error occurs in the workflow. Then, you can link it to another Telegram node to send the error message.
‍

## **Demo 2 | Language detection + translation**

This time we want to translate text into English only if the text’s language is not English.

The final workflow should look like that:

![https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/63e11b361080504c863d0b59_qCoI9rOTMKLCD0FknaUTu5WZU4U1TXtMsZvRTR3N4RXwDQkD5nEhWp_bU0ygR-X-1JEc59AKT2P_IlYkcCjQKiDHrlwLXW2pDgJ12DQh7wUaZfADWEKrZfhH7fDo5gCzdSmDfTvCgWKetK3dwjF8RsM.png](https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/63e11b361080504c863d0b59_qCoI9rOTMKLCD0FknaUTu5WZU4U1TXtMsZvRTR3N4RXwDQkD5nEhWp_bU0ygR-X-1JEc59AKT2P_IlYkcCjQKiDHrlwLXW2pDgJ12DQh7wUaZfADWEKrZfhH7fDo5gCzdSmDfTvCgWKetK3dwjF8RsM.png)

This time, we're introducing a branch in the workflow. IF the language detected is English, do nothing, ELSE translate it.


### **1. Set up a Telegram trigger**

The Telegram trigger is nearly the same as in our first demo for invoice parsing but without the option to download files.


### **2. Set up an HTTP request**

The HTTP Request trigger is nearly the same. You just need to change the endpoint, the encoding type (JSON) and the body parameters (you can see [our api documentation here](https://docs.edenai.co/reference/translation_language_detection_create?referral=integrate-invoice-parser-n8n)):

![https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/63e11b3659418dcdcf6a021a_6e03AeWT6cGed7QVfSSS4RJfeqgjBpoOXgQ3dXRFPmuUQ3_qTtqJnOUqfAvqoQ4LIMgkeHQ8l7pBj5BrqT4dF3YvpZZpaL-rs_XMBx3h7ct6rHWtbnuqyj1fMPW8EeNr29gBKihofEVOPMUHKRxm-W0.png](https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/63e11b3659418dcdcf6a021a_6e03AeWT6cGed7QVfSSS4RJfeqgjBpoOXgQ3dXRFPmuUQ3_qTtqJnOUqfAvqoQ4LIMgkeHQ8l7pBj5BrqT4dF3YvpZZpaL-rs_XMBx3h7ct6rHWtbnuqyj1fMPW8EeNr29gBKihofEVOPMUHKRxm-W0.png)

‍
Remember to add a parameter “attribute_as_list” to *true*, so that instead of receiving a list of objects containing a language and a confidence score, you will get multiple lists: one with all the languages detected, and another with all the corresponding confidences.

This will help us in the next step as we want to know if English is part of the list of languages detected. You can see that in the “text” field, you have a dynamic Value. When you want to use specific data from a previous node that is not binary, you can use an *Expressions* instead of a Fixed Value.

If you click on the expand button you will get an interface to choose the right field from the data of the previous nodes, you can also just drag and drop the field you need in the Value input. Here, you’ll just need the text part of the message received.

### **3. Branch the workflow**

After getting the response, you can branch the workflow depending on its content.

Then, add a condition that will be *true* if “en” is in the list of languages as followed:

![https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/63e11b36de6dde389581d318_aNO08VHavlast_bnQWgU8SkOCBRM69Swcthw0mtE6o_hMoIFDybQWx6XKAb8w8ZNiPr_wHXLyOFsbfwb_5TSocYuyAWIwNgSfkYZc98Q-A3JD0IGb1mieDlsObcVphz_BXaF-csFxuZ5RNazHjU8Vw0.png](https://uploads-ssl.webflow.com/61e7d259b7746e3f63f0b6be/63e11b36de6dde389581d318_aNO08VHavlast_bnQWgU8SkOCBRM69Swcthw0mtE6o_hMoIFDybQWx6XKAb8w8ZNiPr_wHXLyOFsbfwb_5TSocYuyAWIwNgSfkYZc98Q-A3JD0IGb1mieDlsObcVphz_BXaF-csFxuZ5RNazHjU8Vw0.png)

We just want to know if “languages” list **contains** the value “en”. If the condition is *true*, the workflow will go to the *true* branch, otherwise *false*.


### **4. Translate and send it to Telegram**

#### **Let’s say your text is not in English:**

You want to translate the text. To do this,  once again, use an HTTP Request node to make a request to Eden AI. There is nothing special happening that we didn’t see in the previous ones, we just want to translate the text message.

Now that you’ve translated the message, you can send it back on telegram!
‍

#### **What if English is detected in the text?**

We can just add a “Do nothing” node to… do nothing.

That's it, you now have a chat that automatically translates messages written in a foreign language!
‍

## **Time to build your own workflow!**

That's it!🥳

What we showed you is just a glimpse of all the possibilities available.

Thanks to n8n and Eden AI, it is very easy to build your own workflow using the power of AI and automation without having to write code! Bear in mind that what we showed you were examples using Telegram but you could use nearly anything.

n8n as a large variety of built-in nodes, plus a great amount of community nodes. For instance, you could use similar workflows with Discord, or use mails, Google Drive, AWS, databases, Stripe, etc.

‍

*If you're interesting in more low-code tools, have a look at our step-by-step tutorials on how to bring AI to your application with [Power Apps](https://www.edenai.co/post/a-step-by-step-guide-to-integrating-edenai-invoice-parser-on-microsoft-powerapps?referral=integrate-invoice-parser-n8n), [Google App Script](https://www.edenai.co/post/a-step-by-step-guide-to-integrating-ai-in-your-app-with-google-app-script?referral=integrate-invoice-parser-n8n), [Retool](https://www.edenai.co/post/a-step-by-step-guide-to-implementing-ai-in-your-app-using-retool?referral=integrate-invoice-parser-n8n), [Make](https://www.edenai.co/post/how-to-integrate-invoice-parsing-into-your-application-using-make?referral=integrate-invoice-parser-n8n), and [IFTTT.](https://www.edenai.co/post/a-step-by-step-guide-to-implementing-ai-in-your-app-using-ifttt?referral=integrate-invoice-parser-n8n)*



**[Create your Account on Eden AI](https://app.edenai.run/user/register?referral=integrate-invoice-parser-n8n)**