Actions in Flyflow are predefined operations that an agent can perform during a call. These actions enable you to automate common tasks, such as forwarding calls or hanging up, based on the conversation context. By configuring actions for your agent, you can enhance the call handling capabilities and create a more dynamic and responsive experience for your users.

How Actions Work

When you create or update an agent in Flyflow, you have the option to define a set of actions that the agent can perform. Each action consists of a name, instructions, and optional parameters. The agent can trigger these actions during a call based on specific conditions or events, allowing for customized call flows and responses.

Supported Actions

Flyflow currently supports the following actions during a call:

  1. forward: This action forwards the call to another phone number.
  2. hangup: This action terminates the call.

Forward Action

The forward action allows the agent to redirect the call to a specified phone number. This can be useful in scenarios where the call needs to be transferred to a different department, an external service, or another individual.

Parameters

  • name: The name of the action, which should be set to forward.
  • instructions: A description or instructions for the action.
  • forwarding_number: The phone number to which the call should be forwarded. This parameter is required for the forward action.

Example

{
  "name": "forward",
  "instructions": "Forward the call to the support team.",
  "forwarding_number": "+1234567890"
}

Hangup Action

The hangup action allows the agent to terminate the call. This action can be triggered when the conversation reaches its natural conclusion or when specific conditions are met that warrant ending the call.

Parameters

  • name: The name of the action, which should be set to hangup.
  • instructions: A description or instructions for the action.

Example

{
  "name": "hangup",
  "instructions": "End the call after providing the requested information."
}

Defining Actions for an Agent

When creating or updating an agent, you can specify the actions in the agent's configuration. The Actions field in the agent object should contain an array of action definitions, each specifying the name, instructions, and any required parameters.

Example Request to Upsert an Agent with Actions

{
  "name": "Support Agent",
  "system_prompt": "Welcome to our support line. How can I assist you today?",
  "initial_message": "Thank you for calling.",
  "voice_id": "female-young-american-warm",
  "llm_model": "gpt-4o",
  "webhook": "https://your-webhook-url.com",
  "tools": [],
  "filler_words": false,
  "actions": [
    {
      "name": "forward",
      "instructions": "Forward the call to the support team.",
      "forwarding_number": "+1234567890"
    },
    {
      "name": "hangup",
      "instructions": "End the call after providing the requested information."
    }
  ]
}

In this example, the agent is configured with two actions: forward and hangup. The forward action will redirect the call to the specified phone number, and the hangup action will terminate the call based on the provided instructions.

Handling Actions in Your Application

To handle actions triggered by the agent, your application should be designed to receive and process webhook notifications from Flyflow. When an action is performed during a call, Flyflow will send an HTTP POST request to the specified webhook URL with details about the action and the associated call data.

Example Webhook Payload for an Action

{
  "event_type": "action_performed",
  "call_id": "abc123",
  "timestamp": "2023-06-08T10:30:00Z",
  "data": {
    "action_name": "forward",
    "action_instructions": "Forward the call to the support team.",
    "forwarding_number": "+1234567890"
  }
}

The payload includes the following fields:

  • event_type: The type of the event that triggered the webhook (action_performed).
  • call_id: The unique identifier of the call associated with the event.
  • timestamp: The timestamp indicating when the event occurred.
  • data: An object containing event-specific data.
    • For action events, the data object includes:
      • action_name: The name of the action that was performed.
      • action_instructions: The instructions or description of the action.
      • forwarding_number: The phone number to which the call was forwarded (for forward actions).

By processing these webhook notifications, you can implement custom logic and integrations based on the actions performed by the agent during a call.

Conclusion

Actions in Flyflow provide a powerful way to automate and customize call handling. By defining actions such as forward and hangup for your agents, you can create dynamic call flows that respond to specific conditions and events. Combined with Flyflow's webhook capabilities, actions enable you to build sophisticated integrations and automate workflows based on real-time call data.