createPost Documentation
Purpose
This node is designed to facilitate the creation of posts within a specified platform, leveraging an integration with the Meta Threads API. This functionality allows users to generate content by providing text and optional media, which will be posted on their behalf. The primary objective of createPost is to streamline the process of sharing updates, announcements, or any kind of communication within the Meta Threads ecosystem.
Settings
This node accepts various settings, detailed as follows:
1. text
- Input Type: String
- Description: This setting defines the main content of the post. It is a required field, meaning the function will not execute successfully without it. Changing the value of
textdirectly affects the message that will be published; if left empty, an error will be returned indicating that this field is mandatory. - Default Value: None (This field is required).
2. mediaType
- Input Type: String (Enum: TEXT, IMAGE, VIDEO)
- Description: This setting specifies the type of media associated with the post. It can take values such as "TEXT" for purely textual content, "IMAGE" for posts that include images, or "VIDEO" for those that include video content. Modifying this value will change how the post is treated by the receiving platform. For instance, setting it to "IMAGE" when uploading an image will ensure the correct formatting and handling of the post.
- Default Value:
TEXT.
3. imageUrl
- Input Type: String (URL)
- Description: This setting accepts a URL that points to an image file to be included with the post. If provided along with a media type of "IMAGE", the image will be displayed in the post. If left empty or not applicable, it will default to undefined and no image will be included. Care should be taken to ensure the URL is valid to avoid errors.
- Default Value: None (undefined if not provided).
4. videoUrl
- Input Type: String (URL)
- Description: Similar to
imageUrl, this setting accepts a URL pointing to a video file intended to accompany the post. If specified, it must correspond with the media type set to "VIDEO". If this setting is empty, it will default to undefined. Providing a valid URL is crucial for embedding the video correctly in the post. - Default Value: None (undefined if not provided).
How It Works
Upon invocation, the node first gathers input values from the inputs and config objects. It prioritizes inputs over config and assigns defaults if necessary.
-
Validation: The function checks for the presence of the
textinput. Iftextis absent, it returns an error message indicating that the text is required. -
Integration Setup: The function utilizes the integration connection to establish a connection to the Meta Threads API under the context provided.
-
Post Creation: It calls the
createThreadsPostmethod on the integration object, passing along necessary parameters liketext,mediaType,imageUrl, andvideoUrl. -
Error Handling: If any errors occur during the API call, they are caught and returned as an error message specifying that an internal error has occurred.
-
Output: If the post creation is successful, the output data returned from the API is handed back as an
output1field.
Use Cases & Examples
Use Cases
-
Social Media Management Tool: A business uses
createPostto automatically post updates, offers, or announcements on their Meta Threads profile from an analytics or management platform. -
Marketing Campaigns: A digital marketing agency can utilize
createPostto publish promotional content, including stunning visuals and engaging video clips, directly to target audiences. -
Event Notifications: An event organizer might implement this functionality in an application to announce upcoming events in real-time, supporting image and video previews.
Example Configuration
Scenario: A marketing agency wants to announce a new product launch by posting a text update with an accompanying promotional image.
Configuration Data:
{
"inputs": {
"text": "🚀 Exciting News! We're thrilled to launch our latest product. Check it out!",
"mediaType": "IMAGE",
"imageUrl": "https://example.com/images/product-launch.png",
"videoUrl": ""
},
"config": {
"text": "Fallback announcement text (not used in this case)",
"mediaType": "TEXT",
"imageUrl": "",
"videoUrl": ""
},
"context": {
"user": "exampleUserId"
}
}Explanation: In this example, the text field contains a compelling announcement about the product. The mediaType is set to "IMAGE" to indicate that there is an associated image. The imageUrl points to the promotional graphic, while videoUrl is left empty since no video content is necessary for this announcement. This setup ensures effective communication and media sharing on Meta Threads.