All guides
Channels Advanced 8 min read

Webhooks API Integration

Integrate any external chat or messaging system with your agent via HTTP requests.

Overview

The MyChatBot Webhooks API allows you to integrate any external chat or messaging system with your agent. This enables your AI assistant to communicate with users from any chat platform or custom application that can send HTTP requests.

Setting up webhooks

Required fields: API Token (a unique token to authenticate your requests), Unique Page ID (a unique identifier for your integration page), Reply Webhook URL (where MyChatBot sends responses back).

Connection steps: go to the Integrations tab → select the agent → scroll to Webhooks API → click Connect → fill in API Token, Unique Page ID, and Reply Webhook URL → toggle Connect assistant to this channel → set the Reply Delay (seconds) with the slider → click Connect Webhooks API to save.

Sending messages to MyChatBot

Make a POST request to the webhook endpoint:

POST https://api.mychatbot.app/webhook/mychatbot

Include the following JSON payload:

{
  "client_id": "UNIQUE_CLIENT_IDENTIFIER",
  "page_id": "YOUR_PAGE_ID",
  "client_name": "User Name",
  "client_avatar": "https://example.com/avatar.jpg",
  "platform": "YOUR_PLATFORM_NAME",
  "text": "Hello, I have a question",
  "attachments": ["https://example.com/image.jpg"]
}

Required fields: client_id (unique end-user identifier), page_id (the Page ID you configured), platform (name identifying your platform, e.g. "CustomApp"), text (the user's message). Optional fields: client_name (display name), client_avatar (avatar URL), audio (URL for voice messages), attachments (array of file/image URLs).

Receiving responses

MyChatBot sends responses to the Reply Webhook URL you provided, as a form-encoded POST request with these parameters: text (response message), images (URLs to any images, if applicable), file (URL to any file attachment), audio (URL to audio for voice responses).

Voice message support

The API supports voice in both directions. Sending voice to MyChatBot: include an audio URL in your request, MyChatBot automatically transcribes it and processes it as text:

{
  "client_id": "UNIQUE_CLIENT_IDENTIFIER",
  "page_id": "YOUR_PAGE_ID",
  "client_name": "User Name",
  "platform": "YOUR_PLATFORM_NAME",
  "audio": "https://example.com/audio.mp3"
}

Receiving voice responses: if voice responses are enabled in your settings, the assistant can respond with voice messages, included in the webhook response as an audio parameter.

Technical details

Message processing: the request is decoded and validated; the system checks the channel is active for the Page ID; a chat record is retrieved or created; audio (if present) is transcribed; the message is added to history; the assistant generates a response; the response is sent to the Reply Webhook URL.

Audio transcription: MyChatBot downloads the audio file, transcribes it via speech-to-text, processes the transcribed text as a regular message, and adds a prefix indicating it was originally voice.

Response generation: the assistant generates a response based on context; links/media are extracted; the text is split into manageable chunks if needed; each part is sent to your Reply Webhook URL; if voice is enabled, the text is also converted to speech.

Error handling

MyChatBot returns standard HTTP status codes: 200 OK (successful), 400 Bad Request (malformed request or missing required fields), 401 Unauthorized (invalid API token), 500 Internal Server Error (server-side error).

Advanced features & use cases

Multi-part messages: responses exceeding the maximum length are automatically split into multiple parts and sent sequentially. Media support: images (via the images param), files (file), and audio (audio), all as URL references. Response delay: configurable in the dashboard for a more natural flow.

Use cases: custom chat applications; integration with existing support systems; mobile app chat; IoT devices with messaging; custom business applications needing AI chat; third-party platforms not directly supported.