Generate text based on a prompt with this custom operation, powered by OpenAI.
Speaker 0: Here we have an articles collection with a title and a piece of content. We're gonna generate a social post, a social text right here, but I'm also gonna get to show you the other prompts that are available as well as the advanced usage mode. So let's go ahead and create a new flow, and we'll call this writer. We're gonna do this based on a manual flow trigger, so you click a button in the sidebar. We'll make that available on the article item pages.
Now this will only return when triggered, the ID. So first thing we wanna do is read the whole item so we can get the content. So we will read data from the content. Including the content. Now, we're gonna use the ai writer operation.
Let's take a little look at it together. Firstly, you need to provide an OpenAI API key. You select the GPT model, each of these having different characteristics around speed and cost, and, of course, the quality of the output, we'll use GPT 4. And you can use one of our selected prompts, fix spelling and grammar, short social post, make longer, make shorter, create an SEO description, or a custom prompt. On top of all of that, you can also use this messages mode here in order to utilize, like, multi step prompt engineering where you can give it kind of a history of messages as either the system, the assistant, or the user, and then your message will come in after all of that.
Really good for powerful prompt engineering. But for now, we'll just create a short social post. So we're gonna pass into this last dot content, and we're gonna use our built in prompt short social post. Let's go ahead and see what this returns. So we'll go ahead here.
We'll go back to our item, and we'll run the writer operation. So that's going off. It's doing its work, but, of course, we've not told it to save back to the item. So that is the end, but now we get to see in the logs what was actually returned. We see here the text is indeed returned.
So what we can do is we can add on to the end of this and update data operation. We will update the article, which triggered this flow once again. So trigger dot body dot keys 0 and we are gonna update the social text property with the value of last like so. And that's everything we need to do. Of course, the flexibility comes in the configuration, the custom prompts, and indeed the multi step prompt engineering that is available to you.
For now, if we click this manual prompt and we wait a few seconds, we should receive a much shorter I mean, this is, like, a fairly long piece here. It's a transcription from a podcast. That is a social post that we can go ahead and share. So that's how the AI writer operation works. I hope you find it useful.
I'm sure you can see the many many many utilizations of it, and, yeah, thank you so much for joining me. I'll see you in the next video!