OneBot-api icon

OneBot-api

Consume OneBot API

Overview

This node integrates with the OneBot API to perform various operations related to bots, friends, groups, messages, members, and miscellaneous functions. Specifically, for the resource "好友" (Friend) and operation "获取陌生人信息" (Get Stranger Info), it retrieves information about a stranger user by their user ID or username.

Common scenarios where this node is beneficial include:

  • Fetching detailed profile information of a user who is not in your friend list.
  • Automating interactions based on stranger user data.
  • Integrating with chatbots or messaging platforms that use OneBot API to manage contacts and gather user info.

Practical example:

  • You want to get profile details of a user who sent you a message but is not your friend yet. Using this node with the "获取陌生人信息" operation allows you to fetch that user's info automatically.

Properties

Name Meaning
User Name or ID Select a user from your friend list or specify a user ID via expression. This identifies the stranger whose information you want to retrieve.

The property supports loading options dynamically from the friend list.

Output

The node outputs JSON data containing the response from the OneBot API for the requested operation. For "获取陌生人信息", the output JSON will typically include fields describing the stranger's profile information such as nickname, user ID, age, gender, and other available metadata.

If an error occurs during execution, the output JSON will contain an error field with the error message and a success field set to false.

The node does not output binary data.

Dependencies

  • Requires connection to a OneBot API endpoint.
  • Needs an API key credential configured in n8n to authenticate requests to the OneBot API.
  • The node uses internal helper methods to load friend lists and make API requests.

Troubleshooting

  • Common issues:

    • Failure to retrieve friend list options may cause inability to select users.
    • Network or authentication errors when calling the OneBot API.
    • Invalid or missing user ID input.
  • Error messages:

    • "Failed to get login info": Indicates the node could not authenticate or retrieve bot login status. Check API credentials and connectivity.
    • "Failed to get friend list": The node cannot fetch the friend list for dynamic options. Verify API permissions and network access.
    • "Unknown resource type": Occurs if an unsupported resource is selected; ensure "friend" is chosen for this operation.
    • Execution errors are returned in the output JSON under the error field with descriptive messages.
  • Resolutions:

    • Confirm API credentials are valid and have necessary permissions.
    • Ensure the OneBot server is reachable.
    • Provide a valid user ID or select from the loaded friend list.
    • Review logs for detailed error messages.

Links and References

Discussion