twist_threads_add
Create a new discussion thread in a Twist channel with title, content, attachments, and customizable notifications for users and groups.
Instructions
Adds a new thread to a channel.
Args: channel_id: The id of the channel title: The title of the new thread content: The content of the new thread actions: List of action buttons to the new thread attachments: List of attachments to the new thread direct_group_mentions: The groups that are directly mentioned direct_mentions: The users that are directly mentioned groups: The groups that will be notified recipients: An array of users that will be attached to the thread or "EVERYONE" send_as_integration: Displays the integration as the thread creator temp_id: The temporary id of the thread
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| channel_id | Yes | ||
| title | Yes | ||
| content | Yes | ||
| actions | No | ||
| attachments | No | ||
| direct_group_mentions | No | ||
| direct_mentions | No | ||
| groups | No | ||
| recipients | No | ||
| send_as_integration | No | ||
| temp_id | No |
Implementation Reference
- src/threads.py:85-125 (handler)Handler function that implements the twist_threads_add tool by calling the Twist API endpoint 'threads/add' with the provided parameters.def twist_threads_add( ctx: Context, channel_id: int, title: str, content: str, actions: Optional[List[Dict[str, Any]]] = None, attachments: Optional[List[Dict[str, Any]]] = None, direct_group_mentions: Optional[List[int]] = None, direct_mentions: Optional[List[int]] = None, groups: Optional[List[int]] = None, recipients: Optional[Union[List[int], str]] = None, send_as_integration: Optional[bool] = None, temp_id: Optional[int] = None ) -> Union[str, Dict[str, Any]]: """Adds a new thread to a channel. Args: channel_id: The id of the channel title: The title of the new thread content: The content of the new thread actions: List of action buttons to the new thread attachments: List of attachments to the new thread direct_group_mentions: The groups that are directly mentioned direct_mentions: The users that are directly mentioned groups: The groups that will be notified recipients: An array of users that will be attached to the thread or "EVERYONE" send_as_integration: Displays the integration as the thread creator temp_id: The temporary id of the thread """ all_params = locals() token = ctx.request_context.lifespan_context.twist_token params = {k: v for k, v in all_params.items() if k != 'ctx' and v is not None} try: logger.info(f"Adding thread to channel ID: {channel_id}") thread_data = twist_request("threads/add", params=params, token=token, method="POST") logger.info(f"Added thread with ID: {thread_data.get('id')}") return thread_data except Exception as error: logger.error(f"Error adding thread: {error}") return f"Error adding thread: {str(error)}"