create_form
Generate a new Google Form with a specified title, description, and document tab title using user's Google email. Returns form ID and edit URL for immediate access.
Instructions
Create a new form using the title given in the provided form message in the request.
Args:
user_google_email (str): The user's Google email address. Required.
title (str): The title of the form.
description (Optional[str]): The description of the form.
document_title (Optional[str]): The document title (shown in browser tab).
Returns:
str: Confirmation message with form ID and edit URL.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| description | No | ||
| document_title | No | ||
| service | Yes | ||
| title | Yes | ||
| user_google_email | Yes |
Implementation Reference
- gforms/forms_tools.py:19-65 (handler)The handler function for the 'create_form' tool. It is registered via the @server.tool() decorator and implements the logic to create a new Google Form using the Google Forms API, handling title, description, and document_title parameters.@server.tool() @handle_http_errors("create_form", service_type="forms") @require_google_service("forms", "forms") async def create_form( service, user_google_email: str, title: str, description: Optional[str] = None, document_title: Optional[str] = None ) -> str: """ Create a new form using the title given in the provided form message in the request. Args: user_google_email (str): The user's Google email address. Required. title (str): The title of the form. description (Optional[str]): The description of the form. document_title (Optional[str]): The document title (shown in browser tab). Returns: str: Confirmation message with form ID and edit URL. """ logger.info(f"[create_form] Invoked. Email: '{user_google_email}', Title: {title}") form_body: Dict[str, Any] = { "info": { "title": title } } if description: form_body["info"]["description"] = description if document_title: form_body["info"]["document_title"] = document_title created_form = await asyncio.to_thread( service.forms().create(body=form_body).execute ) form_id = created_form.get("formId") edit_url = f"https://docs.google.com/forms/d/{form_id}/edit" responder_url = created_form.get("responderUri", f"https://docs.google.com/forms/d/{form_id}/viewform") confirmation_message = f"Successfully created form '{created_form.get('info', {}).get('title', title)}' for {user_google_email}. Form ID: {form_id}. Edit URL: {edit_url}. Responder URL: {responder_url}" logger.info(f"Form created successfully for {user_google_email}. ID: {form_id}") return confirmation_message
- gforms/forms_tools.py:19-19 (registration)Registration of the 'create_form' tool using the @server.tool() decorator.@server.tool()
- gforms/forms_tools.py:22-37 (schema)Input schema defined by function parameters with type hints and detailed docstring describing args and return type.async def create_form( service, user_google_email: str, title: str, description: Optional[str] = None, document_title: Optional[str] = None ) -> str: """ Create a new form using the title given in the provided form message in the request. Args: user_google_email (str): The user's Google email address. Required. title (str): The title of the form. description (Optional[str]): The description of the form. document_title (Optional[str]): The document title (shown in browser tab).