How can I push a user event from my backend?Push the event to the user profile
Articles on: Developers
Crisp lets you push events from the Crisp chatbox. If, however, you'd like to push those events from your backend instead, there's a way to do it via the Crisp REST API. This article explains how to do so.
First of all, you need to connect your backend to the Crisp APIs. Read this introduction article on how to do it.
Once you are done, you will follow this integration process (explained in details below):
- Your backend can reach the Crisp APIs
- In order to push an event to an user profile in your website, we need their
people_id(ie. profile identifier)
- You can set the
people_idstraight as the useremail(the API does the job of matching anemailbeing passed aspeople_id)
The
people_id
reference value is an identifier, which does not change for a given profile whenever you change its associated email. You can still pass in an
email
value as the
people_id
value in a request; the API will do the job of matching the email to an identifier internally, which is more convenient in most use cases.
Okay! Lets proceed now.
You may push an event by submitting an event data:
undefined { "text": "basket:item:added", "color": "blue", "data": { "product": "iPhone X" } }
As a HTTP
POST
to the following route:
/website/{website_id}/people/events/{people_id}
, where
website_id
is your Crisp website identifier (it does not change), and
people_id
, here, is your user
email
value (you can also pass in a
people_id
identifier, if you already have it).
Here's an example formatted route:
/website/04ed9a29-ccda-4f46-b2f3-b151d2d90fa7/people/events/john.doe@crisp.chat
, which would give the following full URL to Crisp API:
https://api.crisp.chat/v1/website/04ed9a29-ccda-4f46-b2f3-b151d2d90fa7/people/events/john.doe@crisp.chat
.
This route is explained in the docs for the people profile event route.
Updated on: 13/03/2024
Updated on: 19/07/2024
Thank you!