AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
import { createAction, Property } from '@activepieces/pieces-framework';
import { propsValidation } from '@activepieces/pieces-common';
import { googleChatApiAuth, googleChatCommon } from '../common';
import { spacesDropdown } from '../common/props';
import { googleChatAPIService } from '../common/requests';
export const findMember = createAction({
auth: googleChatApiAuth,
name: 'findMember',
classification: 'READ',
displayName: 'Find Member',
description: 'Search space member by email',
audience: 'both',
aiMetadata: {
description: 'Looks up a member of a given Google Chat space by their email address, returning the matching membership or an error message if the email is not found or the person is not in that space. Use to resolve an email to a space member before acting on them. Read-only and idempotent.',
idempotent: true,
},
props: {
spaceId: spacesDropdown({ refreshers: ['auth'], required: true }),
email: Property.ShortText({
displayName: 'Member Email',
description: 'The email address of the member to find',
required: true,
}),
},
async run({ auth, propsValue }) {
await propsValidation.validateZod(propsValue, googleChatCommon.findMemberSchema);
const { spaceId, email } = propsValue;
const accessToken = auth.access_token;
try {
const people = await googleChatAPIService.fetchPeople(
accessToken
);
const person = people.find((p: any) =>
p?.emailAddresses?.some(
(e: any) => e.value.toLowerCase() === email.toLowerCase()
)
);
if (!person) return { error: `No user found with email ${email}` };
const spaceMemberId = (person.resourceName as string).replace('people', 'users');
const spaceMembers = await googleChatAPIService.fetchSpaceMembers(
accessToken,
spaceId as string
);
const matchingMember = spaceMembers.find(
(m: any) => m.member?.name === spaceMemberId
);
if (!matchingMember) return {
error: `${email} is not a member of space ${spaceId}`,
};
return matchingMember;
} catch (e) {
console.error('Error finding member by email', e);
return { error: 'Failed to retrieve member information' };
}
},
});