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

# When Functions Run: Before, During and After a Call

> A custom function can run before the call starts, mid-conversation as a tool the agent calls, or after the call ends with the transcript in hand.

Every [custom function](/docs/integrations/custom-functions) has an **execution phase** that decides when it runs. Most functions are tools the agent calls mid-conversation, but a function can also run once at the start of a call or once at the end.

## The three phases

| Phase | When it runs | What it is for |
| - | - | - |
| **Before the call** | Once, when the call starts and before the agent speaks | Loading context the agent should know from the first word |
| **During the call** | Whenever the agent decides it is needed | Real-time lookups and actions, driven by the conversation |
| **After the call** | Once, when the call ends | Pushing results somewhere, with the transcript and summary available |

You assign functions to phases from the agent's **Functions** tab, under **Call Lifecycle** for the before and after phases, and under the tool list for during-call functions.

## Before the call

Use this for anything the agent should already know when it picks up — an account record, a delivery status, whether this caller is on a list.

The function runs once at the start of the call. Whatever it returns becomes available to the agent as context and as variables the workflow can use, so the agent can greet the caller with the information already in hand rather than looking it up mid-sentence.

<Tip>
  A pre-call lookup is usually a better experience than a mid-call one: the agent never has to pause to fetch something it could have had all along.
</Tip>

## During the call

This is the default. The function is exposed to the agent as a tool, and the agent calls it when the conversation calls for it — looking up an order, checking availability, creating a ticket.

Because the caller is waiting, keep these fast. If an operation is slow and the result is not needed for the agent's next sentence, mark it **async** instead.

## After the call

Use this to push an outcome somewhere once the call is over. The function runs after the call ends, when the transcript, the summary, and any structured analysis are available.

Typical uses:

* Writing a record into an internal system
* Notifying a team about an outcome
* Triggering a follow-up process

<Note>
  Post-call functions and [webhooks](/docs/integrations/webhooks) cover similar ground. Use a webhook when you want the call data delivered to a system you control; use a post-call function when you want to act on the call from inside VoiceInfra's function system.
</Note>

## Choosing a phase

<CardGroup cols={2}>
  <Card title="Use before the call when" icon="clock">
    The agent should know something from the first word, and the value does not change during the call.
  </Card>

  <Card title="Use during the call when" icon="bolt">
    The caller's own words decide whether the action is needed, or the data must be current at that moment.
  </Card>

  <Card title="Use after the call when" icon="flag-checkered">
    The action needs the finished conversation — the transcript, summary, or extracted fields.
  </Card>

  <Card title="Use a webhook instead when" icon="webhook">
    You want the raw call record pushed to your own endpoint rather than acting on it inside VoiceInfra.
  </Card>
</CardGroup>

## Frequently asked questions

<AccordionGroup>
  <Accordion title="Can I assign more than one function to a phase?">
    Yes. You can assign multiple functions to the before and after phases, and as many tools to the during-call phase as you need.
  </Accordion>

  <Accordion title="What can a before-the-call function return?">
    Its response becomes context the agent can use, exposed to prompts and workflows as variables. Return structured JSON with clearly named fields so the agent can reference specific values.
  </Accordion>

  <Accordion title="What information is available to an after-the-call function?">
    The call has finished, so the transcript, the AI-generated summary, and any structured analysis are all available alongside the call's basic details.
  </Accordion>

  <Accordion title="Can a before or after function be used as a tool in a workflow?">
    No. Workflow tool nodes run mid-conversation, so they only accept during-call functions. Publishing tells you when this is the problem.
  </Accordion>

  <Accordion title="Do lifecycle functions count against plan limits?">
    Assigning them does not. Any API calls they make are yours, and any calls or messages they trigger are metered normally.
  </Accordion>
</AccordionGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.