# Backend Triggers

Use backend events to trigger surveys inside your mobile app and website. Additional properties can be passed with the backend events to add more context to users' responses.

### Setting up the Backend Trigger

* Navigate to Connections Tab > Backend Trigger on Blitzllama's dashboard
* Click on the Backend Trigger card and then click 'Enable'.&#x20;
* Copy the URL :link:(send backend trigger events on this URL) & the unique API Key 🔑 (add in the API header \[x-api-key]).

#### API call

```javascript
var request = require('request');

var options = {
  'method': 'POST',
  'url': 'https://events.blitzllama.com/api/v1/connections/backend/event', //copied url
  'headers': {
    'x-api-key': '<copied API Key>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
   "user_id":"user_123",
  "event_name":"item_added_to_cart",
  "properties": {
      "id": 1,
      "name": "War and Peace",
      "author": "Leo Tolstoy",
      "type": "hardcover",
      "category": "novel"
    }
  })
};

request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

{% hint style="info" %}
**event\_name** - this is the name of the backend trigger, which will show up in the Trigger tab on Blitzllama's dashboard after the first successful API.

**user\_id** - the unique user identifier.

**properties** -  JSON object that will be added to each survey responses.
{% endhint %}

**Sample payload**

```json
{
  "user_id":"user_123",
  "event_name":"item_added_to_cart",
  "properties": {
      "id": 1,
      "name": "War and Peace",
      "author": "Leo Tolstoy",
      "type": "hardcover",
      ...
      "category": "novel"
    }
  }  
```

###

### **How to trigger an in-app survey using Backend Trigger**

* In the survey editor navigate to "Configure & Launch" > "Select trigger" section&#x20;
* Click on "Activate with backend event" option
* Choose the backend triggers (all your backend triggers will be populated in the dropdown)
* Add event expiration time (max 100 hours). This allows you maintain relevancy of the survey questions.
* Lastly, choose where the surveys should show up on your app or website by selecting the frontend triggers from the "Select Trigger" dropdown.

<figure><img src="/files/xFBnoGA16buSW5v4tdo9" alt=""><figcaption><p>In the above screenshot of a Sleep Tracking app, a sleep quality monitoring survey will be shown to the users within 2 hours of them ending their sleep ("ended sleep" event) on the app's homepage ("MainActivity" frontend trigger).</p></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.blitzllama.com/connections-sources/backend-triggers.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
