Developers — Bonjourchat
Skip to content

Developers

Build on Bonjourchat.

Add customer chat to your website, connect your channels and build a mobile chat experience. The dashboard, API and widget are served from the same domain.

Dashboardhttps://bonjourchat.com/app

Visitor APIhttps://bonjourchat.com/api/widget

Widget scripthttps://bonjourchat.com/widget/sdk.js

Install the widget

  1. 01

    Create a website

    Open Integrations → Websites in your workspace. Add a website and keep it active.

  2. 02

    Allow your domains

    Add the hosts where the widget will run, including ports for local development. *.example.com covers subdomains; add example.com separately.

  3. 03

    Copy the installation code

    Use the public key from that website’s installation screen. Add the script once, then send a message and reply from the inbox.

<!-- Replace YOUR_PUBLIC_KEY with the key from Integrations → Websites. -->
<!-- Add once, before </body>, on an allowed website domain. -->
<script src="https://bonjourchat.com/widget/sdk.js" data-bonjourchat-key="YOUR_PUBLIC_KEY" async></script>

Replace YOUR_PUBLIC_KEY with the complete bc_ key from your website. No npm package is needed. The script calls the API on its own origin. For a self-hosted installation, use the script URL supplied by your dashboard.

Authentication

A website’s public key identifies its installation. The browser sends its Origin, which must match an allowed domain. Bootstrap returns a visitor_token; include it with the public_key in subsequent JSON requests. These requests only access that visitor’s conversation.

The widget stores its visitor session in local storage when available. Tokens last 30 days and are bound to the website and origin. Pass an existing token to bootstrap to resume a session; a new bootstrap without it creates a new visitor.

Treat the visitor token as private. A public website key gives no access to your team’s inbox. Dashboard operations use your signed-in session and workspace permissions. Mobile server keys belong only on your authenticated backend.

Visitor API reference

All routes below accept POST with Content-Type: application/json and return JSON. Replace the example origin with an allowed website origin, YOUR_PUBLIC_KEY with its key, and YOUR_VISITOR_TOKEN with the bootstrap response. Browsers set Origin automatically. The examples show a new visitor and illustrative message IDs; use the IDs returned by your requests.

Visitor session

History & messages

Visitor details

curl 'https://bonjourchat.com/api/widget/bootstrap' \
  -H 'Content-Type: application/json' \
  -H 'Origin: https://your-site.com' \
  --data '{
  "public_key": "YOUR_PUBLIC_KEY"
}'
{
  "visitor_token": "YOUR_VISITOR_TOKEN",
  "visitor_id": "VISITOR_ID",
  "name": "Your website"
}

Pagination & retries

  • Before the first message, conversation is null. Sending creates the conversation and visitor profile.
  • History returns conversation.messages and next_cursor. Request older messages by passing next_cursor as before. Keep fetching until it is null. The default page size is 50; limit accepts 1–100.
  • Poll without before for new messages, merge by message ID and backfill older pages until you reach a known message. A new page can leave a gap if more messages arrived than fit in one page.
  • Generate a new UUID client_id for each message. On a timeout, retry the same payload with the same client_id to avoid creating a duplicate.
  • Send text of up to 4,000 characters or a GIF object with gif_id and optional search_term. Send one or the other. The website composer supports text, emoji and GIFs.
  • Profile updates require a name and an email address, or an empty email string. These are visitor-provided details, not verified identity.

Mobile apps

Create an integration under Integrations → Mobile apps. Keep its server key on your backend. After authenticating your customer, request a session using that customer’s stable internal ID. Return the visitor session to the app. The same customer can then resume their conversation on another device.

# Run on your authenticated backend. Keep the server key out of the app.
# Derive customer_id from the signed-in customer, not from request input.
curl 'https://bonjourchat.com/api/mobile/session' \
  -H "Authorization: Bearer $BONJOURCHAT_MOBILE_SERVER_KEY" \
  -H 'Content-Type: application/json' \
  --data '{
  "public_key": "YOUR_MOBILE_PUBLIC_KEY",
  "customer_id": "YOUR_INTERNAL_CUSTOMER_ID",
  "name": "Camille",
  "email": "[email protected]"
}'

The response contains visitor_token, visitor_id and name. Use the mobile public key and token with /api/mobile/conversation, /send, /read and /profile, using the same payloads as the visitor API above. Anonymous sessions can use /api/mobile/bootstrap. Clear the active chat session when the customer signs out.

Connect your channels

Email

Create an email integration to get an inbox address. Send to it directly or forward your existing mailbox. Replies are threaded and inbound attachments are available in the inbox; outgoing replies are text. This does not connect an IMAP mailbox or authorize sending from your own domain.

WhatsApp

Create a WhatsApp integration and scan its QR code using Linked devices on your phone. This uses a linked-device connection, not the WhatsApp Business API. New messages and incoming attachments appear in the inbox; outgoing replies are text. History starts at pairing.

Voice

Create a voice integration and configure your phone gateway with its public key and secret. Each call creates a conversation. Enable transcript or recording publishing on the gateway if needed. Inbox replies are internal notes; call controls stay on the phone gateway.

Owners and admins configure integrations. Messages from connected channels appear in the shared inbox. Customer records remain separate across installations; identities and threads are not automatically merged across channels.

AI & knowledge

Publish articles in your knowledge base, then configure AI under Integrations → AI Agent. Choose drafts for human review or automatic replies. Answers use published sources; questions without sufficient support stay with your team. The configured AI service must be available before automatic replies can run. Agents do not execute refunds, make bookings or modify customer accounts.

Incoming webhooks

Email reception uses a Resend webhook configured by the Bonjourchat server operator. It delivers email.received events to the URL below and verifies the Svix signature with the configured webhook secret. The receiving domain also needs its MX records. Workspace users only need their generated inbox address or a forwarding rule.

https://bonjourchat.com/api/channels/resend/webhook

This endpoint receives provider events. Subscriptions that send Bonjourchat conversation events to your own URL are not currently available.

Errors & rate limits

Bootstrap allows 120 requests per minute per installation and IP address. Sending allows 60 messages per minute per visitor. A 429 response includes Retry-After in seconds. Read receipts accept up to 100 message IDs at a time.

400Invalid payload

Check required fields, UUIDs, IDs and message length.

401invalid_visitor_token

The visitor session is invalid, expired or belongs to another installation or origin.

403website_not_allowed

Check the website key, active status and the request Origin against the allowed domains.

404conversation_not_found

Send a first message before updating a web visitor’s profile.

429chat_rate_limit

Wait for the number of seconds in the Retry-After header before trying again.

SDK availability

Website

Use the hosted /widget/sdk.js script. No package installation required.

React Native

The repository includes @bonjourchat/client-mobile and @bonjourchat/native-chat as workspace packages. They are not published to npm.

Custom clients

Use the visitor HTTP endpoints documented above. No public Node, Python, Swift or Kotlin package is currently distributed.

Mobile scope

Text, emoji and GIF messages, history and read receipts. Push notifications and an attachment picker are not included.

Need help integrating? Talk to our team.