Overview
The Google Sheets integration allows you to:- Import contacts directly from Google Sheets
- Export campaign results back to sheets
- Sync contact data bidirectionally
- Map spreadsheet columns to contact fields
- Update call status in real-time
Prerequisites
- A Google account with access to Google Sheets
- Google Cloud Platform project with Sheets API enabled
- OAuth 2.0 credentials configured
Setup Instructions
Create Google Cloud Project
- Go to Google Cloud Console
- Click Create Project or select an existing project
- Give your project a name (e.g., “TelemanAI Integration”)
- Click Create
Enable Google Sheets API
- In the Cloud Console, go to APIs & Services → Library
- Search for “Google Sheets API”
- Click on it and press Enable
- Also enable “Google Drive API” for listing spreadsheets
Create OAuth 2.0 Credentials
- Go to APIs & Services → Credentials
- Click Create Credentials → OAuth client ID
- If prompted, configure the OAuth consent screen:
- Choose External user type
- Fill in app name, support email, and developer contact
- Add scopes:
https://www.googleapis.com/auth/spreadsheetsandhttps://www.googleapis.com/auth/drive.readonly
- For Application type, select Web application
- Add authorized redirect URI:
- Click Create
- Copy the Client ID and Client Secret
Configure Environment Variables
Add the credentials to your
.env file:The
GOOGLE_REDIRECT_URI must match exactly what you configured in Google Cloud Console.Importing Contacts from Google Sheets
Select a Spreadsheet
After connecting your Google account:
- Click Select Spreadsheet
- Choose the spreadsheet containing your contacts
- Select the specific sheet/tab within the spreadsheet
Map Columns to Fields
Map your spreadsheet columns to TelemanAI contact fields:
- Name: Contact’s full name
- Phone: Phone number (required for calling)
- Email: Email address (optional)
- Custom Fields: Any additional data columns
The first row of your spreadsheet should contain column headers.
Exporting Campaign Data
TelemanAI can write campaign results back to your Google Sheets:Enable Status Column
TelemanAI automatically creates a “Status” column in your sheet if it doesn’t exist. This column will be updated with:
- Called: Contact was successfully called
- Completed: Call completed successfully
- Failed: Call attempt failed
- No Answer: Contact didn’t answer
- Busy: Line was busy
Configure Campaign for Export
When creating a campaign:
- Enable Update Google Sheets
- Select the spreadsheet and sheet
- Choose the status column to update
Sheet Format Requirements
For best results, format your Google Sheets as follows:- Phone numbers should be in E.164 format (e.g., +1234567890)
- The first row must contain headers
- Avoid empty rows between data
- Status column can be anywhere; TelemanAI will find or create it
Advanced Features
Column Header Detection
TelemanAI automatically detects column headers from the first row:Bidirectional Sync
Update cell values programmatically:Automatic Status Column Creation
TelemanAI can automatically append a status column if it doesn’t exist:API Endpoints
Key endpoints for Google Sheets integration:| Endpoint | Method | Description |
|---|---|---|
/google/connect | GET | Initiate OAuth flow |
/google/callback | GET | OAuth callback handler |
/google/disconnect | POST | Disconnect Google Sheets |
/google/spreadsheets | GET | List all spreadsheets |
/google/spreadsheet/select | POST | Select a spreadsheet |
/google/sheet/data | GET | Get all sheet data |
/google/column-headers | GET | Get column headers |
/google/update-cell | POST | Update a cell value |
GoogleSheetController.php (lines 24-260) for implementation details.
Troubleshooting
Authentication Failed
Authentication Failed
Problem: “Google API token not found in session”Solution:
- Ensure you’ve completed the OAuth flow
- Check that
GOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRETare correct - Clear your session and reconnect:
Permission Denied
Permission Denied
Problem: “Insufficient permissions to access spreadsheet”Solution:
- Verify the Google Sheets API is enabled in your GCP project
- Check OAuth scopes include:
https://www.googleapis.com/auth/spreadsheetshttps://www.googleapis.com/auth/drive.readonly
- Re-authorize with the “consent” prompt to grant new permissions
Token Expired
Token Expired
Problem: “Could not refresh the Google access token”Solution:
- The refresh token is automatically handled by TelemanAI
- If issues persist, disconnect and reconnect Google Sheets
- Ensure
setAccessType('offline')is configured for refresh token
Column Headers Not Found
Column Headers Not Found
Problem: “Could not retrieve column headers”Solution:
- Ensure the first row of your sheet contains headers
- Check that the sheet is not empty
- Verify the sheet name is spelled correctly (case-sensitive)
- Sheet names with spaces are automatically handled with quotes
Import Fails with Validation Error
Import Fails with Validation Error
Problem: Contacts fail to importSolution:
- Verify phone numbers are in valid format
- Check for empty rows or cells in required columns
- Ensure no duplicate phone numbers exist
- Review Laravel logs for specific validation errors
Security Best Practices
Token Refresh Mechanism
TelemanAI automatically refreshes expired tokens:GoogleSheetsService.php (line 39-48) for the implementation.
Next Steps
Import Contacts
Learn more about importing contacts
Create Campaign
Use your imported contacts in a campaign
Export Results
Export campaign results to sheets
API Reference
Full API documentation