Skip to content

Instantly share code, notes, and snippets.

Created February 21, 2023 16:21
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
how to add image generation to your chatbot

You should have four flow variables :

peopleAmount (string type) peopleAction (string type) imageStyle (string type) outputUrls (array type)

After creating your prompt (which saves the answers to the first three variables), add this code to the next node to get the urls of the images. They will be stored to outputUrls.

Make sure to replace YOUR_OPENAPI_KEY with your openai api key.

const endpoint = ''

const inputData = JSON.stringify({
  prompt: `There are ${workflow.peopleAmount} people. They are ${workflow.peopleAction}. ${workflow.imageStyle}`,
  n: 2,
  size: '1024x1024'

const config = {
  method: 'post',
  url: '',
  headers: {
    'Content-Type': 'application/json',
    Authorization: 'Bearer YOUR_OPENAPI_KEY'
  data: inputData,
  withCredentials: false

const result = await axios(config)
const { data } = result

workflow.outputUrls =

after the code block, you can add a content element, selecting carousel as the type.

Your carousel should have two cards, with the "Image" fields set to : {{workflow.outputUrls[0].url}} (for the first) {{workflow.outputUrls[1].url}} (for the second)

That's it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment