Skip to main content
Glama

send_message

Send text or media messages to Instagram or Facebook Messenger users using their platform APIs.

Instructions

Send a message to a user on Instagram or Facebook Messenger. Can send text or media (image, video, audio).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
platformYesPlatform to send message on
recipientIdYesThe user ID to send the message to
textNoText message content (optional if sending media)
mediaUrlNoURL of media to send (optional)
mediaTypeNoType of media being sent
isHumanAgentNoSet to true if message is from human agent (extends messaging window)

Implementation Reference

  • Main handler for the 'send_message' MCP tool. Parses arguments with Zod schema and delegates to platform-specific API functions.
    case 'send_message': { const params = SendMessageSchema.parse(args); if (params.platform === 'instagram') { result = await api.sendInstagramMessage({ recipientId: params.recipientId, text: params.text, mediaUrl: params.mediaUrl, mediaType: params.mediaType, isHumanAgent: params.isHumanAgent }); } else { result = await api.sendFacebookMessage({ recipientId: params.recipientId, text: params.text, mediaUrl: params.mediaUrl, mediaType: params.mediaType, isHumanAgent: params.isHumanAgent }); } break; }
  • Zod schema used for input validation in the send_message handler.
    const SendMessageSchema = z.object({ platform: z.enum(['instagram', 'facebook']), recipientId: z.string(), text: z.string().optional(), mediaUrl: z.string().optional(), mediaType: z.enum(['image', 'video', 'audio']).optional(), isHumanAgent: z.boolean().optional() });
  • src/index.ts:104-119 (registration)
    Tool registration in the ListTools response, defining name, description, and JSON schema for inputs.
    { name: 'send_message', description: 'Send a message to a user on Instagram or Facebook Messenger. Can send text or media (image, video, audio).', inputSchema: { type: 'object', properties: { platform: { type: 'string', enum: ['instagram', 'facebook'], description: 'Platform to send message on' }, recipientId: { type: 'string', description: 'The user ID to send the message to' }, text: { type: 'string', description: 'Text message content (optional if sending media)' }, mediaUrl: { type: 'string', description: 'URL of media to send (optional)' }, mediaType: { type: 'string', enum: ['image', 'video', 'audio'], description: 'Type of media being sent' }, isHumanAgent: { type: 'boolean', description: 'Set to true if message is from human agent (extends messaging window)' } }, required: ['platform', 'recipientId'] } },
  • Core implementation for sending messages (text or media) to Instagram via Facebook Graph API.
    export async function sendInstagramMessage(options: SendMessageOptions): Promise<any> { const { recipientId, text, mediaUrl, mediaType, isHumanAgent = false } = options; const payload: any = { recipient: { id: recipientId } }; if (text) { payload.message = { text }; } else if (mediaUrl && mediaType) { payload.message = { attachment: { type: mediaType, payload: { url: mediaUrl, is_reusable: true } } }; } if (isHumanAgent) { payload.messaging_type = 'MESSAGE_TAG'; payload.tag = 'HUMAN_AGENT'; } return makeApiCall({ method: 'POST', endpoint: `/me/messages`, data: payload }); }
  • Core implementation for sending messages (text or media) to Facebook Messenger via Facebook Graph API.
    export async function sendFacebookMessage(options: SendMessageOptions): Promise<any> { const { recipientId, text, mediaUrl, mediaType, isHumanAgent = false } = options; const payload: any = { recipient: { id: recipientId }, access_token: config.fbPageAccessToken }; if (text) { payload.message = { text }; } else if (mediaUrl && mediaType) { payload.message = { attachment: { type: mediaType, payload: { url: mediaUrl, is_reusable: true } } }; } if (isHumanAgent) { payload.messaging_type = 'MESSAGE_TAG'; payload.tag = 'HUMAN_AGENT'; } return makeApiCall({ method: 'POST', endpoint: `/${config.fbPageId}/messages`, data: payload }); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/osborn1997/instagram-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server