Respond chatbot API

Allow your chatbot to claim and close messages. Lexer's Chatbot API enables your chatbot to close messages from your Respond Inbox while it has control of a conversation on Facebook or Twitter. It's designed around the principle that your chatbot is another member of your team with limited permission to claim messages, close messages, and echo responses that it has published.

How it works

As your chatbot is handling the conversation with a customer, it constantly hits the Lexer API to 1) Claim ownership and close messages from the inbox, and 2) Echo responses it has published. Claiming ownership and closing messages will remove them from the inbox so your team are not double handling messages. Echoing responses will update the conversation history to show your team members that particular replies have been sent from the chatbot, and not members of your team.

If your chatbot is unable to resolve the customer's query, and needs to hand over to an agent, it can release the conversation to show subsequent messages in the Lexer Respond inbox. To do this, the chatbot simply stops calling the Claim and close API endpoint, and all new messages from the customer appear in the Respond inbox alongside other conversations for your team to pick up.

Authentication

To begin, you must create a new Bot User in Manage > Team > Our Team. Once created, you can click on the bot user in your team list to open the user's details and view examples of the bots API calls, as well as its unique API token. All requests to the Chatbot API are authenticated with an API token that must be sent via the Auth-Api-Token HTTP header.

Action 1: Claim and close

Our first API endpoint is to be used for all messages your chatbot receives while handling the conversation with your customer. The claim and close action is removing the messages from the Respond workflow. To handover a conversation to your team, the chatbot should be configured to stop calling the API. All subsequent messages will then enter the Inbox queue and a Customer Service Agent will pick it up.

Example

curl -H "Content-Type: application/json" -H "Auth-Api-Token: <ACCESS_TOKEN>" -X POST https://hub.lexer.io/api/clients/<CLIENT_ID>/bots/objects/claim -d '
{
    "object_id":"<OBJECT_ID>",
    "published_at":"<CREATED_TIME>",
    "source": "facebook",
    "state": "closed",
    "account_id": "<FACEBOOK_PAGE_ID>"
}'

Action 2: Echo response

Our second API endpoint is to be used for all messages that the chatbot sends to a customer. It is indicating that this particular response has been generated by the chatbot and will inform the Customer Service Agent that it was an automated response.

Example

curl -H "Content-Type: application/json" -H "Auth-Api-Token: <ACCESS_TOKEN>" -X POST https://hub.lexer.io/api/clients/<CLIENT_ID>/bots/objects/echo -d '

{
    "object_id":"<OBJECT_ID>",
    "published_at":"<CREATED_TIME>",
    "source": "facebook",
    "account_id": "<FACEBOOK_PAGE_ID>"
}'

Facebook API Example

Let’s deconstruct a webhook message received from Facebook to understand which fields are required to interact with the Chatbot API.

{
  "Sender":{
    "id":"USER_ID"
  },
  "Recipient":{
    "id":"PAGE_ID"
  },
  "Timestamp":1458692752478,
  "Message":{
    "Mid":"mid.1457764197618:41d102a3e1ae206a38",
    "text":"hello, world!",
    "quick_reply": {
      "payload": "DEVELOPER_DEFINED_PAYLOAD"
    }
  }
}

The parameters expected by the Lexer API could be retrieved from the message as per the table below:

Lexer API Parameter Messenger API Type Comments
object_id message.mid String ID for the message being actioned.
published_at timestamp String or integer Can be an epoch eg. 1458692752478 or an ISO8601 date eg. “2017-08-01t05:29:44Z”
source facebook String Always “facebook”
state closed String Always “closed”
account_id recipient.id String Facebook page ID
client_id n/a Integer ID of the Lexer client, found with the access token associated with the Bot User in Lexer Hub. Must be used in the URL.

API Response Codes

List of response codes, the body returned, and their description.

Status Body Description
201 {“status”:”ok”} Request was successfully accepted by Lexer.
400 {“status”:”400 Invalid Account”,”error”:”Cannot find an integrated account: 12345”} Integrated Facebook page cannot be found within Lexer.
500 Scary HTML response Invalid JSON or invalid parameter.
500 {“error”:”object_id is missing”} Required field is missing.
500 {“error:”source does not have a valid value”} Source value is not “facebook”.
500 {“error”:”state does not have a valid value”} State value s not set to “closed”.

That's a wrap

That's it for our Chatbot API! If you get stuck, try following the steps above and please don't hesitate to reach out to Lexer Support using the chatbot in the bottom right of the page.

Updated:
April 26, 2025
Did this page help you?
Thank you! Your feedback has been received!
Oops! Something went wrong while submitting the form, for assistance please contact support@lexer.io
Welcome to Lexer!
Fundamentals
Getting started
Javascript Tag basics
Data Platform
Javascript Tag
Data in the CDXP
Fundamentals
Getting started
Our glossary
Fundamentals
Getting started
Integrations overview
Fundamentals
Integrations
Onboarding data with Lexer
Data Platform
Data Onboarding
Data onboarding process
Data Platform
Data Onboarding
Importing CSV data
Data Platform
Data Onboarding
Importing JSON data
Data Platform
Data Onboarding
Secure file uploads
Data Platform
Data Onboarding
SFTP uploads and exports
Data Platform
Data Onboarding
AWS S3 uploads and exports
Data Platform
Data Onboarding
Lexer's attributes
Data Platform
Data Types
Predictive attributes
Data Platform
Data Types
Lexer API overview
Data Platform
Developer APIs
Understanding APIs
Data Platform
Developer APIs
API authentication
Data Platform
Developer APIs
API rate limits
Data Platform
Developer APIs
Bulk write API
Data Platform
Developer APIs
Profile read API
Data Platform
Developer APIs
Activity overview
Insights
Activity
Team report
Insights
Activity
Cases report
Insights
Activity
NPS report
Insights
Activity
Listen overview
Insights
Listen
Searching in Listen
Insights
Listen
Tier filters
Insights
Listen
Saved dives
Insights
Listen
Boolean search
Insights
Listen
Listen CSV exports
Insights
Listen
Visualize overview
Insights
Visualize
Curate image feed
Insights
Visualize
Respond overview
Engagement
Respond
Identity Resolution
Fundamentals
Getting started
My account
Fundamentals
Setup
Manage team
Fundamentals
Setup
Group permissions
Fundamentals
Setup
Classifications
Fundamentals
Setup
Out of the box segments
Fundamentals
Setup
Lexi your AI companion
Fundamentals
Getting started
Browser guide
Fundamentals
Security
Corporate networks
Fundamentals
Security
Multi-factor authentication
Fundamentals
Security
Single sign-on
Fundamentals
Security
Lexer's ultimate troubleshooting guide
Fundamentals
Troubleshooting
Troubleshooting tech issues
Fundamentals
Troubleshooting
Troubleshooting integrations
Fundamentals
Troubleshooting
Troubleshooting Activate
Fundamentals
Troubleshooting
Troubleshooting Respond
Fundamentals
Troubleshooting
Help! My data is missing from the Hub
Fundamentals
Troubleshooting
Lexer data specification
Data Platform
Data Specification
Customer data specification
Data Platform
Data Specification
Commerce data specification
Data Platform
Data Specification
Marketing data specification
Data Platform
Data Specification
Compliance data specification
Data Platform
Data Specification
Data formatting and validation
Data Platform
Data Specification
Product imagery
Data Platform
Data Specification
Currency conversion
Data Platform
Data Specification
Dataset management
Data Platform
Data Management
Getting started with Logs
Data Platform
Data Management
Respond chatbot API
Data Platform
Developer APIs
Activity API
Data Platform
Developer APIs
Lexer Forms overview
Data Platform
Forms
Form builder workflow
Data Platform
Forms
Form conditional logic
Data Platform
Forms
Form settings
Data Platform
Forms
Form segmentation
Data Platform
Forms
Form response analysis
Data Platform
Forms
Form hidden fields
Data Platform
Forms
Form attribute mapping
Data Platform
Forms
Javascript Tag technical guide
Data Platform
Javascript Tag
Javascript Tag use cases
Data Platform
Javascript Tag
Javascript Tag: Shopify Custom Pixel
Data Platform
Javascript Tag
CRM data
Data Platform
Data Types
Transaction data
Data Platform
Data Types
Email engagement data
Data Platform
Data Types
Experian data enrichment
Data Platform
Data Types
Customer Service data
Data Platform
Data Specification
GDPR and CCPA requests
Fundamentals
Compliance
File upload API
Data Platform
Developer APIs
Segment overview
Insights
Segment
Creating segments
Insights
Segment
Smart Search
Insights
Segment
Profile tab
Insights
Segment
Event Explorer
Insights
Segment
Attribute value types
Data Platform
Data Types
Compare segments
Insights
Compare
Compare attributes
Insights
Compare
Activate overview
Engagement
Activate
Segment activations
Engagement
Activate
Event activations
Engagement
Activate
Activation field mapping
Engagement
Activate
Audience splits
Engagement
Activate
A/B splits
Engagement
Activate
Control group splits
Engagement
Activate
Inbox filtering
Engagement
Respond
Ignored Senders
Engagement
Respond
Forms in Respond
Engagement
Respond
Workflow states
Engagement
Respond
Bulk changes
Engagement
Respond
Scheduled replies
Engagement
Respond
Message templates
Engagement
Respond
Finding conversations
Engagement
Respond
Customer profiles
Engagement
Respond
Grouped messages
Engagement
Respond
Automation rules
Engagement
Respond
Redact messages
Engagement
Respond
Routing customer replies
Engagement
Respond
Interact with comments
Engagement
Respond
Respond workflow tips
Engagement
Respond
Contact Reporting
Engagement
Contact
Contact Queue Filters
Engagement
Contact
Contact WhatsApp Queues
Engagement
Contact
Schedule overview
Engagement
Schedule
Serve overview
Engagement
Serve
Installing Serve
Engagement
Serve
Serve user management
Engagement
Serve
Forms in Serve
Engagement
Serve
Configuring Serve
Engagement
Serve
Serve reports
Engagement
Serve
Serve Currency
Engagement
Serve
Serve POS QR Code
Engagement
Serve
Activate CSV export
Engagement
Activate
Track overview
Insights
Track
Track Tables
Insights
Track
Lexer Product Recommender → Klaviyo Integration
Grow
Lexer Product Recommender → Klaviyo Integration
Where do your best customers live? Use geographic insights to maximize media spend and conversion
Grow
Where do your best customers live? Use geographic insights to maximize media spend and conversion
Suppression audiences: How to use them and maximize your media effectiveness
Enrich
Suppression audiences: How to use them and maximize your media effectiveness
Measure campaign effectiveness: Track your KPIs and report on campaign performance
Enrich
Measure campaign effectiveness: Track your KPIs and report on campaign performance
Converting prospects: Acquire customers from your current, engaged prospect base (and save your ad spend!)
Acquire
Converting prospects: Acquire customers from your current, engaged prospect base (and save your ad spend!)
Understanding customer intent: Effective message personalization for buyers who shop outside their gender
Grow
Understanding customer intent: Effective message personalization for buyers who shop outside their gender
Deepen customer understanding: Use third-party data to identify insights for personalized messaging and increased engagement
Grow
Deepen customer understanding: Use third-party data to identify insights for personalized messaging and increased engagement
Basket analysis: Increasing customer lifetime value through targeted product bundling
Grow
Basket analysis: Increasing customer lifetime value through targeted product bundling
Persona building: Personalize your messaging for maximum return on your campaign investments
Grow
Persona building: Personalize your messaging for maximum return on your campaign investments
Driving customer loyalty: Identify, keep, and grow your most loyal customers
Retain
Driving customer loyalty: Identify, keep, and grow your most loyal customers
Increasing customer lifetime value: Upselling strategies
Grow
Increasing customer lifetime value: Upselling strategies
Reactivating lapsed customers: Retention and growth
Retain
Reactivating lapsed customers: Retention and growth
Welcome offer strategies: Using the Hub for analysis
Acquire
Welcome offer strategies: Using the Hub for analysis
Creating customer forms: Best practices
Enrich
Creating customer forms: Best practices
Connecting your MarTech stack with Lexer!
Enrich
Connecting your MarTech stack with Lexer!
Identifying win-back customers using the Second Last Order: Date attribute
Retain
Identifying win-back customers using the Second Last Order: Date attribute
Understanding customers' purchasing habits: Order Sequence filter
Grow
Understanding customers' purchasing habits: Order Sequence filter
Maximizing customer communications in Respond
Retain
Maximizing customer communications in Respond
Using Product Recommendation in the Hub to encourage repeat purchases
Grow
Using Product Recommendation in the Hub to encourage repeat purchases
Encouraging customer loyalty using birthday campaigns
Retain
Encouraging customer loyalty using birthday campaigns
Increasing customer lifetime value: Converting your one-time buyers into two-time buyers
Grow
Increasing customer lifetime value: Converting your one-time buyers into two-time buyers
Collecting zero-party data using Lexer Forms
Enrich
Collecting zero-party data using Lexer Forms
Measuring your data over time with Track
Enrich
Measuring your data over time with Track
UTM Creation Guidelines
UTM Creation Guidelines
UTM Creation Guidelines
Brand Assets
Brand Assets
Brand Assets
GTM guide to creating marketing materials with Lexer
GTM guide to creating marketing materials with Lexer
GTM guide to creating marketing materials with Lexer
How to use the Lexer Form Builder
How to use the Lexer Form Builder
How to use the Lexer Form Builder
Explore our standard integrations
Explore our standard integrations
Explore our standard integrations
Operating a CDP Practice LP
Operating a CDP Practice LP
Operating a CDP Practice LP
LP Sales Enablement
LP Sales Enablement
LP Sales Enablement
Video Training Courses LP
Video Training Courses LP
Video Training Courses LP
Purpose and Mission
Purpose and Mission
Purpose and Mission
Brand & Marketing LP
Brand & Marketing LP
Brand & Marketing LP
Stage 3 - QBRs and Customer insights
Stage 3 - QBRs and Customer insights
Stage 3 - QBRs and Customer insights
Client Onboarding Journey
Client Onboarding Journey
Client Onboarding Journey
Start your CDP Practice
Start your CDP Practice
Start your CDP Practice
Lexer Messaging
Lexer Messaging
Lexer Messaging
Pain point conversations
Pain point conversations
Pain point conversations
Lexer Ideal Customer Profile & Positioning
Lexer Ideal Customer Profile & Positioning
Lexer Ideal Customer Profile & Positioning
Referral Partner Program Overview
Referral Partner Program Overview
Referral Partner Program Overview
Demo Hub Guide
Demo Hub Guide
Demo Hub Guide