Let’s make JANDI message Translator Bot – Google API

Is there a way I can translate JANDI messages?
There were many requests among Toss Lab, Inc. members too.
Because our team is using various languages and located in various countries, in Korea, Taiwan, Malaysia, Dubai, and Japan, etc.

Let’s see how to make a JANDI message translator bot using Google Translation!

<Example of Korean-English / English-Korean
translation bot on JANDI team> 

JANDI messages using google translation

* Using Google Translate API

ㅣ Preparation

You need two values :  Incoming Webhook URL and  Outgoing Webhook URL. To make Outgoing Webhook URL easily, I will use a  Google Apps Script .

1. Make a JANDI connect – Incoming Webhook

1-1) Click [JANDI Connect] button at the upper right of the topic you want to connect the Google translation bot and add an Incoming Webhook Integration. 

1-2) Click the [Save Integration] button to complete JANDI connect webhook making.

  • Copy the Incoming Webhook URL by clicking the ‘Copy’ button.
  • Select a topic to connect a translator bot. If you need to create a new topic, click the ‘New Topic’ button.
  • Set the message profile image and name. I entered the Google Translation logo as a profile image.

 

2. Create a Google Apps Script

To make a translation bot you must create a Outgoing Webhook URL. This process is not easy. So I will use Google Apps Script to simplify the process.

2-1) Go to Apps Marketplace by clicking the ‘More from G Suite Marketplace’ in a Google Apps list.

 

2-2) Search and installGoogle Apps Script. Please click the buttons following the images below.

2-3) Write a script editor using Google Spreadsheet.

Go to Google Drive – Google Sheets – Create a blank spreadsheet.
Change the sheet title to Google Translation–  click ‘Script editor’ on the ‘Tools’ menu.

2-4) I rename the title of Google Apps Script to Google Translation GAS

Copy and paste the entire example code below into the default trans.gs file

※ Please change your ownIncoming Webhook URL in the ‘jandi_incoming_url’ value you copied in the 1-2) stage.

var jandi_incoming_url = "https://wh.jandi.com/connect-api/webhook/15401647/b8b8231e899b2b41934c354ae96504a0"; 
<trans.gs>
function doPost(e) {
    var jsonString = e.postData.getDataAsString();
    var jsonData = JSON.parse(jsonString);
    var requestString = jsonData.data;

    // text, source(korean), target(English)
    var translatedText = LanguageApp.translate(requestString, 'ko', 'en')  ;

    // jandi Setting JCC2000 - Google Translatorv2
    var jandi_incoming_url = "https://wh.jandi.com/connect-api/webhook/15401647/b8b8231e899b2b41934c354ae96504a0"; // edit1
    var jandi_headers = {
        "Accept": "application/vnd.tosslab.jandi-v2+json",
        "Content-type": "application/json",
    };
    var jandi_formData = {
        "body": translatedText
    };
    var jandi_options = {
        "method": "POST",
        "payload": JSON.stringify(jandi_formData),
        "headers": jandi_headers,
    };
    response = UrlFetchApp.fetch(jandi_incoming_url, jandi_options);
    Logger.log(response);
};

 

※ Since the original source text is set to ‘Korean’ and the translated result is set to ‘English’, example code was written in order of ‘ko’ and ‘en’. If you want to change source text language and translated language, please refer to the Language Code Value at this link. Just change the source and output language codes.

// text, source (Korean), target (English)  
var  translatedText  =  LanguageApp . translate ( requestString ,  ' ko ' ,  ' en ' )  ;

 

2-5) When the code setting is completed, please publish the script following the orders.

Click ‘Publish‘ menu – Deploy as a web app – After setting the access scope, click the ‘Deploy‘ button – Review the Authorization and log in your Google account – When the ‘Unverified app’ screen is displayed, go to ‘Advanced‘ – Click ‘Google Translate GAS (Unsafe)’ – Click the ‘Allow‘ button

When the deployment is done, your own Current web app URL is ready. This is the Outgoing Webhook URL for JANDI Connect.

3. Make a JANDI connect – Outgoing Webhook

3-1) Click [JANDI Connect] button at the upper right of the topic you want to connect the Google translation bot and add an Outgoing Webhook Integration. 

 

3-2) Click the [Save Integration]  button to complete the JANDI Connect Outgoing Webhook making.

  • In the webhook URL, enter the Outgoing Webhook URL created in step 2-5).
  • Enter a trigger word you want. ( ex. /trans /google, /en, etc. )

 

3-3) Finally, the JANDI message Google Translator bot is made on the topic!

 

‘JANDI Message Translation’ is the topic I connected  Incoming Webhook and Outgoing Webhook.

Now let’s translate JANDI messages. The original source text language is set to Korean. And the translated messages will be written in English. Trigger the message translation as in the example below. I set the trigger keyword to ‘/trans’.

/ trans < Messages I want to translate>

< Google Translator bot on JANDI> 

 

 

TADA! Did you complete to make the JANDI message translator bot successfully using Google Translation? The translation speed is very fast! I hope you can use it when you contact or work with overseas members.

 

Comments are closed, but trackbacks and pingbacks are open.

%d bloggers like this: