Automate Your Signup Form And Connect Google Sheet, Slack, And Sendgrid APIs

Ravi Paliwal
Socket Basics and its Use-Cases
2 min readOct 12, 2022

--

Here is the video where we have published the tutorial to connect any third-party or internal APPs using API, JavaScript and If-condition with the help of Viasocket.com

  1. We have used Google sheet API to create new rows with the help of Google sheet API. This API creates a new row entry every time you will run the API.

POST URL https://sheets.googleapis.com/v4/spreadsheets/$spredsheeetID:batchUpdate

Body: Json

{
“requests”: [
{ “appendCells”: {
“sheetId”: $GID,
“rows”: [{“values”: [
{ “userEnteredValue”: { “stringValue”: “$Value1” }},
{ “userEnteredValue”: { “stringValue”: “$Value2” }},
{ “userEnteredValue”: { “stringValue”: “$Value3” }},
{ “userEnteredValue”: { “stringValue”: “$Value4” }},
{ “userEnteredValue”: { “stringValue”: “$Value5” }},
{ “userEnteredValue”: { “stringValue”: “$Value6” }},
{ “userEnteredValue”: { “stringValue”: “$Value7”}}
]}],
“fields”: “*”
}}]}

In the above google sheet API, All the bold characters are the value that you need to mention to use the API ie $spredsheeetID, $Value1, $GID, and of course you need google authentication which is already available in the Viasocket.

And if you want to create more column values, you need to add the following line in the code for the number of entries you want to extend.

{ “userEnteredValue”: { “stringValue”: “$Value8”}}

Get SheetID and SpreadsheetID from Google Sheet URL

2. Next we used SendGrid API to send mail from viascoket.

Post https://api.sendgrid.com/v3/mail/send

Body: Json

{
“personalizations”: [{
“to”: [{
“email”: “$recipient_email”,
“name”: “$recipient_name”
}]}],
“from”: {
“email”: “$sender_email”,
“name”: “$sender_name”
},
“subject”: “$email_subject”,
“content”: [{
“type”: “text/html”,
“value”: “$email_body”
}]}

Authentication in the header. (You will get from SendGrid account >>Setting >> API KEY) or check this blog for help

Authorization: Bearer $SENDGRID_API_KEY

3. We have use a javascript code that have convert email id and return the domain of that mail id.

var email = $email;
var name = email.substring(0, email.lastIndexOf(“@”));
var domain = email.substring(email.lastIndexOf(“@”) +1);
domain = domain.toLowerCase();
if (domain.match(/(gmail|yahoo|ymail|rediff|outlook|live|hotmail|zoho|mail.com|icloud|gmx.com)/g)) {
domain = “emailprovider”;
}
return domain;

This code will return the value in the domain parameter.

4. We have used Slack API to send a notification message.

Post URL:

You need to generate an incoming webhook URL from Slack, use this link for help

Body: JSon

{
“channel”: “#socketwall”,
“username”: “UserTable”,
“icon_emoji”: “:smile:”,
“text”: “UserTable wala client hai. $email_1”
}

Similar to these APIs you can connect your own internal API or any other API to automate your sign-up data.

If you face any difficulties in adding API or writing code. please ping us on rpaliwal@viasocket.com

--

--

Tweet me Hello “rpaliwal71”. I am Tech entrepreneur building team productivity suite, 14 Years in SaaS, previously build msg91 and viasocket.com