Docs
Services
Voiceflow.service

Voiceflow Service

services.voiceflow_service.create_transcript(sessionID: str, projectID, device, oss, browser)

Creates a transcript record for a session in the Voiceflow database.

  • Parameters:
    • sessionID (str) – The session identifier.
    • projectID – The project identifier associated with the session.
    • device – The type of device used in the session.
    • os – The operating system used during the session.
    • browser – The browser used during the session.
  • Returns: The response from the Voiceflow API as a JSON object after creating the transcript.
  • Return type: dict

NOTE

Calls get_assistant_session to retrieve session details, and get_project_headers for necessary request headers.

services.voiceflow_service.delete_state(user_id: str)

Deletes a user’s session state in the Voiceflow runtime.

  • Parameters: user_id (str) – The user identifier whose session state is to be deleted.
  • Returns: The API response as a JSON object after deleting the state.
  • Return type: dict

NOTE

Calls get_dialog_headers to fetch headers needed for the HTTP request.

services.voiceflow_service.fetch_state(user_id: str)

Fetches the current state of a session from the Voiceflow API.

  • Parameters: user_id (str) – The user identifier for which the session state is retrieved.
  • Returns: The current state of the user’s session as a JSON object.
  • Return type: dict

NOTE

Uses get_dialog_headers to obtain headers for the HTTP request.

services.voiceflow_service.post_button(user_id: str, button_id: str)

Simulates a button press in a Voiceflow session by sending a button action type.

  • Parameters:
    • user_id (str) – The user identifier for the Voiceflow session.
    • button_id (str) – The identifier of the button that is being “pressed”.
  • Returns: The response from the Voiceflow API after processing the button press.
  • Return type: dict

NOTE

Calls get_dialog_headers for request headers and handle_response to manage the API response.

services.voiceflow_service.post_launch_request(sessionID: str)

Sends a launch request to initiate a session with a Voiceflow runtime environment.

  • Parameters: sessionID (str) – The session identifier for the Voiceflow runtime.
  • Returns: The response from the Voiceflow API after processing the launch request.
  • Return type: dict

NOTE

This function utilizes get_dialog_headers to retrieve the necessary headers for the request.

services.voiceflow_service.post_text(user_id: str, text: str)

Sends a text input to the Voiceflow API to simulate a user’s text message in the session.

  • Parameters:
    • user_id (str) – The user identifier for the Voiceflow session.
    • text (str) – The text input to be sent to the session.
  • Returns: The response from the Voiceflow API after processing the text input.
  • Return type: dict

NOTE

Utilizes get_dialog_headers to get the necessary headers and handle_response to process the API response.

services.voiceflow_service.retrieve_transcripts()

Retrieves transcripts from both the Voiceflow API and local database, and transforms their names for unified presentation.

  • Returns: A JSON object containing the combined list of transcripts or an error message.
  • Return type: JSON or None

NOTE

Uses get_all_transcripts to fetch transcripts from the local database and transform_transcript_names to standardize transcript names before returning them.

services.voiceflow_service.update_variable(user_id: str, key: str, value: str)

Updates a variable in the Voiceflow runtime for a specific user session.

  • Parameters:
    • user_id (str) – The user identifier in the Voiceflow session.
    • key (str) – The name of the variable to update.
    • value (str) – The new value to set for the variable.
  • Returns: Confirmation message indicating successful update of the variable.
  • Return type: str

NOTE

Utilizes get_dialog_headers to obtain the necessary headers for the PATCH request.