Skip to main content
A Bot is an existing user that also has a webhook. Once a bot is enabled, CometChat relays the messages it receives to the bot’s webhookURL, and your service replies by calling the Send Bot Message API.

Endpoints

How bots work

  • A bot is a user plus a webhook. The uid you pass to the Create Bot API must already belong to a User; if it does not, the API returns ERR_UID_NOT_FOUND.
  • One-to-one messages sent to the bot are relayed to its webhookURL.
  • Group messages are relayed according to groupChatSetting:
  • A bot only relays messages while enabled is true.
  • Set useBasicAuth to true to send HTTP basic auth credentials with every webhook call, so your endpoint can verify the caller.
  • Bots reply through the Send Bot Message API, which posts a message as the bot.
  • Agents created through AI Agents are not managed by these endpoints. They don’t appear in the List Bots response, and Get, Update and Delete return ERR_BOT_NOT_FOUND for their UIDs.
The API returns a bot’s stored password in responses to Create, List, Get and Update. This includes bots whose useBasicAuth was later set to false, because turning it off does not clear the stored credentials. A GET /bots response therefore contains the basic auth credentials of every bot in the app. Treat those responses as secrets, and restrict who can use the API key that reads them.

Relationships

  • Users — A bot is a User with a webhook attached. Its name and avatar belong to the user, so change them with the Update User API.
  • Send Bot Message — Use the Send Bot Message API to post a message as a bot.
  • Custom Bots — For an end-to-end walkthrough, including the webhook payload your service receives, see the Custom Bots guide.

Bot properties

Responses omit every property whose value is empty or false, so a standard bot has no isAIBot, and a bot that has never had basic auth has no useBasicAuth, username or password. Setting useBasicAuth to false with the Update Bot API does not clear stored credentials: the response drops useBasicAuth but still contains username and password.

Error handling

For the complete list of error codes, see Error Guide. For all system limits (bot caps, UID length, etc.), see Properties and Constraints.