Hello friends, In this article, I am going to write about how to integrate Google Script and Interakt Track APIs. But before I start, Let’s take a look at what Interakt is and its usage.
Interakt and its Usage
Interakt is a whatsapp business API solution provider which is used by most of the businesses to automate messaging with their customers. We can say that Interakt is a whatsapp marketing tool that helps business owners to boost their sales. We can simply connect whatsapp business API and your e-commerce site that were created on shopify, woocommerce, etc...
Here are some usages of Interakt -
How to Connect Google Sheets to Interakt Track API
Interakt provides an API Key to create users and update events in its dashboard. By using Interakt API we can connect it to google sheets script and update users details in the interakt dashboard.
In this article, we learn about how to create users and update their details by Interakt Track API. There are two types of Interakt APIs are available :
-User Track API : To create a new user and add their traits ( users attribute ) in Interakt Dashboard.
-Event track API : To update users' events in the dashboard.
We use Interakt Track API documentation - https://www.interakt.shop/resource-center/api-doc to create our script in Google Script.
Steps to Integrate Google Sheets and Interakt
Step - 1: Creating Sheet and adding user details
First of all, we create a new google sheet and add user details in a row. (See Image)
Step - 2: Creating Project in GooleApps Script
Now go to Extensions > Apps Script, A new tab will open of google script untitled project. Save this project with the name Interakt Integration.
Step - 3: Get the Interakt API
To integrate with Google sheets and Interakt we need the API key from Interakt . To get the API key login to your Interakt dashboard and go to Setting > Developer Setting > Secret Key. Copy the Secret API Key.
Step - 4: Writing Google Script To Connect with Interakt
You should have a basic knowledge of google script to understand the script. Here is the script to send HTTP request to Interakt dashboard by its API. Replace YOUR_API_KEY with the your Interakt Secret API key.
function adduser() {var sheet = SpreadsheetApp.getActive().getActiveSheet()var userid = sheet.getRange(2, 1).getValue();var countrycode = sheet.getRange(2, 2).getValue();var phoneNumber = sheet.getRange(2, 3).getValue();var name = sheet.getRange(2, 4).getValue();var email = sheet.getRange(2, 5).getValue();var product_name = sheet.getRange(2, 6).getValue();var orderValue = sheet.getRange(2, 7).getValue();var header = {"Content-Type": "application/json","Authorization": "Basic YOUR_API_KEY"}var payload = JSON.stringify({"userid": userid,"phoneNumber": phoneNumber,"countryCode": countrycode,"traits": {"name": name,"email": email,"product_name": product_name,"order_value": orderValue}})var options = {"method" : "POST","headers" : header,"payload": payload,"muteHttpExceptions":true}response = UrlFetchApp.fetch('https://api.interakt.ai/v1/public/track/users/', options);Logger.log(response);json_response = JSON.parse(response)SpreadsheetApp.getActive().toast(response);}
Step - 5: Save and Run The Script
Now save your script. An adduser function will be created in Script. Click on Run to start the execution of the function. Google Script asks you to review the permissions. Give access to the script. After this function will run and your result will appear in Execution Log.
In this article, I have written a Google script for adding users and their traits in Interakt Dashboard. You can copy this script and create your own script for your application.
No comments:
Post a Comment