Docs
Functions
Voiceflow.functions

Voiceflow Functions

voiceflow_functions.handle_buttons(buttons_response)

Extracts button data from a response segment and formats it into a list of dictionaries, each representing a button.

  • Parameters: buttons_response (dict) – A segment of the response data that contains buttons.
  • Returns: A list where each dictionary contains the ‘id’ and ‘name’ of a button.
  • Return type: list of dict

NOTE

This function is typically used to process and format button data as part of handling a larger API response in handle_response.

voiceflow_functions.handle_response(response)

Processes a response from an API and converts it into a structured dictionary format that categorizes different types of response elements such as text, choices, visuals, and cards.

  • Parameters: response (requests.Response) – The response object from a requests library call which is expected to contain JSON content.
  • Returns: A structured dictionary where each key corresponds to a block of the response with details on the type and content of the block, such as text messages, images, or choice buttons.
  • Return type: dict

NOTE

This function expects the response data to be in a specific format and includes error handling for specific error structures. It also calls handle_buttons to process any button elements within the response.