Skip to main content
POST
https://mtxbiyilvgwhbdptysex.supabase.co/functions/v1
/
create-chat-widget
curl -X POST https://mtxbiyilvgwhbdptysex.supabase.co/functions/v1/create-chat-widget \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "agent_id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "Support Widget",
    "primary_color": "#4f46e5",
    "welcome_message": "Hi there! How can we help you today?",
    "collect_visitor_email": true
  }'
{
  "id": "d4e5f6a7-b8c9-0d1e-2f3a-456789bcdef0",
  "widget_key": "wgt_a1b2c3d4e5f6789012345678",
  "agent_id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "Support Widget",
  "primary_color": "#4f46e5",
  "position": "bottom-right",
  "welcome_message": "Hi there! How can we help you today?",
  "collect_visitor_name": true,
  "collect_visitor_email": true,
  "is_active": true,
  "embed_code": "<script>(function(w,d,s,o,f,js,fjs){w['PatWidget']=o;w[o]=w[o]||function(){(w[o].q=w[o].q||[]).push(arguments)};js=d.createElement(s);fjs=d.getElementsByTagName(s)[0];js.id=o;js.src=f;js.async=1;fjs.parentNode.insertBefore(js,fjs);}(window,document,'script','PatChat','https://solomobile.ai/widget/pat-chat.js'));PatChat('init',{widgetKey:'wgt_a1b2c3d4e5f6789012345678'});</script>",
  "created_at": "2024-01-15T10:30:00Z"
}
Create a new chat widget that can be embedded on your website. Visitors can chat with your AI agent in real-time through the widget.

Request Body

agent_id
string
required
UUID of the agent to handle chat conversations.
name
string
Display name for the widget (internal use).Default: Website Chat
primary_color
string
Hex color code for the widget theme.Default: #6366f1
position
string
Widget position on the page: bottom-right or bottom-left.Default: bottom-right
welcome_message
string
Message shown when visitor opens the chat.Default: Hi! How can I help you today?
offline_message
string
Message shown when no agent is available.Default: Leave a message and we'll get back to you.
collect_visitor_name
boolean
Whether to ask for visitor’s name.Default: true
collect_visitor_email
boolean
Whether to ask for visitor’s email.Default: false
allowed_domains
array
List of domains where the widget can be embedded. Empty means all domains allowed.Example: ["example.com", "www.example.com"]

Response

id
string
Unique widget identifier.
widget_key
string
Public key for embedding the widget.
embed_code
string
Ready-to-use HTML embed code.
curl -X POST https://mtxbiyilvgwhbdptysex.supabase.co/functions/v1/create-chat-widget \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "agent_id": "550e8400-e29b-41d4-a716-446655440000",
    "name": "Support Widget",
    "primary_color": "#4f46e5",
    "welcome_message": "Hi there! How can we help you today?",
    "collect_visitor_email": true
  }'
{
  "id": "d4e5f6a7-b8c9-0d1e-2f3a-456789bcdef0",
  "widget_key": "wgt_a1b2c3d4e5f6789012345678",
  "agent_id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "Support Widget",
  "primary_color": "#4f46e5",
  "position": "bottom-right",
  "welcome_message": "Hi there! How can we help you today?",
  "collect_visitor_name": true,
  "collect_visitor_email": true,
  "is_active": true,
  "embed_code": "<script>(function(w,d,s,o,f,js,fjs){w['PatWidget']=o;w[o]=w[o]||function(){(w[o].q=w[o].q||[]).push(arguments)};js=d.createElement(s);fjs=d.getElementsByTagName(s)[0];js.id=o;js.src=f;js.async=1;fjs.parentNode.insertBefore(js,fjs);}(window,document,'script','PatChat','https://solomobile.ai/widget/pat-chat.js'));PatChat('init',{widgetKey:'wgt_a1b2c3d4e5f6789012345678'});</script>",
  "created_at": "2024-01-15T10:30:00Z"
}

Embed Code

Add the widget to your website by pasting this code before the closing </body> tag:
<script>
  (function(w,d,s,o,f,js,fjs){
    w['PatWidget']=o;w[o]=w[o]||function(){(w[o].q=w[o].q||[]).push(arguments)};
    js=d.createElement(s);fjs=d.getElementsByTagName(s)[0];
    js.id=o;js.src=f;js.async=1;fjs.parentNode.insertBefore(js,fjs);
  }(window,document,'script','PatChat','https://solomobile.ai/widget/pat-chat.js'));
  PatChat('init', { widgetKey: 'YOUR_WIDGET_KEY' });
</script>