Forjinn Docs

Development Platform

Documentation v2.0
Made with
by Forjinn

Google Microsoft Integrations

Learn about google microsoft integrations and how to implement it effectively.

8 min read
🆕Recently updated
Last updated: 12/9/2025

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 pagination
  • createDraft - Create new email draft
  • getDraft - Retrieve specific draft
  • updateDraft - Modify draft content
  • sendDraft - Send draft as email
  • deleteDraft - Delete draft permanently
Message Operations
  • listMessages - List messages with advanced filtering
  • getMessage - Get specific message with full content
  • sendMessage - Send new email message
  • modifyMessage - Add/remove labels from messages
  • trashMessage - Move message to trash
  • untrashMessage - Restore message from trash
  • deleteMessage - Permanently delete message
Label Operations
  • listLabels - List all available labels
  • getLabel - Get specific label details
  • createLabel - Create new custom label
  • updateLabel - Update label properties
  • deleteLabel - Delete custom label
Thread Operations
  • listThreads - List email conversation threads
  • getThread - Get complete thread with all messages
  • modifyThread - Apply labels to entire thread
  • trashThread - Move thread to trash
  • untrashThread - Restore thread from trash
  • deleteThread - 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 spreadsheet
  • getSpreadsheet - Get spreadsheet metadata and structure
  • updateSpreadsheet - Update spreadsheet properties
Values Operations
  • getValues - Read cell values from ranges
  • updateValues - Write values to specific ranges
  • appendValues - Append new rows to sheets
  • clearValues - Clear content from ranges
  • batchGetValues - Read multiple ranges efficiently
  • batchUpdateValues - Update multiple ranges in one request
  • batchClearValues - 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 calendars
  • getCalendar - Get specific calendar details
  • createCalendar - Create new calendar
  • updateCalendar - Update calendar properties
  • deleteCalendar - Delete calendar
Event Operations
  • listEvents - List calendar events with filtering
  • getEvent - Get specific event details
  • createEvent - Create new calendar event
  • updateEvent - Update event details
  • deleteEvent - Delete calendar event
Message Operations
  • listMessages - List email messages
  • getMessage - Get specific message
  • createDraftMessage - Create draft message
  • sendMessage - Send email message
  • updateMessage - Update message properties
  • deleteMessage - Delete message
  • copyMessage - Copy message to folder
  • moveMessage - Move message to folder
  • replyMessage - Reply to message
  • forwardMessage - 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 channels
  • getChannel - Get specific channel
  • createChannel - Create new channel
  • updateChannel - Update channel properties
  • deleteChannel - Delete channel
  • archiveChannel - Archive channel
  • unarchiveChannel - Unarchive channel
  • listChannelMembers - List channel members
  • addChannelMember - Add member to channel
  • removeChannelMember - Remove member from channel
Chat Operations
  • listChats - List all chats
  • getChat - Get specific chat
  • createChat - Create new chat
  • updateChat - Update chat properties
  • deleteChat - Delete chat
  • listChatMembers - List chat members
  • addChatMember - Add member to chat
  • removeChatMember - Remove member from chat
  • pinMessage - Pin message in chat
  • unpinMessage - Unpin message in chat
Message Operations
  • listMessages - List chat/channel messages
  • getMessage - Get specific message
  • sendMessage - Send new message
  • updateMessage - Update message content
  • deleteMessage - Delete message
  • replyToMessage - Reply to message
  • setReaction - Add reaction to message
  • unsetReaction - 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

  1. Token Management: Automatic token refresh and secure storage
  2. Scope Limitation: Request only necessary permissions
  3. Error Handling: Graceful handling of authentication failures
  4. Rate Limiting: Respect API rate limits and quotas
  5. 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

  1. Authentication Issues:

    • Verify OAuth2 credentials
    • Check token expiration
    • Validate required scopes
  2. API Errors:

    • Check rate limits
    • Verify request parameters
    • Review API documentation
  3. Permission Errors:

    • Confirm user permissions
    • Check service-specific access rights
    • Validate credential scopes
  4. 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.