Custom Authentication
This guide helps you connect CX Genie with your system to automatically retrieve user contact information through a secure API, instead of manual input.
🛠️ Step 1: Set up Authentication API
Go to
Custom Authentication
in CX Genie (under Development in Bot Detail).Enable the toggle to activate the feature.
Enter your Authentication URL - This should be an API endpoint in your system that CX Genie can call via a
POST
request.Example request body CX Genie will send:
{ "access_token": "...", "user_id": "..." }
🪪 Step 2: Pass Access Token and Optional User Info in Embed Script
To use Custom Authentication, you must pass an access_token
from your website into the CX Genie chat widget.
Use the data-token
attribute in your script tag:
<script src="https://your-widget-url.js" data-token="your_access_token"> </script>
✅ Optionally, pass additional user fields:
If enabled in the Additional request body section (e.g., "User ID" is checked), you can also pass more user-specific data via additional data-
attributes:
Attribute
Description
data-user-id
Unique ID of the user
data-email
User’s email address
data-name
Full name
data-phone-number
Phone number
Example:
<script src="https://your-widget-url.js" data-token="your_access_token" data-user-id="12345" data-email="[email protected]" data-name="John Doe" data-phone="0987654321"> </script>
These values will be included in the request body sent to your authentication API if configured accordingly.
📤 Step 3: Configure the Response Format
CX Genie needs to determine whether a user already exists in the system. You must configure your API to return a response with one of the following primary identifiers:
id
(default)email
phone_number
You can select the identification method from the "Identify method" dropdown in the Custom Authentication screen.
➤ Required Field Based on Your Selection:
Selected Method
Required in data
response
Id
id
Email
email
Phone number
phone_number
✅ Full Example Response:
{ "data": { "id": "12345", "email": "[email protected]", "name": "John Doe", "phone_number": "0987654321", "metadata": {} } }
🔍 Note: The field you choose must always be included in the response. If it's missing, the authentication may fail.
🧪 Step 4: Test Your Setup
Use the Testing panel on the right side of the screen:
Enter a sample
access_token
and select additional body fields.Click Send test request to verify your API is responding correctly.
📝 Tips
You can use the
metadata
field to give the bot more context about the user.Ensure your API is secured and only accessible from authorized sources.
Last updated