Google Microsoft Integrations
Learn about google microsoft integrations and how to implement it effectively.
Google & Microsoft Services Integration
Forjinn provides comprehensive integrations with Google and Microsoft services, enabling AI agents to interact with productivity tools, communication platforms, and cloud services.
Google Services Integration
Google Search API
Overview
Real-time web search capabilities using Google Custom Search API.
Features
- Real-time search results
- Custom search engine support
- Advanced search parameters
- Rate limiting and quota management
Configuration
{
label: 'Google Custom Search',
name: 'googleCustomSearch',
description: 'Access Google search results in real-time',
credentials: {
googleCustomSearchApiKey: 'your-api-key',
googleCustomSearchApiId: 'your-search-engine-id'
}
}
Usage Example
// Search for information
const searchResults = await googleSearch.invoke({
query: "latest AI developments 2024",
num: 10,
start: 1
});
Gmail Integration
Overview
Complete email management through Gmail API with OAuth2 authentication.
Available Operations
Draft Operations
listDrafts- List all drafts with paginationcreateDraft- Create new email draftgetDraft- Retrieve specific draftupdateDraft- Modify draft contentsendDraft- Send draft as emaildeleteDraft- Delete draft permanently
Message Operations
listMessages- List messages with advanced filteringgetMessage- Get specific message with full contentsendMessage- Send new email messagemodifyMessage- Add/remove labels from messagestrashMessage- Move message to trashuntrashMessage- Restore message from trashdeleteMessage- Permanently delete message
Label Operations
listLabels- List all available labelsgetLabel- Get specific label detailscreateLabel- Create new custom labelupdateLabel- Update label propertiesdeleteLabel- Delete custom label
Thread Operations
listThreads- List email conversation threadsgetThread- Get complete thread with all messagesmodifyThread- Apply labels to entire threadtrashThread- Move thread to trashuntrashThread- Restore thread from trashdeleteThread- Permanently delete thread
Configuration Example
const gmailTools = createGmailTools({
actions: ['listMessages', 'sendMessage', 'createDraft'],
accessToken: oauthToken,
defaultParams: {
messageMaxResults: 50,
messageQuery: 'is:unread',
messageTo: 'user@example.com',
messageSubject: 'Automated Email',
messageBody: 'This is an automated message from Forjinn'
}
});
Advanced Features
// Send email with attachments and formatting
await sendMessage({
to: 'recipient@example.com',
cc: 'cc@example.com',
bcc: 'bcc@example.com',
subject: 'Project Update',
body: `
<html>
<body>
<h2>Project Status Update</h2>
<p>The project is progressing well...</p>
</body>
</html>
`,
attachments: ['report.pdf', 'data.xlsx']
});
// Advanced message filtering
await listMessages({
query: 'from:client@company.com has:attachment is:unread',
maxResults: 25,
labelIds: ['INBOX', 'IMPORTANT']
});
Google Sheets Integration
Overview
Comprehensive spreadsheet operations with batch processing capabilities.
Available Operations
Spreadsheet Operations
createSpreadsheet- Create new spreadsheetgetSpreadsheet- Get spreadsheet metadata and structureupdateSpreadsheet- Update spreadsheet properties
Values Operations
getValues- Read cell values from rangesupdateValues- Write values to specific rangesappendValues- Append new rows to sheetsclearValues- Clear content from rangesbatchGetValues- Read multiple ranges efficientlybatchUpdateValues- Update multiple ranges in one requestbatchClearValues- Clear multiple ranges simultaneously
Configuration Example
const sheetsTools = createGoogleSheetsTools({
accessToken: oauthToken,
actions: ['getValues', 'updateValues', 'appendValues'],
defaultParams: {
spreadsheetId: '1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms',
range: 'Sheet1!A1:C10',
valueInputOption: 'USER_ENTERED',
valueRenderOption: 'FORMATTED_VALUE'
}
});
Advanced Usage
// Batch operations for efficiency
await batchUpdateValues({
spreadsheetId: 'your-sheet-id',
valueInputOption: 'USER_ENTERED',
data: [
{
range: 'Sheet1!A1:B2',
values: [['Name', 'Age'], ['John', 30]]
},
{
range: 'Sheet1!D1:E2',
values: [['City', 'Country'], ['NYC', 'USA']]
}
]
});
// Formula and formatting support
await updateValues({
range: 'Sheet1!C1',
values: [['=SUM(A1:B1)']],
valueInputOption: 'USER_ENTERED'
});
Microsoft Services Integration
Microsoft Outlook Integration
Overview
Complete calendar and email management through Microsoft Graph API.
Available Operations
Calendar Operations
listCalendars- List all accessible calendarsgetCalendar- Get specific calendar detailscreateCalendar- Create new calendarupdateCalendar- Update calendar propertiesdeleteCalendar- Delete calendar
Event Operations
listEvents- List calendar events with filteringgetEvent- Get specific event detailscreateEvent- Create new calendar eventupdateEvent- Update event detailsdeleteEvent- Delete calendar event
Message Operations
listMessages- List email messagesgetMessage- Get specific messagecreateDraftMessage- Create draft messagesendMessage- Send email messageupdateMessage- Update message propertiesdeleteMessage- Delete messagecopyMessage- Copy message to foldermoveMessage- Move message to folderreplyMessage- Reply to messageforwardMessage- Forward message
Configuration Example
const outlookTools = createOutlookTools({
accessToken: microsoftToken,
actions: ['listEvents', 'createEvent', 'sendMessage'],
defaultParams: {
maxResultsListEvents: 50,
subjectCreateEvent: 'Team Meeting',
startDateTimeCreateEvent: '2024-01-15T10:00:00',
endDateTimeCreateEvent: '2024-01-15T11:00:00',
locationCreateEvent: 'Conference Room A',
attendeesCreateEvent: 'team@company.com,manager@company.com'
}
});
Advanced Event Management
// Create recurring meeting
await createEvent({
subject: 'Weekly Standup',
body: 'Weekly team standup meeting',
start: {
dateTime: '2024-01-15T09:00:00',
timeZone: 'UTC'
},
end: {
dateTime: '2024-01-15T09:30:00',
timeZone: 'UTC'
},
recurrence: {
pattern: {
type: 'weekly',
interval: 1,
daysOfWeek: ['monday']
},
range: {
type: 'endDate',
endDate: '2024-12-31'
}
},
attendees: [
{
emailAddress: {
address: 'team@company.com',
name: 'Team Members'
},
type: 'required'
}
]
});
Microsoft Teams Integration
Overview
Comprehensive Teams automation for channels, chats, and messaging.
Available Operations
Channel Operations
listChannels- List team channelsgetChannel- Get specific channelcreateChannel- Create new channelupdateChannel- Update channel propertiesdeleteChannel- Delete channelarchiveChannel- Archive channelunarchiveChannel- Unarchive channellistChannelMembers- List channel membersaddChannelMember- Add member to channelremoveChannelMember- Remove member from channel
Chat Operations
listChats- List all chatsgetChat- Get specific chatcreateChat- Create new chatupdateChat- Update chat propertiesdeleteChat- Delete chatlistChatMembers- List chat membersaddChatMember- Add member to chatremoveChatMember- Remove member from chatpinMessage- Pin message in chatunpinMessage- Unpin message in chat
Message Operations
listMessages- List chat/channel messagesgetMessage- Get specific messagesendMessage- Send new messageupdateMessage- Update message contentdeleteMessage- Delete messagereplyToMessage- Reply to messagesetReaction- Add reaction to messageunsetReaction- Remove reaction from message
Configuration Example
const teamsTools = createTeamsTools({
accessToken: microsoftToken,
actions: ['sendMessage', 'listMessages', 'createChannel'],
defaultParams: {
chatChannelIdSendMessage: 'channel_id_123',
messageBodySendMessage: 'Hello from Forjinn AI!',
contentTypeSendMessage: 'text',
teamIdCreateChannel: 'team_id_456',
displayNameCreateChannel: 'AI Automation',
membershipTypeCreateChannel: 'standard'
},
type: 'chatMessage'
});
Advanced Teams Automation
// Send rich message with adaptive cards
await sendMessage({
chatId: 'chat-id',
body: {
contentType: 'html',
content: `
<div>
<h2>Project Status Update</h2>
<p><strong>Status:</strong> On Track</p>
<p><strong>Completion:</strong> 75%</p>
<p><strong>Next Milestone:</strong> January 30, 2024</p>
</div>
`
},
attachments: [
{
contentType: 'application/vnd.microsoft.card.adaptive',
content: {
type: 'AdaptiveCard',
version: '1.3',
body: [
{
type: 'TextBlock',
text: 'Project Dashboard',
weight: 'Bolder',
size: 'Medium'
}
]
}
}
]
});
// Create private channel with specific members
await createChannel({
teamId: 'team-id',
displayName: 'Private Project Discussion',
description: 'Confidential project planning',
membershipType: 'private',
members: [
'user1@company.com',
'user2@company.com',
'manager@company.com'
]
});
Authentication & Security
OAuth2 Flow
Both Google and Microsoft integrations use OAuth2 for secure authentication:
// Automatic token refresh
async init(nodeData: INodeData): Promise<any> {
let credentialData = await getCredentialData(nodeData.credential, options);
credentialData = await refreshOAuth2Token(nodeData.credential, credentialData, options);
const accessToken = getCredentialParam('access_token', credentialData, nodeData);
if (!accessToken) {
throw new Error('No access token found in credential');
}
return createServiceTools({
accessToken,
actions: selectedActions,
defaultParams: nodeParams
});
}
Required Permissions
Google Services
- Gmail:
https://www.googleapis.com/auth/gmail.modify - Sheets:
https://www.googleapis.com/auth/spreadsheets - Search: Custom Search API key and Search Engine ID
Microsoft Services
- Outlook:
Mail.ReadWrite,Calendars.ReadWrite - Teams:
Chat.ReadWrite,Channel.ReadWrite.All,TeamMember.ReadWrite.All
Security Best Practices
- Token Management: Automatic token refresh and secure storage
- Scope Limitation: Request only necessary permissions
- Error Handling: Graceful handling of authentication failures
- Rate Limiting: Respect API rate limits and quotas
- Audit Logging: Log all API interactions for compliance
Error Handling & Troubleshooting
Common Error Patterns
try {
const response = await serviceAPI.request(endpoint, options);
return response.data;
} catch (error) {
if (error.code === 'InvalidAuthenticationToken') {
// Refresh token and retry
await refreshOAuth2Token(credential, credentialData, options);
return await serviceAPI.request(endpoint, options);
}
if (error.code === 'RateLimitExceeded') {
// Implement exponential backoff
await delay(calculateBackoffDelay(error.retryAfter));
return await serviceAPI.request(endpoint, options);
}
throw new Error(`Service API error: ${error.message}`);
}
Troubleshooting Steps
-
Authentication Issues:
- Verify OAuth2 credentials
- Check token expiration
- Validate required scopes
-
API Errors:
- Check rate limits
- Verify request parameters
- Review API documentation
-
Permission Errors:
- Confirm user permissions
- Check service-specific access rights
- Validate credential scopes
-
Network Issues:
- Test connectivity
- Check firewall settings
- Verify proxy configuration
Integration Examples
Automated Email Processing
// Process unread emails and create tasks
const unreadEmails = await listMessages({
query: 'is:unread from:client@company.com',
maxResults: 10
});
for (const email of unreadEmails) {
const fullEmail = await getMessage({ messageId: email.id });
// Create calendar event for follow-up
await createEvent({
subject: `Follow up: ${fullEmail.subject}`,
start: { dateTime: tomorrow9AM },
end: { dateTime: tomorrow10AM },
body: `Follow up on email from ${fullEmail.from}`
});
// Mark as read
await modifyMessage({
messageId: email.id,
removeLabelIds: ['UNREAD']
});
}
Team Collaboration Automation
// Create project channel and send status update
const channel = await createChannel({
teamId: 'main-team',
displayName: 'Project Alpha',
description: 'Project Alpha coordination'
});
await sendMessage({
channelId: channel.id,
body: 'Project Alpha channel created! Let\'s collaborate here.',
mentions: ['@team', '@project-manager']
});
// Update project spreadsheet
await updateValues({
spreadsheetId: 'project-tracker',
range: 'Status!A1:C1',
values: [['Project Alpha', 'In Progress', new Date().toISOString()]]
});
This comprehensive integration enables powerful automation workflows across Google and Microsoft ecosystems while maintaining security and reliability.