controller.controller_flask

This file contains the Controller class which controls the flow of the conversation while the user interacts with the agent using Flask.

Module Contents

Classes

ControllerFlask

Helper class that provides a standard way to create an ABC using

class controller.controller_flask.ControllerFlask

Bases: moviebot.controller.controller.Controller

Helper class that provides a standard way to create an ABC using inheritance.

initialize(user_id: str) None

Initializes structs for a new user.

Parameters

user_id – User id.

start_conversation(user_id: str, restart=False) moviebot.controller.http_data_formatter.HTTP_OBJECT_MESSAGE

Starts conversation with agent and sends instructions to user.

Parameters
  • user_id – User id.

  • restart – Whether or not to restart the agent.

Returns

Object with start message to send to the server.

movie_info(movie_id: str, user_id: str) None

Retrieves relevant movie info from database for selected user.

Parameters
  • movie_id – Movie id.

  • user_id – User id.

execute_agent(configuration: Dict[str, Any]) None

Runs the conversational agent and executes the dialogue by calling the basic components of IAI MovieBot.

Parameters

configuration – Configuration for the agent.

restart(user_id: str) Callable

Restarts agent for this user.

get_movie_id(response: str) str

Retrieves movie id from agent response string.

Parameters

response – Agent response.

Returns

Movie id.

continue_dialogue(user_id: str, payload: str) None

Continues dialogue with the agent. Updates movie info.

Parameters
  • user_id – User id.

  • payload – User payload.

accept_license(user_id: str, b_accept: bool = True) Callable

User accepts license agreement. Data for this user is stored in conversation history.

Parameters
  • user_id – User id.

  • b_accept – Whether or not the user accepts the license agreement. Defaults to True.

reject_license(user_id: str) Callable

User rejects license agreement. Data for this user is not stored in conversation history.

Parameters

user_id – User id.

record(user_id: str, payload: str) None

Records user conversation if user has accepted privacy policy.

Parameters
  • user_id – User id.

  • payload – User payload.

delete_data(user_id: str) moviebot.controller.http_data_formatter.HTTP_OBJECT_MESSAGE

Deletes stored conversation history for user.

Parameters

user_id – User id.

send_message(user_id: str, payload: str) moviebot.controller.http_data_formatter.HTTP_OBJECT_MESSAGE

Sends template, buttons or text based on current agent options.

Parameters
  • user_id – User id.

  • payload – User payload.

Returns

Object with message to send to the server.

run_method(user_id: str, payload: str) Union[bool, Callable]

Runs methods for specific user inputs.

Parameters
  • user_id – User id.

  • payload – User payload.

Returns

Output of the payload action if possible.

exit(user_id: str) moviebot.controller.http_data_formatter.HTTP_OBJECT_MESSAGE

Ends conversation and deletes user id from agent.

Parameters

user_id – User id.

instructions(user_id: str) moviebot.controller.http_data_formatter.HTTP_OBJECT_MESSAGE

Creates utterance with usage instructions.

The instructions are sent when the conversation starts and when ‘/help’ is received.

Parameters

user_id – User id.

Returns

Object with instructions message to send to the server.

storage_instructions(user_id: str, b_accept: bool) moviebot.controller.http_data_formatter.HTTP_OBJECT_MESSAGE

Instructions for deleting stored conversation history.

Parameters
  • user_id – User id.

  • b_accept – Whether or not the user accepts the license agreement.

Returns

Object with storage information to send to the server.

privacy_policy(user_id: str) moviebot.controller.http_data_formatter.HTTP_OBJECT_MESSAGE

Creates utterance with policy.

Parameters

user_id – User id. Defaults to None.

Returns

Object with privacy message to send to the server.

greetings() str

Returns a greeting message.