> For the complete documentation index, see [llms.txt](https://docs.inova.us/v1/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.inova.us/v1/twilio-in-browser-call-plugin/actions-and-events.md).

# Actions & Events

## Actions & Events

The **Twilio Client** element exposes the element actions and events below. Add them from your Bubble workflows (**Element Actions › Twilio Client**, or the **Twilio Client** event triggers).

### Element Actions

#### Calling

* **Start Call** — Places an outgoing call. Inputs: **Call Number** (the destination number or client identity) and **Caller Number (optional)** (the caller ID to present). Blocked if a call is already active. To use a per-call caller ID, your Twilio voice function must read `event.appCallerId` (see [Getting Started](/v1/twilio-in-browser-call-plugin/getting-started.md)).
* **Hangup Call** — Disconnects the active call and resets the call states.
* **Mute** — Toggles mute on the active call. Reflected in the **Muted** state.
* **Send Digits** — Sends DTMF tones on the active call (e.g. to navigate IVR menus). Input: **Digits**. Requires an active call.

#### Incoming calls

* **Accept Incoming Call** — Accepts the current incoming call. Any existing active call is disconnected first.
* **Reject Incoming Call** — Rejects the incoming call; sets the incoming call status to `busy`.
* **Ignore Incoming Call** — Silently ignores the incoming call.

#### Device management

* **Register Device** — Registers the device so it can receive incoming calls.
* **Unregister Device** — Unregisters the device; it will no longer receive incoming calls.
* **Update token** — Fetches a fresh access token from your token URL and updates the device. Use with the **Token Expiring** event to keep sessions alive.
* **Reset Twilio Device** — Hangs up any active calls, destroys and reinitializes the device, and clears all states.
* **Destroy Device** — Destroys the device instance and releases its resources.

### Events

Add these as workflow event triggers (**Twilio Client › \<event>**).

| Event                      | Fires when                                                                                                           |
| -------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| **Incoming Call**          | An inbound call arrives. Read **Incoming Call Phone Number** / **Incoming Call Sid** to populate your UI.            |
| **Accepted Incoming Call** | The user accepts an incoming call.                                                                                   |
| **Call Status is Open**    | The active call is connected (answered). Useful to auto-start recording.                                             |
| **Update Call Id**         | The active call SID becomes available (read the **Call Id** state).                                                  |
| **Token Expiring**         | Fires \~10 seconds before the access token expires. Trigger your token-refresh event / **Update token** action here. |
| **Auto Rejected Call**     | An incoming call was auto-rejected because the user was busy (see the **Auto Reject** field).                        |
| **Twilio Error**           | The Twilio Client raised an error. Read the **Error** state for details.                                             |

### Server-side Action: Voice Access Token

Generates a Twilio Voice access token (JWT) from a Bubble API workflow, so the client can register without exposing your credentials. Expose it via a Bubble backend workflow and point the plugin's **accessTokenURL** at it (or supply the token directly via the **Sub Account Token** field).

**Inputs**

| Input                  | Description                                            |
| ---------------------- | ------------------------------------------------------ |
| Account Sid            | Your Twilio Account SID (`AC…`).                       |
| API Key                | Twilio API Key SID (`SK…`).                            |
| API Secret             | Twilio API Key secret.                                 |
| Application Sid        | Your TwiML Application SID.                            |
| Identity               | The client identity (usually your Agent Identifier).   |
| Allow Incoming Calls   | Whether the token grants incoming calls (default yes). |
| Time to live (Seconds) | Token lifetime in seconds (default 3600).              |

**Returns:** `Identity` (text) and `Token` (text — the signed JWT).

{% hint style="warning" %}
Use an **API Key SID/Secret** (`SK…`), not your Auth Token, or Twilio will reject the token with error **31202**. See Troubleshooting.
{% endhint %}
