> ## Documentation Index
> Fetch the complete documentation index at: https://docs.diga.io/llms.txt
> Use this file to discover all available pages before exploring further.

# The Diga Piece

> Complete reference for Diga triggers and actions to connect workflows with calls

## What is the Diga Piece?

The Diga piece is the component that connects your workflows with your agent calls. It provides triggers to react to call events and actions to interact with Diga's telephony system.

<CardGroup cols={2}>
  <Card title="Triggers" icon="zap">
    Start a workflow when a call event occurs
  </Card>

  <Card title="Actions" icon="play">
    Execute operations within a running workflow
  </Card>
</CardGroup>

## Triggers

### Pre-Call

Activates when a call starts, **before the agent greets**. This is the trigger for [pre-call workflows](/en/build/flows/pre-call-flows). The agent waits for the flow's output and uses it to customize the conversation before saying its first word.

<Warning>
  A pre-call flow **must end with the [Return Call Data](#return-call-data) action** so the agent receives the prompt addition and dynamic variables. The generic **Respond** piece will not work — its response never reaches the agent.
</Warning>

#### Configuration

| Field                     | Description                                                                                                                                                               |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Timeout (seconds)**     | Maximum time the agent waits for this flow before continuing (or aborting). Defaults to **30 seconds** and is capped at **55 seconds**.                                   |
| **Abort call on failure** | If enabled, the call is hung up when the flow fails, times out, or returns invalid data. Disabled by default, in which case the call continues without the flow's output. |

#### Data received

When this trigger fires, the workflow receives the data of the starting call, which you can use to look up the right record:

| Field               | Description                               |
| ------------------- | ----------------------------------------- |
| `call_id`           | Unique call identifier                    |
| `type`              | Call type (`inbound` or `outbound`)       |
| `phone_number`      | Contact's phone number                    |
| `contact_id`        | Contact identifier                        |
| `agent_id`          | Agent identifier                          |
| `start_time`        | Start date and time                       |
| `dynamic_variables` | Dynamic variables already set on the call |

<Tip>
  See [Pre-call Flows](/en/build/flows/pre-call-flows) for the full guide, including how to build, assign, and gate calls with these flows.
</Tip>

***

### Call Finished

Activates automatically when a call ends. This is the main trigger for **post-call** workflows.

#### Data received

When this trigger fires, the workflow receives all call information:

| Field               | Description                              |
| ------------------- | ---------------------------------------- |
| `call_id`           | Unique call identifier                   |
| `status`            | Final call status                        |
| `duration`          | Duration in seconds                      |
| `type`              | Call type (`inbound` or `outbound`)      |
| `end_reason`        | Reason the call ended                    |
| `phone_number`      | Contact's phone number                   |
| `contact_id`        | Contact identifier                       |
| `agent_id`          | Agent identifier                         |
| `start_time`        | Start date and time                      |
| `end_time`          | End date and time                        |
| `dynamic_variables` | Dynamic variables passed to the agent    |
| `messages`          | Complete message history (transcription) |

Each message in the `messages` array includes:

* `role` — Who spoke (`user` or `assistant`)
* `content` — The message text
* `created_date` — When it was sent

<Tip>
  You can use any of these fields in your workflow actions. For example, insert the full transcription into an email or send the duration to a spreadsheet.
</Tip>

#### Configuration

This trigger requires no additional configuration. You just need to [assign the workflow to an agent](/en/build/flows/assign-agents) for it to activate.

<Tip>
  See [Post-call Flows](/en/build/flows/post-call-flows) for the full guide on building and assigning these flows.
</Tip>

***

### Function Call

Activates during a call when the agent decides to execute a function. This is the trigger for **during-call** workflows. The agent uses it as another tool, similar to [integrations](/en/build/integrations/introduction).

<Tip>
  See [During-call Flows](/en/build/flows/during-call-flows) for the full guide on building and assigning these flows.
</Tip>

#### Configuration

| Field                    | Description                                                                                                                                                  |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Function description** | Natural language instruction telling the agent when to use this function. Example: "Use this function when the user wants to check appointment availability" |
| **Parameters**           | Data the agent should extract from the conversation. For each parameter you define: name, data type, whether it's required, and a description                |
| **User confirmation**    | Whether the agent should ask for confirmation before executing                                                                                               |

#### Parameters

Parameters define what information the agent extracts from the conversation to send to the workflow. For example, for a "Check availability" workflow:

| Parameter | Type | Required | Description                        |
| --------- | ---- | -------- | ---------------------------------- |
| `date`    | Text | Yes      | The date to check availability for |
| `service` | Text | No       | The type of service requested      |

The agent automatically extracts these values from the conversation context and sends them to the workflow.

##### Value source

Each parameter has a **Value Source** that decides where its value comes from:

* **Extracted by AI** (default): the agent extracts the value from the conversation, using the parameter's description to know what to look for.
* **Dynamic Variable**: the value is taken directly from a [dynamic variable](/en/build/agents/dynamic-variables) instead of being extracted. When you pick this option, enter the **Dynamic Variable Name** (without braces, e.g. `customer_id`). The agent is not asked for this parameter — Diga fills it in automatically from the call's variables.

Use **Dynamic Variable** for data you already have (set via the API or a [pre-call flow](/en/build/flows/pre-call-flows)), so the agent doesn't have to ask for it again during the conversation. For a step-by-step and example, see [Filling parameters from dynamic variables](/en/build/flows/during-call-flows#filling-parameters-from-dynamic-variables).

#### Data received

| Field               | Description                       |
| ------------------- | --------------------------------- |
| `call_id`           | Identifier of the ongoing call    |
| `function_name`     | Name of the executed function     |
| `arguments`         | Parameters extracted by the agent |
| `agent_id`          | Agent identifier                  |
| `contact_id`        | Contact identifier                |
| `dynamic_variables` | Dynamic variables from the call   |
| `timestamp`         | Execution timestamp               |

#### How the agent waits

The agent **waits** for the workflow to finish and receives the response, then uses it to continue the conversation.

**Example**: Check appointment availability. The agent asks for the date, executes the workflow, waits for the response, and tells the user the available time slots.

**Important**: The workflow must include the **Return Response** action as the last step to send data back to the agent. The maximum wait time is 60 seconds.

<Warning>
  If the workflow takes more than 60 seconds or doesn't include the **Return Response** action, the agent will receive an error and continue the conversation without the data.
</Warning>

#### User confirmation

When you enable user confirmation, the agent explains to the user what action it's about to perform and asks for confirmation before executing the workflow. This is useful for sensitive actions like processing payments or making bookings.

**Example conversation:**

```
User: "I'd like to book an appointment for tomorrow at 10"
Agent: "Sure, I'll book an appointment for tomorrow Thursday at 10:00. Can you confirm?"
User: "Yes, go ahead"
Agent: [executes the workflow]
```

## Actions

### Make Call

Initiates an outbound call from a workflow. This action turns any workflow into a call trigger, allowing you to create automated campaigns or calls reactive to external events. Workflows built around this action are known as **call launcher** workflows.

#### Configuration

| Field                 | Description                                                                                      |
| --------------------- | ------------------------------------------------------------------------------------------------ |
| **From number**       | The Diga phone number the call will be made from. Selected from your project's available numbers |
| **To number**         | The number to call. Can be a fixed or dynamic value (data from a previous step)                  |
| **Agent version**     | The agent version that will handle the call (optional)                                           |
| **Dynamic variables** | Variables to pass to the agent during the call (optional)                                        |

#### Use cases

<AccordionGroup>
  <Accordion title="Lead follow-up">
    Connect a CRM trigger (new lead created) with the Make Call action to automatically contact new leads.

    ```
    Trigger: New lead in HubSpot
    → Action: Make call to lead's number
       - Agent: "Qualification agent"
       - Variables: lead name, source, product of interest
    ```
  </Accordion>

  <Accordion title="Appointment reminders">
    Use a schedule trigger to call clients and remind them of their appointments.

    ```
    Trigger: Schedule (24h before each appointment)
    → Action: Look up next day's appointments
    → Action: Make call to each contact
       - Agent: "Reminder agent"
       - Variables: appointment date, service, address
    ```
  </Accordion>

  <Accordion title="Post-form calls">
    Connect a webhook with the Make Call action to contact users who complete a web form.

    ```
    Trigger: Webhook (form completed)
    → Action: Make call to form's phone number
       - Agent: "Sales agent"
       - Variables: name, email, inquiry
    ```
  </Accordion>
</AccordionGroup>

***

### Return Response

Returns data to the agent during a call. This action is **required** in during-call workflows. It's the last step of the workflow and contains the information the agent needs to continue the conversation.

#### Configuration

| Field             | Description                                              |
| ----------------- | -------------------------------------------------------- |
| **Response type** | JSON or plain text                                       |
| **Content**       | The data to return. Can include data from previous steps |

#### Example

A workflow that checks appointment availability:

```
Trigger: Function Call (parameters: date, service)
→ Action: Query calendar API (HTTP request)
→ Action: Return Response
   - Type: JSON
   - Content: { "slots": ["10:00", "11:30", "15:00"], "service": "General consultation" }
```

The agent receives this data and tells the user: "I have availability at 10:00, 11:30, and 15:00 for a general consultation. Which would you prefer?"

***

### Return Call Data

Returns data to the agent **before the call starts**. This action is **required** as the last step of a [pre-call flow](/en/build/flows/pre-call-flows) — it's what sends the prompt and variables back to the agent so it can begin the conversation.

<Note>
  Don't confuse this with **Return Response**. Return Call Data runs at the *start* of a call (pre-call flows); Return Response runs *during* a call (during-call flows).
</Note>

#### Configuration

| Field                 | Description                                                                                                     |
| --------------------- | --------------------------------------------------------------------------------------------------------------- |
| **Prompt Addition**   | Text appended to the agent's system prompt for this call. May contain `{{variable}}` placeholders. Optional.    |
| **Dynamic Variables** | Key/value pairs merged into the call's dynamic variables. They override values set at the call level. Optional. |

#### Example

A pre-call flow that personalizes the agent based on a CRM lookup:

```
Trigger: Pre-Call
→ Action: Find contact in HubSpot (by phone number)
→ Action: Return Call Data
   - Prompt Addition: "You're speaking with a returning premium customer. Be attentive."
   - Dynamic Variables: { "customer_name": "Jane Doe", "plan_tier": "premium" }
```

The agent begins the call already knowing the caller's name and plan, and can use `{{customer_name}}` and `{{plan_tier}}` anywhere in its prompt, greeting, or path.

## Referencing Data Between Steps

In any action, you can use data from previous steps. Click on an input field to see the available data from all previous steps.

**Reference examples:**

* Trigger data: transcription, duration, function parameters
* Previous action data: API response, query result

This lets you build workflows where information flows naturally from one step to the next.

## Next Steps

<CardGroup cols={2}>
  <Card title="Create workflows" icon="plus" href="/en/build/flows/creating-workflows">
    Put these triggers and actions into practice by creating your first workflow.
  </Card>

  <Card title="Assign to agents" icon="link" href="/en/build/flows/assign-agents">
    Connect your workflows with agents to activate them.
  </Card>

  <Card title="Templates" icon="copy" href="/en/build/flows/templates">
    Use templates that already include the Diga piece configured.
  </Card>

  <Card title="Integrations" icon="plug" href="/en/build/integrations/introduction">
    Compare workflows with direct integrations in the agent.
  </Card>
</CardGroup>
