Get in touch
or send us a question?
CONTACT

Using IFTTT with google home to call responsible person

This document is tutorial using IFTTT for customer to call responsible person in some small-medium company.

Scenario:

 When customers come, in normal case, they will talk to receptionist, and receptionist will call for responsible person.
In some company, they havetoring bell to call someone for talk, then call for responsible persion.
With this tutorial, customers now can talk to our Google Home, then responsible person will get ChatWork message.

Pros:
No need for someone always at the door.
Customers have not to wait for calling.

Cons:
Fix language, all customers will use same language.
If company has people from many country, customers will have problem with pronounce name.
Because noone is at the door, so we will have problem with thieves, call for joke people. We have to lock or chains the device (Google Home)

Preparing:
Goolge Home (can use any device with Google Assistant support but Google Home is the easiest device to use)
Google account.
Chatwork account.

Implement:
Part 1: IFTTT website implement

Step 1:
Go to website: https://ifttt.com, then sign in.

Step 2: Click on your username, select “New Applet”
Screen Shot 2018-06-04 at 11.50.09 AM

Step 3: Click on “this”
Screen Shot 2018-06-04 at 11.51.10 AM

Step 4: Click on “Google Assistant”
Screen Shot 2018-06-04 at 11.51.31 AM

Step 5: Input your Google Assistant account (recomment same account with IFTTT account)

Step 6: Select “Say a phrase with a text ingredient”
Screen Shot 2018-06-04 at 11.53.24 AM

Step 7: Type format of sentence for customer to say with $ is the variable, type response sentence of Google Assistant, with right language, then click “Create trigger”
In this case, I will let customer to say: “I want to meet …”, Google Assistant will response: “I have made contact for your, please wait a moment” with English
Screen Shot 2018-06-04 at 11.59.41 AM

Step 8: Click “That”
Screen Shot 2018-06-04 at 1.42.41 PM

Step 9: Click on “Google Sheets”

Screen Shot 2018-06-04 at 1.43.24 PM

Step 10: Input your Google Sheetsaccount (recomment same account with IFTTT account)

Step 11: Select “Update cell in spreadsheet”
Screen Shot 2018-06-04 at 1.49.10 PM

Step 12:Input file location and Spreadsheet name, update cell, then click “Create action”
In this case I choose default Folder (IFTTT), Spreadsheet name is “Call Chatwork”, Cell A1
Screen Shot 2018-06-04 at 1.55.40 PM

Step 13: Click “Finish”

Part 2: Google sheets and Google app script implement.

Step 1: Open your created google sheet from https://drive.google.com

Step 2: Format like me or whatever you want, just to store name or section and chatwork room id.
Screen Shot 2018-06-04 at 2.53.17 PM

You can find Chatwork roomId in address like this
Screen Shot 2018-06-04 at 2.50.44 PM

Step 3: Enable chatwork api and get api key
In chat work, click your avatar and select API Setting
Screen Shot 2018-06-04 at 4.45.23 PM
Enter your password and store key for using later.
Screen Shot 2018-06-04 at 4.45.56 PM

Step 4: Select Tools -> Script editor
Screen Shot 2018-06-04 at 2.45.53 PM

Step 5: In script editor type as below

var roomId ='72xxxxx'  // Default room id using when no matching
var token ='2c99xxxxxxxxxxxxxxxxxxxxxxxx' // your token get at step 3

function callChatwork(body){
  var mySheet = SpreadsheetApp.getActiveSheet();  // current sheet
  var myCell = mySheet.getActiveCell();    // current cell
  if (myCell.getRow() == 1 || myCell.getColumn() == 1) // Only check if edit cell is A1
  {
    var text = myCell.getValue().toString().toLowerCase();
    var isSent = false;
    if (text != "") // Only check if A1 cell has value
    {
      var client = ChatWorkClient.factory({token: token});
      for (var row = 4; row <= 8; row++)  // 4, 8: start and end of record 
      {
        var cellValue = mySheet.getRange(row, 2).getValue().toString(); 
        if (text.indexOf(cellValue.toLowerCase())>-1) // compare contain because customer can add something like Mr/Mrs, please...
        {
          var roomId2 = mySheet.getRange(row, 3).getValue()
          client.sendMessage(
          {
            room_id: roomId2,
            body: cellValue + ", someone is waiting for you at the door"
          }
          );
          isSent = true;
          break;
        }
      }
      if (!isSent)
      {
        client.sendMessage(
        {
          room_id: roomId,
          body: "Someone is trying to call " + text + " at the door"
        }
        );
      }
    }
  }
}

Step 6: Add trigger to active this script by Edit -> Current project’s trigger, then add as below
Screen Shot 2018-06-04 at 5.26.50 PM

Step 7: Add library by Source -> Library…, type as below for adding ChatworkClient api

M6TcEyniCs1xb3sdXFF_FhI-MNonZQ_sT

Screen Shot 2018-06-04 at 5.35.28 PM

Screen Shot 2018-06-04 at 5.35.51 PM

That it’s, now you can using google home to contact as video below (^-^)
https://drive.google.com/file/d/1xKYL6oOdNbwMarASMmJqLKAuOlg-uOcu/view?usp=sharing