Skip to main content
Glama

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
NameRequiredDescriptionDefault
companyNoCompany URN where the account is admin (format: company:123456)
textYesMessage text
timeoutNoTimeout in seconds
userYesRecipient user URN (must include prefix, e.g. fsd_profile:ACoAA...)

Implementation Reference

  • 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
          };
        }
      }
    );
  • 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;
    }
  • 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;
    }
  • 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;
  • 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:");
    };

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/anysiteio/hdw-mcp-server'

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