Skip to main content
Glama

waha_pin_message

Pin important messages to the top of WhatsApp chats for easy reference, with customizable duration settings.

Instructions

Pin a message in a chat. Pinned messages appear at the top of the chat.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chatIdYesChat ID (format: number@c.us)
messageIdYesMessage ID to pin
durationNoPin duration in seconds (default: 86400 = 24 hours)

Implementation Reference

  • MCP server handler function that processes the waha_pin_message tool call, validates inputs, calls the WAHA client pinMessage method, and returns success response.
    private async handlePinMessage(args: any) {
      const chatId = args.chatId;
      const messageId = args.messageId;
      const duration = args.duration || 86400; // Default 24 hours
    
      if (!chatId) {
        throw new Error("chatId is required");
      }
    
      if (!messageId) {
        throw new Error("messageId is required");
      }
    
      await this.wahaClient.pinMessage({
        chatId,
        messageId,
        duration,
      });
    
      return {
        content: [
          {
            type: "text",
            text: `Successfully pinned message ${messageId} in chat ${chatId}.\nDuration: ${duration} seconds`,
          },
        ],
      };
    }
  • Tool schema definition including name, description, and input schema returned by ListToolsRequestSchema handler.
    name: "waha_pin_message",
    description: "Pin a message in a chat. Pinned messages appear at the top of the chat.",
    inputSchema: {
      type: "object",
      properties: {
        chatId: {
          type: "string",
          description: "Chat ID (format: number@c.us)",
        },
        messageId: {
          type: "string",
          description: "Message ID to pin",
        },
        duration: {
          type: "number",
          description: "Pin duration in seconds (default: 86400 = 24 hours)",
          default: 86400,
        },
      },
      required: ["chatId", "messageId"],
    },
  • src/index.ts:1063-1064 (registration)
    Registration of the waha_pin_message tool in the CallToolRequestSchema switch statement, dispatching to the handler.
    case "waha_pin_message":
      return await this.handlePinMessage(args);
  • WAHAClient helper method that makes the HTTP POST request to the WAHA API to pin the message.
    async pinMessage(params: {
      chatId: string;
      messageId: string;
      duration?: number;
    }): Promise<void> {
      const { chatId, messageId, duration } = params;
    
      if (!chatId) {
        throw new WAHAError("chatId is required");
      }
    
      if (!messageId) {
        throw new WAHAError("messageId is required");
      }
    
      const queryParams: Record<string, any> = {};
      if (duration !== undefined) {
        queryParams.duration = duration;
      }
    
      const queryString = this.buildQueryString(queryParams);
      const endpoint = `/api/${this.session}/chats/${encodeURIComponent(
        chatId
      )}/messages/${encodeURIComponent(messageId)}/pin${queryString}`;
    
      await this.request<void>(endpoint, {
        method: "POST",
      });
    }

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/seejux/waha-mcp'

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