Send your knowhash Deck to Google Contacts, free
Everyone in your Deck appears in your Google Contacts, under a knowhash label, and on your phone. Changes follow by themselves every 15 minutes, and each Deck card can get an Open in Google Contacts button.
Even if you use Outlook or another CRM, it's worth doing for the photos alone: Deck shows each person's Google photo instead of their initials.
This is the simplest connection there is. It's a short script that lives inside your own knowhash sheet, using your own Google account:
- Nothing in between. No automation service, no extra sign-ups, and nothing passes through knowhash.
- On your phone by itself. Android shows Google Contacts straight away; on iPhone it's one setting.
- Your own edits are kept. Emails, phone numbers and links you add in Google Contacts are never removed.
- Photos on your Deck cards for anyone with a photo on their Google account.
- Free, with no monthly limit that a Deck is likely to reach.
You'll need knowhash with Deck set up and a few contacts in it. New to Deck? Open any LinkedIn profile, click Deck in the knowhash panel, then Set up Deck.
Step 1: Open Apps Script from your knowhash sheet
- Open your knowhash sheet. In Deck, click open in Google Sheets at the bottom of the contact list.
- In the sheet's menu, click Extensions → Apps Script. A script editor opens in a new tab, linked to this sheet.
- Click Untitled project at the top and rename it Deck → Google Contacts.
Step 2: Turn on Google Contacts access
- In the left column of the script editor, click + next to Services.
- Choose People API and click Add. It appears under Services as People.
Nothing happens when you click +? This can happen if you're signed in to more than one Google account. Add the service by hand instead: click Project Settings (the gear) on the left, tick Show "appsscript.json" manifest file in editor, go back to the editor, open appsscript.json, replace its contents with the block below, and save. People then appears under Services.
{
"timeZone": "Australia/Melbourne",
"dependencies": {
"enabledAdvancedServices": [
{ "userSymbol": "People", "version": "v1", "serviceId": "peopleapi" }
]
},
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8"
}
Change the time zone to yours if you like; it doesn't affect the sync.
Step 3: Paste the script
- Click Code.gs on the left, select everything in it and delete it.
- Click Copy the script below, paste it into Code.gs, and click the save icon.
/**
* knowhash Deck -> Google Contacts
* Version 2026-11-30: adds an Open in Google Contacts button to your Deck cards for you.
*
* Copies the people in your knowhash Deck into your own Google Contacts, under the label "knowhash",
* so they also appear on your phone. Runs inside your own Google Sheet: nothing passes through knowhash
* or any other service.
*
* Setup (once): Services + People API, paste this script, choose "setup" and click Run.
* After that it runs by itself every 15 minutes and only sends people whose details changed.
*
* It adds four columns at the far right of your Contacts tab:
* gc_id the Google Contacts ID (or "deleted" if you deleted the contact in Google Contacts)
* gc_link a direct link to the contact, for an "Open in Google Contacts" Deck button: {gc_link}
* gc_synced the kh_updated_at value last sent, so unchanged people are skipped
* gc_photo_url the person's own Google profile photo, if they have one ("none" if not).
* Deck shows it on their card instead of their initials.
*
* Guide: https://knowhash.com/how-to/deck-google-contacts/
*/
/** @OnlyCurrentDoc */
// The line above asks Google for access to this one spreadsheet only, not all your sheets.
const GC_SCRIPT_VERSION = '2026-11-30'; // compare with the guide page to see if a newer copy is there
const TAB = 'Contacts'; // the tab knowhash writes your Deck to
const LABEL = 'knowhash'; // the Google Contacts label your Deck contacts get
const EVERY_MINUTES = 15; // how often to check for changes (1, 5, 10, 15 or 30)
const ID_COL = 'gc_id', LINK_COL = 'gc_link', DONE_COL = 'gc_synced', PHOTO_COL = 'gc_photo_url';
const PHOTO_CHECKS_PER_RUN = 20; // photo look-ups per run, for people already sent
const FIELDS = 'names,emailAddresses,phoneNumbers,organizations,urls';
/** Run this once. It starts the 15-minute timer and does a first sync straight away. */
function setup() {
ScriptApp.getProjectTriggers()
.filter((t) => t.getHandlerFunction() === 'syncContacts')
.forEach((t) => ScriptApp.deleteTrigger(t));
ScriptApp.newTrigger('syncContacts').timeBased().everyMinutes(EVERY_MINUTES).create();
syncContacts();
}
/** Sends new and changed Deck contacts to Google Contacts. */
function syncContacts() {
const sheet = SpreadsheetApp.getActive().getSheetByName(TAB);
if (!sheet) throw new Error('No tab called "' + TAB + '" in this spreadsheet.');
// Find columns by their header name, and add ours at the far right if they're missing.
const head = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues()[0].map((h) => String(h).trim());
[ID_COL, LINK_COL, DONE_COL, PHOTO_COL].forEach((h) => {
if (head.indexOf(h) >= 0) return;
if (sheet.getMaxColumns() < head.length + 1) sheet.insertColumnsAfter(sheet.getMaxColumns(), 1);
sheet.getRange(1, head.length + 1).setValue(h);
head.push(h);
});
const col = {};
head.forEach((h, i) => { if (h && col[h] == null) col[h] = i; });
addContactsButton_();
const last = sheet.getLastRow();
if (last < 2) return;
const rows = sheet.getRange(2, 1, last - 1, head.length).getDisplayValues();
const label = labelName_();
const started = Date.now();
for (let i = 0; i < rows.length; i++) {
if (Date.now() - started > 5 * 60 * 1000) break; // Apps Script stops at 6 minutes: the rest go on the next run.
const r = rows[i];
const v = (k) => (col[k] == null ? '' : String(r[col[k]] || '').trim());
const rowNo = i + 2;
if (v('kh_removed').toUpperCase() === 'TRUE') continue; // removed from Deck: leave Google Contacts alone
if (!v('kh_name') && !v('kh_email')) continue;
if (v(ID_COL) === 'deleted') continue; // you deleted it in Google Contacts: respect that
const stamp = v('kh_updated_at') || v('kh_added_at');
if (v(ID_COL) && stamp && stamp === v(DONE_COL)) continue; // unchanged since the last sync
const mine = {
names: [{ givenName: v('kh_first_name') || v('kh_name'), familyName: v('kh_first_name') ? v('kh_last_name') : '' }],
emailAddresses: [v('kh_email'), v('kh_other_email')].filter(Boolean).map((e, n) => ({ value: e, type: n ? 'other' : 'work' })),
phoneNumbers: v('kh_phone') ? [{ value: v('kh_phone'), type: 'mobile' }] : [],
organizations: v('kh_company') || v('kh_headline') ? [{ name: v('kh_company'), title: v('kh_headline') }] : [],
urls: [
v('kh_profile_url') ? { value: v('kh_profile_url'), type: 'LinkedIn' } : null,
deckUrl_(v) ? { value: deckUrl_(v), type: 'knowhash Deck' } : null,
].filter(Boolean),
};
try {
let id = v(ID_COL);
if (id) {
let cur = null;
try {
cur = People.People.get(id, { personFields: FIELDS });
} catch (e) {
if (/not ?found|404/i.test(String(e))) { sheet.getRange(rowNo, col[ID_COL] + 1).setValue('deleted'); continue; }
throw e;
}
// Names, company and title follow your Deck. Emails, phones and links are added, never removed,
// so anything you added yourself in Google Contacts stays.
People.People.updateContact({
etag: cur.etag,
names: mine.names,
organizations: mine.organizations.length ? mine.organizations : cur.organizations || [],
emailAddresses: merge_(cur.emailAddresses, mine.emailAddresses),
phoneNumbers: merge_(cur.phoneNumbers, mine.phoneNumbers),
urls: merge_(cur.urls, mine.urls),
}, id, { updatePersonFields: FIELDS });
// Their details changed, so look their photo up again on a later run.
if (col[PHOTO_COL] != null && v(PHOTO_COL)) sheet.getRange(rowNo, col[PHOTO_COL] + 1).setValue('');
} else {
mine.memberships = [{ contactGroupMembership: { contactGroupResourceName: label } }];
id = People.People.createContact(mine).resourceName; // e.g. people/c1234567890
sheet.getRange(rowNo, col[ID_COL] + 1).setValue(id);
sheet.getRange(rowNo, col[LINK_COL] + 1).setValue('https://contacts.google.com/person/' + id.replace('people/', ''));
}
sheet.getRange(rowNo, col[DONE_COL] + 1).setValue("'" + stamp); // stored as text, so it compares exactly
Utilities.sleep(800); // stay inside Google's limit on contact changes per minute
} catch (e) {
console.warn('Row ' + rowNo + ' (' + v('kh_name') + '): ' + e); // shows under Executions; tried again next run
}
}
// Photos: Google links a contact to the person's own Google profile shortly after it's created,
// so look up a few people each run who've been sent but have no photo checked yet.
let checks = 0;
for (let i = 0; i < rows.length && checks < PHOTO_CHECKS_PER_RUN; i++) {
if (Date.now() - started > 5.5 * 60 * 1000) break;
const id = String(rows[i][col[ID_COL]] || '').trim();
if (!/^people\//.test(id) || String(rows[i][col[PHOTO_COL]] || '').trim()) continue;
checks++;
try {
const p = People.People.get(id, { personFields: 'photos' });
const real = (p.photos || []).find((x) => !x.default && x.url);
sheet.getRange(i + 2, col[PHOTO_COL] + 1).setValue(real ? real.url : 'none');
} catch (e) {
console.warn('Photo for row ' + (i + 2) + ': ' + e);
}
}
}
/** Adds an "Open in Google Contacts" button to your Deck cards, once: a row in your sheet's Actions tab.
* Rename it or delete it as you like; the script won't put it back. */
function addContactsButton_() {
const props = PropertiesService.getScriptProperties();
if (props.getProperty('GC_BUTTON')) return;
try {
const ss = SpreadsheetApp.getActive();
let tab = ss.getSheetByName('Actions');
if (!tab) {
tab = ss.insertSheet('Actions');
tab.getRange(1, 1, 1, 3).setValues([['kh_label', 'kh_url', 'kh_notes']]).setFontWeight('bold');
}
const vals = tab.getDataRange().getValues();
const head = vals[0].map((h) => String(h).trim().toLowerCase());
const L = head.indexOf('kh_label'), U = head.indexOf('kh_url'), N = head.indexOf('kh_notes');
if (L < 0 || U < 0) { props.setProperty('GC_BUTTON', 'skipped'); return; } // tab changed by hand: leave it alone
if (!vals.slice(1).some((r) => /\{gc_link\}/i.test(String(r[U])))) {
const row = head.map(() => '');
row[L] = 'Open in Google Contacts';
row[U] = '{gc_link}';
if (N >= 0) row[N] = 'Added by the knowhash Google Contacts script. Rename or delete it as you like.';
tab.appendRow(row);
}
props.setProperty('GC_BUTTON', 'yes');
} catch (e) {
console.warn('Could not add the Open in Google Contacts button: ' + e); // tried again next run
}
}
/** A link to this person's card in your Deck: knowhash's kh_deck_url column, or built the same way. */
function deckUrl_(v) {
if (v('kh_deck_url')) return v('kh_deck_url');
const m = v('kh_profile_url').match(/linkedin\.com\/in\/([^/?#]+)/i);
if (!m) return '';
let key = m[1];
try { key = decodeURIComponent(key); } catch (e) {}
return 'https://knowhash.com/deck/?s=' + encodeURIComponent(SpreadsheetApp.getActive().getId()) + '#c=' + encodeURIComponent(key.toLowerCase());
}
/** Keeps what's there and adds anything new (ignoring case and spaces). */
function merge_(have, add) {
const out = (have || []).map((x) => ({ value: x.value, type: x.type }));
const key = (x) => String(x.value || '').toLowerCase().replace(/\s+/g, '');
const seen = new Set(out.map(key));
add.forEach((x) => { if (!seen.has(key(x))) { out.push(x); seen.add(key(x)); } });
return out;
}
/** Finds the "knowhash" label in Google Contacts, or creates it. */
function labelName_() {
const groups = People.ContactGroups.list({ pageSize: 1000 }).contactGroups || [];
const found = groups.find((g) => g.name === LABEL);
return found ? found.resourceName : People.ContactGroups.create({ contactGroup: { name: LABEL } }).resourceName;
}
Script version 2026-11-30. It's also on the second line of the script, so you can check which copy you have.
Also available as a file: Code.js. It's short, and every part is explained in its comments.
Step 4: Run it once
- In the bar above the code, choose setup in the function list, then click Run.
- Google asks for permission. Click Review permissions and choose your Google account.
- Google shows Google hasn't verified this app. Click Advanced, then Go to your project’s name (unsafe), then tick Select all and click Continue. The script needs all three: your contacts, this sheet, and running every 15 minutes while you’re away.
Look at the developer's name: it's your own email address. Click Advanced.
Tick Select all, then Continue. The sheet permission covers this one spreadsheet only.
Why the warning? Google shows it for every script a person writes or pastes for themselves, and it names you as the developer, because you are: the script lives in your own sheet. The script is yours, runs only in your account, and only you can see it. It asks for your contacts and for this one spreadsheet, nothing else in your Drive, which is exactly what it uses: you can read every line above.
The first sync starts straight away. The Execution log at the bottom shows Execution completed when it's done.
Step 5: Check your contacts
- Open contacts.google.com. Your Deck contacts are under the knowhash label on the left.
- Back in your sheet, four new columns have appeared at the far right of the Contacts tab:
gc_id,gc_link,gc_syncedandgc_photo_url. The script uses them to keep track. Leave them where they are.
Your Deck contacts under the knowhash label.
The script's columns, at the far right of your sheet. gc_photo_url fills in on the next run.
Step 6: Your Open in Google Contacts button
There's nothing to add: the script puts an Open in Google Contacts row in your sheet's Actions tab for you (and makes the tab if you don't have one). Back in Deck, tap Refresh, and each contact gets a button that goes straight to them in Google Contacts.
Rename or delete the row in the Actions tab as you like; the script won't put it back.


Bonus: photos on your Deck cards
Many people have a photo on their own Google account. Once someone is in your Google Contacts, Google links them to that photo, and the script copies its address into gc_photo_url. Deck then shows their photo instead of their initials. There's nothing to set up: photos appear within about 15 minutes of someone being sent, after you tap Refresh. People without a Google photo show none and keep their initials.
Photos for people who have one on their Google account; initials for everyone else.
Use Outlook or another CRM? You can still do this, just for the photos. Your Deck already lives in your Google account, so setting this up gives your Deck cards faces whatever else you use. Your contacts simply sit in a knowhash label in Google Contacts as well.
On your phone
- Android: nothing to do. Your Google contacts are already on your phone.
- iPhone: open Settings → Apps → Contacts → Contacts Accounts, tap your Google account and turn on Contacts.
That's it
Add or edit someone in Deck, and within 15 minutes they're in Google Contacts with their name, email, phone, company, headline and LinkedIn link, plus a knowhash Deck link back to their Deck card.
What it does and doesn't do. Name, company and headline follow your Deck. Emails, phone numbers and links are added, never removed, so your own additions in Google Contacts stay. Removing someone from Deck doesn't delete them from Google Contacts. If you delete a contact in Google Contacts, the script leaves them deleted and writes deleted in gc_id; clear that cell to bring them back.
If something doesn't work
- "ReferenceError: People is not defined": step 2 was missed. Add the People API service, then run setup again.
- No knowhash label in Google Contacts: check the Execution log for errors, then run setup again.
- A contact didn't update: in the script editor, click Executions on the left. Each run lists any row it couldn't send, and tries it again next run.
- Changed someone's email in Deck? The new one is added in Google Contacts, but the old one stays there too, because the script never removes anything. Delete the old one in Google Contacts if it's wrong.
- Stop syncing: in the script editor, click Triggers (the clock) on the left and delete the syncContacts trigger. Your contacts stay as they are.
- No Open in Google Contacts button, or it's greyed out: that contact hasn't been sent yet, or Deck is showing what it loaded earlier. Tap Refresh.
Improve this guide. Did a screen look different, a step trip you up, or would you like it to do more? Tell us, and we'll update the guide for everyone who uses it next.
Would rather we set this up for you? Email Mike. Questions? support@knowhash.com · All connection guides