Skip to main content

Overview

The AiContentGenerator component provides a UI for generating, editing, and fixing content using AI. It integrates with modal components to handle the AI interactions and provides options for customizing the generation parameters like tone, keywords, language, emojis, and hashtags. It can be used to add AI content generation capabilities to any input field or content area by wrapping the target element with this component.

Import

import AiContentGenerator from "@components/ai-content-generator/AiContentGenerator";

Usage Example

import React, { useState } from "react";
import AiContentGenerator from "@components/ai-content-generator/AiContentGenerator";
import { Button } from "@tag/tag-components-react-v4";

function AnotherComponentWithHandling() {
// This function receives the output from the AI generator/editor/fixer
const handleAIResult = (newContent) => {
console.log("AI Result applied:", newContent);
};

return (
<AiContentGenerator
defaultValue={content} // Pass the current content as defaultValue
sourceID="another-component"
handleAddToEditor={handleAIResult}
>
<Button>Generate/Edit with AI</Button>
</AiContentGenerator>
);
}

Props

PropTypeDescriptionDefault Value
defaultValuestringThe initial content value to be used for editing or fixing. If no value is given the generation modal will appear.
minOutputnumberMinimum limit for the number of words input.10
maxOutputnumberMaximum limit for the number of words input.100
tonebooleanEnables/disables the tone selection option in the generator modal.true
keywordsbooleanEnables/disables the keywords input option in the generator modal.true
languagebooleanEnables/disables the language selection option in the generator modal.false
emojisbooleanEnables/disables the emojis option in the generator modal.true
hashtagsbooleanEnables/disables the hashtags option in the generator modal.true
sourceIDanyAn identifier for the source of the content generation request.
handleAddToEditorfunctionCallback function to handle adding the generated/edited/fixed content to an editor.
disableTopicbooleanDisables the topic input field in the generator/edit modal.false
childrenReactNodeThe element that triggers the AI content generator functionality.

sourceID

The sourceID prop is used to identify the source of the content generation request. It is used to track the origin of the content generation request. plasee use one of the foloowing values:

ValueModuleDescription
1Campaign builderSubject line in Campaign builder
2SocialSocial Media post caption
3JourneyNot implemented yet
4SelectionNot implemented yet
5Ecast profileSubject line in Ecast profile
6Email builderEmail body builder