Skip to content

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

1.2 KB
Raw Blame
import { segmentAuth } from '../../.';
import { Property, createAction } from '@activepieces/pieces-framework';
import { Analytics } from '@segment/analytics-node'

export const identifyUser = createAction({
  name: 'identifyUser',
  classification: 'WRITE',
  displayName: 'Identify User',
  description: '',
  audience: 'both',
  aiMetadata: { description: 'Sends a Segment Identify call that associates a user (by required userId) with a set of traits, registering or updating that profile in Segment. Use when an agent needs to record who a user is and their attributes for downstream analytics/tooling. Not idempotent: each call emits a new Identify event.', idempotent: false },
  props: {
    userId: Property.ShortText({
      displayName: 'User ID',
      required: true,
    }),
    traits: Property.Object({
      displayName: 'Traits',
      description: 'The traits to associate with the user',
      required: true,
    }),
  },
  auth: segmentAuth,
  async run(context) {
    const analytics = new Analytics({ writeKey: context.auth.secret_text })
    analytics.identify({
      userId: context.propsValue.userId,
      traits: context.propsValue.traits,
    })
    return {
      success: true,

    }
  },
});