https://discord.gg/botpress logo
Botpress Chat API: createEvent
# 🤝help
e
- Context: I am using a custom Chat UI on the frontend (combination of bubble.io and custom HTML) and Botpress Chat API for my WebApp. - Objective: I want to send user specific context/data via [createEvent](https://botpress.com/docs/api-reference/chat-api/openapi/createEvent). - Issue: I always get 400 status code, specifically:
Copy code
{
  "message": "must be equal to one of the allowed values"
}
- Attempts: I have been using this body structure in my API calls, trying the
type
with
"text"
,
"trigger"
,
"object"
,
"event"
, but so far all of them return `400 status code`:
Copy code
{
  "payload": {
    "type": "text",
    "text": "some random text"
  }
}
- As far as I know, there shouldn't be any issue with my
x-user-key
,
conversationId
, and any other fields that are required by botpress chat API, because I have tested them with the other endpoints (eg:
createUser
,
createConversation
,
createMessage
, etc). This is just one side of the issue. The end goal would be for my Bubble webapp backend to be able to do 2-way communication with my botpress chat engine. Is there probably some samples of working
createEvent
API call that I can imitate? Thanks in advance.
s
Your issue likely stems from an incorrect event type or payload structure. For createEvent, ensure the type matches Botpress's allowed values (e.g., "proactive-trigger" for custom events). Are you using Botpress's native event types, or do you need custom event handling?
e
First of all, thanks for responding to my post. Basically the objective is I need to send a custom event to my Botpress chatbot. Just to reiterate. If I want to send a custom event via
createEvent
endpoint with the following payload:
Copy code
{
  "payload": {
    "type": "banana",
    "data": {
      "foo": "bar"
    }
  },
  "conversationId": "conv_01K1..."
}
- Do I need to define in my workflow how to handle
"type": "banana"
first ? - Or should the value of the
type
should match only native Botpress's allowed values?
Solved it. I just need to use chat ID instead of webchat ID.
p
I'm glad you found a solution!
g
👋 @echoing-napkin-26350 I have a somewhat related question about sending the response back from chat api to external service similar to Bubble. I have tried many times and was unable to get the latest reply from botpress to show up correctly in the chat api. May i know if you have done that successfully?