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.3 KB
Raw Blame
import { createAction, Property } from '@activepieces/pieces-framework';
import { HttpMethod } from '@activepieces/pieces-common';
import { callTwilioApi } from '../common';
import { twilioAuth } from '../..';

export const twilioGetMessage = createAction({
  auth: twilioAuth,
  name: 'get_message',
  classification: 'READ',
  description: 'Get the status and details of a sent or received message.',
  audience: 'both',
  aiMetadata: { description: 'Fetches the full details and status of a single Twilio message by its SID. Use to check delivery status or inspect a known message; requires the message SID (starting with "SM" or "MM"). Read-only and idempotent.', idempotent: true },
  displayName: 'Get Message',
  props: {
    message_sid: Property.ShortText({
      displayName: 'Message SID',
      description: 'Starts with SM or MM. Shown in the Send SMS output and Twilio logs.',
      required: true,
      placeholder: 'SM0123456789abcdef0123456789abcdef',
    }),
  },
  async run(context) {
    const { message_sid } = context.propsValue;
    const account_sid = context.auth.username;
    const auth_token = context.auth.password;

    const path = `Messages/${message_sid}.json`;

    const response =  await callTwilioApi(
      HttpMethod.GET,
      path,
      { account_sid, auth_token }
    );

    return response.body;
  },
});