Manage Google Contacts from Telegram using OpenAI GPT-4o-mini

Go to Workflow
0 views
Built by May Zhan May Zhan
Created on August 11, 2026

Description

Quick overview
This workflow listens for Telegram bot messages (text or photos), uses OpenAI to extract and classify contact requests, and then looks up, creates, or updates entries in Google Contacts before replying with a confirmation message in Telegram.

How it works
Triggers when your Telegram bot receives a new message and captures the chat ID, text/caption, and any attached photo.
If a photo is included, it downloads the image and sends it to OpenAI Vision to extract contact details and the intended action as a JSON array.
If the message is text-only, it sends the text to OpenAI to classify whether it’s a contact request and to extract contact fields as a JSON array.
Loops through each extracted contact item, skipping non-contact chatter and routing parsing failures to an error reply in Telegram.
Searches Google Contacts (People API) for an existing match using email first, then name, then phone.
For lookup requests, formats the top matching Google Contacts results and sends them back to Telegram.
For create or update requests, creates a new Google Contact or merges updates into the first match, then sends a success confirmation to Telegram.

Setup
Create a Telegram bot with @BotFather and add your Telegram bot token as a Telegram credential in n8n.
Add an OpenAI API credential (used to call the Chat Completions endpoint for both text and vision extraction).
Add a Google Contacts OAuth2 credential with the scope https://www.googleapis.com/auth/contacts so the workflow can search, create, and update contacts.
Remove/disable pinned sample data on the Telegram trigger and the OpenAI HTTP request nodes before activating.
Ensure no other active workflow uses the same Telegram bot webhook, since Telegram supports only one webhook per bot token.

Nodes Used (3)

Code
n8n-nodes-base.code
HTTP Request
n8n-nodes-base.httpRequest
Telegram
n8n-nodes-base.telegram