Skip to content

MyChatBot Webhooks API Integration

Overview

The MyChatBot Webhooks API allows you to integrate any external chat or messaging system with your MyChatBot 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

To connect the Webhooks API, you'll need to provide the following fields:

  1. API Token - A unique token to authenticate your requests
  2. Unique Page ID - A unique identifier for your integration page
  3. Reply Webhook URL - The URL where MyChatBot will send responses back

Connection Steps

  1. Navigate to the Integrations tab in your MyChatBot dashboard
  2. Select the agent you want to connect to the Webhooks API
  3. Scroll down to find Webhooks API in the integrations list
  4. Click the Connect button
  5. Fill in the required fields:
    • API Token: Your unique authentication token that will be used to verify webhook requests
    • Unique Page ID: A unique identifier for this integration channel
    • Reply Webhook URL: The URL where MyChatBot will send responses back to your system
  6. Toggle Connect assistant to this channel to enable the integration
  7. Set the desired Reply Delay (in seconds) using the slider - this controls how quickly your assistant responds
  8. Click Connect Webhooks API button to save your integration

Sending Messages to MyChatBot

To send messages from your system to MyChatBot, make a POST request to the MyChatBot webhook endpoint:

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

Request Format

The request should include the following JSON payload:

json
{
  "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: A unique identifier for the end user
  • page_id: The unique Page ID you configured in MyChatBot
  • platform: A name identifying your platform (e.g., "CustomApp")
  • text: The message text from the user

Optional Fields:

  • client_name: The end user's display name
  • client_avatar: URL to the end user's avatar image
  • audio: URL to an audio file (for voice messages)
  • attachments: Array of URLs to attached files or images

Receiving MyChatBot Responses

MyChatBot will send responses to the Reply Webhook URL you provided during setup. The response will be sent as a form-encoded POST request with the following parameters:

  • text: The response message text
  • images: URLs to any images included in the response (if applicable)
  • file: URL to any file attachments (if applicable)
  • audio: URL to audio files for voice responses (if applicable)

Voice Message Support

The Webhooks API supports voice messages in both directions:

Sending Voice Messages to MyChatBot

Include an audio URL in your webhook request:

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

MyChatBot will automatically transcribe the audio and process it as text.

Receiving Voice Responses

If you've enabled voice responses in your MyChatBot settings, the assistant can respond with voice messages. These will be included in the webhook response as an audio parameter.

Technical Details

Message Processing

When a message is received by the MyChatBot webhook endpoint, the following process occurs:

  1. The request is decoded and validated
  2. The system checks if the channel is active for the given Page ID
  3. A chat record is retrieved or created for the user
  4. If the message contains audio, it's automatically transcribed
  5. The message is added to the conversation history
  6. The AI assistant processes the message and generates a response
  7. The response is sent back to the specified Reply Webhook URL

Audio Transcription

If an audio URL is provided in the request, MyChatBot will:

  1. Download the audio file
  2. Transcribe the content using speech-to-text capabilities
  3. Process the transcribed text as a regular message
  4. Add a prefix indicating it was originally a voice message

Response Generation

After processing the message:

  1. The AI assistant generates a response based on the conversation context
  2. Any links or media in the response are extracted
  3. The text is split into manageable chunks if needed
  4. Each part of the response is sent to your Reply Webhook URL
  5. If voice replies are enabled, the text is also converted to speech

Error Handling

MyChatBot will return standard HTTP status codes:

  • 200 OK: Request was successful
  • 400 Bad Request: Malformed request or missing required fields
  • 401 Unauthorized: Invalid API token
  • 500 Internal Server Error: Server-side error processing the request

Advanced Features

Multi-part Messages

If your MyChatBot assistant sends a response that exceeds the maximum message length, it will automatically split the message into multiple parts and send them sequentially to your webhook endpoint.

Media Support

The Webhooks API supports various media types:

  • Images: Sent as URL references in the images parameter
  • Files: Sent as URL references in the file parameter
  • Audio: Sent as URL references in the audio parameter

Response Delay

You can configure the response delay in the MyChatBot dashboard. This sets how long the assistant waits before responding, which can create a more natural conversation flow.

Use Cases

The Webhooks API is perfect for:

  • Custom chat applications
  • Integration with existing customer support systems
  • Mobile app chat functionality
  • IoT devices with messaging capabilities
  • Custom business applications requiring AI chat support
  • Third-party platform integrations not directly supported by MyChatBot