send_linkedin_chat_message
Send direct messages to LinkedIn users through the HorizonDataWave API using account credentials from environment settings.
Instructions
Send a chat message via LinkedIn management API. Account ID is taken from environment.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| company | No | Company URN where the account is admin (format: company:123456) | |
| text | Yes | Message text | |
| timeout | No | Timeout in seconds | |
| user | Yes | Recipient user URN (must include prefix, e.g. fsd_profile:ACoAA...) |
Implementation Reference
- src/index.ts:862-895 (handler)Registration and inline handler implementation for the 'send_linkedin_chat_message' tool. Normalizes and validates the recipient URN, constructs API payload with account_id and message text, sends POST request to the AnySite LinkedIn management chat message endpoint, and returns the API response or error.server.tool( "send_linkedin_chat_message", "Send LinkedIn chat message (requires ACCOUNT_ID)", { user: z.string().describe("Recipient user URN (must include prefix)"), company: z.string().optional().describe("Company URN"), text: z.string().describe("Message text"), timeout: z.number().default(300).describe("Timeout in seconds") }, async ({ user, company, text, timeout }) => { const normalizedUser = normalizeUserURN(user); if (!isValidUserURN(normalizedUser)) { return { content: [{ type: "text", text: "Invalid URN format. Must start with 'fsd_profile:'" }], isError: true }; } const requestData: any = { timeout, user: normalizedUser, text, account_id: ACCOUNT_ID }; if (company) requestData.company = company; log("Starting LinkedIn send chat message for user:", normalizedUser); try { const response = await makeRequest(API_CONFIG.ENDPOINTS.CHAT_MESSAGE, requestData); return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] }; } catch (error) { log("LinkedIn send chat message error:", error); return { content: [{ type: "text", text: `LinkedIn send chat message API error: ${formatError(error)}` }], isError: true }; } } );
- src/types.ts:57-62 (schema)TypeScript interface defining the structure of input arguments for the send_linkedin_chat_message tool.export interface SendLinkedinChatMessageArgs { user: string; company?: string; text: string; timeout?: number; }
- src/types.ts:519-529 (helper)Type guard validation function for SendLinkedinChatMessageArgs inputs.export function isValidSendLinkedinChatMessageArgs( args: unknown ): args is SendLinkedinChatMessageArgs { if (typeof args !== "object" || args === null) return false; const obj = args as Record<string, unknown>; if (typeof obj.user !== "string" || !obj.user.trim()) return false; if (obj.company !== undefined && typeof obj.company !== "string") return false; if (typeof obj.text !== "string" || !obj.text.trim()) return false; if (obj.timeout !== undefined && typeof obj.timeout !== "number") return false; return true; }
- src/index.ts:88-92 (helper)Utility function used by the handler to normalize LinkedIn user URN by prepending 'fsd_profile:' if missing.const normalizeUserURN = (urn: string): string => { if (!urn.includes("fsd_profile:")) { return `fsd_profile:${urn}`; } return urn;
- src/index.ts:95-97 (helper)Utility function used by the handler to validate if a URN starts with 'fsd_profile:'.const isValidUserURN = (urn: string): boolean => { return urn.startsWith("fsd_profile:"); };