Executing actions on your endpoint

Want to make your custom data more interactive? You can add input fields, textareas and action buttons that let your agents perform tasks directly from Fernand. These actions send requests to your server, making it easy to manage user data without leaving the interface.

Before you start
For security reasons, action requests can only be sent to endpoints that share the same domain as your custom data endpoint. For example, if you load user data from https://api.yoursite.com/users/details, you can only send actions to api.yoursite.com

Adding action buttons

Simple button

Need a straightforward action like deleting a user account? Use a simple button! Here's how:

<button 
  name="delete" 
  data-method="post" 
  data-url="https://api.yoursite.com/users/{{ email }}">
  Delete this account
</button>

Required attributes:

  • data-url: Where to send the request (must match your data endpoint domain)

  • data-method: Optional, defaults to POST. Accepts POST, PUT, PATCH, and DELETE

Using forms

Need to collect multiple pieces of data? Forms are your friend! They use standard HTML form attributes.

<form method="put" action="https://api.yoursite.com/users/...">
  
</form>

Working with checkboxes

Checkboxes in Fernand are smart. They can handle both single confirmations and multiple selections.

Single confirmation

<input type="checkbox" name="agree" value="yes" />

This generates: {"agree": true} when checked, false when unchecked.

Multiple selection

<input type="checkbox" name="options" value="A" />
<input type="checkbox" name="options" value="B" />

This generates: {"options": ["A", "B"]} when both are selected, or an empty array if none are selected.

Handling requests

When an agent triggers an action, here's what your server receives:

  • agent Email of the agent performing the action

  • conversation_id Fernand conversation ID

  • subject Conversation subject

  • contact Primary contact email

  • data Form data (if using a form)

Success is any 2xx response, and requests timeout after 3 seconds.

Managing permissions

Only agents with the "Execute" role can perform actions. Want to hide specific parts of your HTML template from unauthorized users? Use the {% if can_execute %} conditional statement.

{% if can_execute %}
  <button name="action" data-method="post" ...>Do something</button>
{% endif %}
Was this helpful?