### Answer
To have an AI agent run a function before initiating a transfer in Retell AI, you'll need to add multiple tools to your agent and update your prompt to specify the sequence.
## For Single/Multi Prompt Agents
1.
Add your custom function tool first - Add whatever function you need to run before the transfer [(1) ](
)
2.
Add the transfer tool - Click Add in the tools section and select either "Agent Transfer" or "Transfer Call" from the dropdown menu [(2) ](
) [(1) ](
)
3.
Update your prompt to specify the sequence - Include clear instructions like: "First call the [your_function_name] tool, then use the transfer_call tool to transfer to [destination]" [(1) ](
)
## For Conversation Flow
1.
Create a function calling node for your custom function [(3) ](
) [(4) ](
)
2.
Add an Agent Transfer Node or Call Transfer Node after your function node
3.
Connect the nodes so the function executes before the transfer
The key is in your prompt instructions - you need to explicitly tell the agent the order of operations. The agent will follow the sequence you specify in the prompt, calling your custom function first, then proceeding with the transfer [(2) ](
) [(1) ](
) .