OpenWA Documentation

website·Indexed 32 days ago

https://docs.openwa.dev

Technical reference for OpenWA, featuring API models, controllers, and structures. Includes documentation for MessageCollector, Dialog interfaces, pre-processors, and logging transports, as well as session information and health check interfaces.

Tokens
57.7K
Snippets
411
Records
576
Agent score
58%

What's inside OpenWA

  1. Overview of Socket Mode for WhatsApp sessions

    Socket Mode allows the separation of the WhatsApp session from the application code. This architecture enables running the session and application on different servers, allows code changes without restarting the WhatsApp session, supports multiple socket clients connected to a single session, and ensures session persistence if the application crashes.
  2. Overview of OpenWA Easy API and Integrations

    OpenWA provides an 'Easy API' that allows users to convert their account into an API and configure automations and integrations without writing code. The platform includes a suite of first-class integrations with services such as Chatwoot, Node Red, S3, and Twilio.
  3. Overview of open-wa automation tools

    open-wa is a collection of tools designed to automate WhatsApp accounts. It can be deployed and run through several methods depending on the use case: using the CLI via npx or Docker for quick setups, or by integrating the library into custom code running locally or via Socketed mode.
  4. Understand the ReactionEvent object structure

    The ReactionEvent object is emitted by the onReaction event and provides details about a reaction associated with a message. It contains the target message, the specific reaction from the host account, a list of all reactions, and the event type.
    interface ReactionEvent {
      /** The message being reacted to */
      message: Message;
      /** The reaction sent by the host account */
      reactionByMe: Reaction;
      /** An array of all reactions */
      reactions: Reaction[];
      /** The type of the reaction event: 'add' or 'change' */
      type: 'add' | 'change';
    }
  5. ParticipantChangedEventModel Interface Properties

    The ParticipantChangedEventModel provides details about a change in group participants. It contains the following properties:

    • action: The type of change event (of type groupChangeEvent).
    • by: The ID of the contact who performed the action (ContactId).
    • chat: The ID of the chat where the change occurred (ChatId).
    • who: A list of contact IDs affected by the change (ContactId[]).
  6. Create an OpenWA API

    OpenWA provides two primary methods for creating an API to interact with WhatsApp: using a ready-made API via npx for quick setup, or building a custom API using Express.js by integrating the built-in OpenWA middleware.
  7. Reference the GenericGroupChangeEvent interface properties

    The GenericGroupChangeEvent interface provides details about events triggered within a group. It includes information about the actor who triggered the event, the type of change, and associated metadata.
    interface GenericGroupChangeEvent {
      author: Contact; // The contact who triggered this event (e.g., who changed the group picture)
      body: string; // Additional information about the event
      groupMetadata: GroupMetadata; // Metadata associated with the group
      groupPic: string; // Base 64 encoded image of the group picture
      id: MessageId; // Unique identifier for the event
      type: GenericGroupChangeEventType; // The specific type of group event
    }
  8. GroupMetadata interface properties

    The GroupMetadata interface provides detailed information about a group chat. Key properties include:

    • id: The unique chat ID of the group (GroupChatId).
    • creation: Timestamp of when the group was created (number).
    • groupType: The category of the group, restricted to values: "DEAFULT", "SUBGROUP", or "COMMUNITY".
    • owner: The ID of the group owner (NonSerializedId).
    • desc: (Optional) The group's description (string).
    • descOwner: (Optional) The account that last updated the description (ContactId).
    • participants: An array of Participant objects currently in the group.
    • pendingParticipants: An array of Participant objects awaiting entry.
    • joinedSubgroups: A list of group IDs (format ${number}@g.us) that the host account has joined as part of this community.
    • defaultSubgroup: Boolean indicating if communities have a default group chat.
    • isParentGroup: (Optional) Boolean indicating if the group is a parent group (community).
    • isParentGroupClosed: Boolean indicating if the parent group is closed.
    • support: (Optional) Boolean (purpose undefined).
    • suspended: (Optional) Boolean (purpose undefined).
    • trusted: (Optional) Boolean (purpose undefined).
  9. Reference the BusinessProfile interface properties

    The BusinessProfile interface provides detailed information about a business contact. Key properties include:

    • id: The Contact ID of the business (ContactId).
    • description: The business description (string).
    • email: The business' email address (string).
    • address: The physical address of the business (string).
    • latitude / longitude: The geographic coordinates of the business location if set (number).
    • website: An array of strings representing the business' websites (string[]).
    • businessHours: The operating hours of the business (BusinessHours).
    • catalogStatus: The status of the business' catalog (string).
    • categories: The business' categories (BizCategory[]).
    • fbPage: The Facebook page of the business (any).
    • igProfessional: The Instagram profile of the business (any).
    • isProfileLinked: Boolean indicating if the profile is linked (boolean).
    • profileOptions: The business' profile options (BizProfileOptions).
    • tag: A special string that identifies the business (string).
  10. Automatically reject incoming calls

    The autoReject method automatically rejects calls on the host account device. Note that the caller's device will continue to ring due to Multi-Device (MD) architecture. An optional message can be sent to the caller upon rejection.
    // Returns Promise<boolean>
    await client.autoReject('I cannot take calls right now');