cs-icon.svg

ChatGPT Use Cases

The Contentstack Automate ChatGPT Connector integrates OpenAI's ChatGPT with Contentstack's content management system, allowing users to create high-quality AI-generated content directly within Contentstack. This streamlines content creation, enhances digital experiences, and offers two automation use cases for translating text and generating image URLs.

Below are two distinct ChatGPT automation use cases:

  1. For translating a specified string into a chosen language upon trigger invocation via the Function Calling action.
  2. For generating an image URL via the DALL-E 3 Image Generator action, which can then be utilized to create an asset in Contentstack.

Prerequisites

To use the ChatGPT connector, you first need to add your ChatGPT account and authorize it with a valid API Key and Organization ID.

Generate API Key and Get Organization ID from the OpenAI platform

To generate an API Key and Organization ID in your OpenAI platform account, follow the steps given below:

  1. Log in to your OpenAI platform account.
  2. Once you log in, you will be navigated to the API keys section as shown below. Click the + Create new secret key button to generate a new API Key.
    Create_New_Secret_key.png
  3. On the Create new secret key modal, enter a Name (Optional) and select the appropriate Permissions. Click the Create secret key button to generate a new secret key.
    Create_Secret_Key_Popup.png

    An API Key gets generated. Copy it to your clipboard and click the Done button to close the pop-up.

    Copy_secret.png

    Note: Since the API Key is confidential, it is displayed only once. If you do not copy it to your clipboard, you will need to create a new secret key.

  4. We will now see how to get the Organization ID. So from the left navigation panel, click Settings, and you will get the Organization ID.

    Copy the organization ID to your clipboard and paste it in the Organization ID field.

    Note: Make sure you save the API Key and Organization ID to your clipboard, as these will be used to connect your ChatGPT account to Automate in the next step.

Connect your ChatGPT Account to Automate

Let’s take a look at how to add your ChatGPT account using the Organization ID and API Key generated above. To do so, follow the steps given below:

  1. Click Configure Action Step from the left navigation panel.
  2. Click Action Step to configure third-party services.
  3. Within the Configure Action Step, click the ChatGPT connector.
    Select_Connector.png
  4. Under Choose an Action tab, select any one action from the list. Here we are selecting the Chat action.
    Chat_Action.png
  5. On the Configure Action page, click the + Add New Account button to add your ChatGPT account.
    Add_Chat_Account.png
  6. In the Authorize modal, enter a Title. Enter the API Key and Organization ID retrieved in the Generate API Key and get Organization ID from the OpenAI Platform step from your OpenAI platform account. Click the Authorize button.
    image26.png

Once done, you can go ahead and set up your ChatGPT account.

Use Case 1: Translate the Response using Function Calling Action based on Sub Automation

Let’s see an example to understand the use of the Function Calling and Function Calling Response action.

In this use case, we will cover a scenario where, if a user hits a HTTP trigger URL, then a translated response will be shown.

Here, we configure the Function Calling action to add different sub automations created in a project. ChatGPT analyses and returns the response based on the most precise sub automation.

In the next step, after configuring the Sub Automation action, the user gets the translated output which can be formatted in string format using the Function Calling Response action.

Let’s look at the setup in detail.

Set up the Connectors

  1. Configure HTTP Trigger

    1. From the left navigation panel, click Configure Trigger.
    2. Within the Configure Trigger step, click the HTTP connector.
    3. Select a Method, i.e. GET/POST.
      ChatGPT_Use_Case_Configure_Trigger_HTTP_Trigger
    4. Click the Proceed button.
    5. Click the Test Trigger button.
      ChatGPT_Use_Case_Configure_Trigger_Test_Trigger
    6. Click the Save and Exit button.
      Save_Trigger.png
  2. Configure Function Calling Action

    1. From the left navigation panel, click Configure Action Step .
    2. Then, click Action Step to configure third-party services.
    3. Within the Configure Action Step, click the ChatGPT connector.
    4. Under Choose an Action tab, select the Function Calling action.
    5. On the Function Calling Configure Action page, enter the details given below:
      1. Click + Add New Account button to connect your ChatGPT account as shown in the Connect your ChatGPT Account to Automate step.
      2. Select the API Model from the drop-down list to generate content for the chat responses.
      3. Under the Prompt Input section, click + Add Prompt Text button.
      4. Select the Role and enter the Input Query. You can enter an input query i.e., Translate to German language.
      5. Click + Add Sub Automation button to add multiple sub automations configured within your project. ChatGPT will return the most accurate response based on the sub automations.
        Chat_Fields.png
    6. Click Proceed.
    7. Click the Test Action button.
      ChatGPT_Use_Case_Configure_Function_Calling_Test_Action
    8. Click the Save and Exit button. You will see the response in the output.
      ChatGPT_Use_Case_Configure_Function_Calling_Save_Exit
  3. Configure Sub Automation Action

    1. Within the Configure Action Step, click the Sub Automation connector.
    2. Under Choose an Action tab, select the Sub Automation action.
    3. On the Sub Automation Configure Action page, enter the details given below:
      1. Select the Sub Automation from the drop-down. Select the Suggested Data Element(s) value from the drop-down. The Suggested Data Element(s) will suggest the function name from the previous step.
      2. In the Sub Automation Template, select the Suggested Data Element(s). The Suggested Data Element(s) will suggest the sub automation response.
        ChatGPT_Use_Case_Configure_Sub_Automation_Select_Fields
    4. Click the Proceed button.
    5. To test the configured action, click the Test Action button.
      ChatGPT_Use_Case_Configure_Sub_Automation_Test_Action
    6. Click the Save and Exit button. You will see the translated string in the output.
      ChatGPT_Use_Case_Configure_Sub_Automation_Save_Exit
  4. Configure Function Calling Response Action

    1. Within the Configure Action Step, click the ChatGPT connector.
    2. Under Choose an Action tab, select the Function Calling Response action.
    3. On the Function Calling Response Configure Action page, enter the details given below:
      1. Click + Add New Account button to connect your ChatGPT account as shown in the Connect your ChatGPT Account to Automate step.
      2. Select the API Model from the drop-down list for response predictions.

        Additional Resource: For more information about the API Models, please refer to ChatGPT API Models.

      3. In the Function Calling Response field, select the output of the Function Calling action from the previous step.
      4. In the Sub Automation Response field, select the output of the sub automation.
        Select_Fields.png
      5. Click the Show Optional Fields toggle button to use these optional fields.
        Show_Optional_Fields.png
    4. Click Proceed.
    5. Check if the details are correct. If yes, then click Test Action.
      Test_Action.png
    6. You will get the response(s). Once set, click Save and Exit. You see the response in a proper string format.
      ChatGPT_Use_Case_Function_Calling_Response_Save_and_Exit
  5. Configure Response Connector

    1. Within the Configure Action Step, click the Response connector.
    2. Under Choose an Action tab, select the Response action.
    3. On the Response Configure Action page, enter the details given below:
      1. Based on the results of your configured action, enter the Response Status.
      2. In the Response Body field, add the data you want to send as the response. Fetch the data received from the Function Calling Response action.
        ChatGPT_Use_Case_Configure_Response_Select_Field
      3. Additionally, you can add Response Headers to provide any additional information.
    4. Click Proceed.
    5. To execute and test the configured action, click Test Action.
      Test_Action.png
    6. On successful configuration, you can see the below output. Click Save and Exit.
      ChatGPT_Use_Case_Configure_Response_Save_Exit
  6. You can check the response by activating the automation and visiting the HTTP webhook URL configured in the trigger step.

Use Case 2: Generate an Image using the DALL-E 3 Image Generator Action

Let’s see an example to understand the use of the DALL-E 3 Image Generator action.

In this use case, we will cover a scenario where, if a user creates an entry in Contentstack, the entry gets updated with the image generated via the DALL-E 3 Image Generator.

Creating a new entry triggers the automation, and the DALL-E 3 Image Generator generates an image based on the entry title fetched from the Entry trigger step. It generates an image URL based on the title.

In the next step, configure the Create an Asset action and fetch the image generated in the previous step. An asset is created in the Contentstack Assets module.

Once the asset is created, configure the Update an Entry action. Fetch the asset UID in the Entry Data field to update the entry with the image generated.

Let’s look at the setup in detail.

Set up the Connectors

  1. Configure Entry Trigger

    1. Within the Configure Trigger step, click the Contentstack connector.
    2. Under Choose Trigger tab, select the Entry trigger.Select_Entry_Trigger
    3. Add your Contentstack account. For more information, refer to the Contentstack Trigger documentation.
    4. In the Select an Event drop-down, choose the Entry Created event from the list of events.
    5. Select a Stack, and a Branch from the Lookup drop-down.Select_Trigger_Fields.png
    6. Once done, click Proceed.
    7. Click Test Trigger to test the configured trigger.Test_Trigger

      Note: You can specify trigger conditions that will determine whether the complete automation should run or not. The automation and conditional path will not be carried out if the trigger conditions are not satisfied. You can see the updated list of executions in the Execution Log section.

    8. On successful configuration, you can see the below output. Click Save and Exit.Save_Exit_Button
  2. Configure ChatGPT Connector

    1. Within the Configure Action Step, click the ChatGPT connector.
    2. Under Choose an Action, select the DALL-E 3 Image Generator action.
    3. On the Function Calling Configure Action page, enter the details given below:
      1. Click + Add New Account button to connect your ChatGPT account as shown in the Connect your ChatGPT Account to Automate step.
      2. Provide the Prompt Text to generate an image response.

        For our use case, provide the following prompt text as shown below: “Create an image for the Blog title - ” followed by the entry title fetched from the previous Entry trigger step.

      3. In the Select Image Size drop-down, select the resolution for the image generation from the drop-down list. This will generate an image in the defined size.
      4. In the Select Style drop-down, select the style for the image generation from the drop-down list. By default, the image is generated in Vivid style.
      5. In the Select Quality drop-down, select the quality for the image generation from the drop-down list. By default, the image is generated in Standard quality. Select_Fields.png
    4. Click Proceed.
    5. Check if the details are correct. If yes, then click Test Action.Test_Action.png
    6. You will get the following response. Once set, click Save and Exit.Save_Exit_button.png
  3. Configure Create an Asset Action

    1. Within the Configure Action Step, click the Contentstack connector.
    2. Under Choose an Action tab, select Create an Asset action.
    3. On the Create an Asset Configure Action page, enter the details given below:
      1. Click + Add New Account button to connect your Contentstack account.

        Additional Resource: For more information, refer to the Contentstack Management documentation.

      2. Select a Stack from the Lookup list and enter a Title for the asset. Fetch the entry title from the previous step as shown below. This will create an asset with the same name as the entry.
      3. Specify a File Name for the asset, such as ‘vacation.png’ or ‘vacation.jpeg’. Create_an_Asset_Field_1.png
      4. Select the Input URL of the image fetched from the previous step, i.e., DALL-E 3 Image Generator action step and specify a suitable Description for the asset.Create_an_Asset_Field_2.png
      5. Optionally, enable the Show Optional Fields toggle button to display the Select Folder field. In the Select Folder drop-down, choose a destination folder to create an asset in it.
    4. Once done, click Proceed.
    5. Click Test Action to test the configured action. Test_Action
    6. On successful configuration, you can see the below output. Click Save and Exit. Save_Exit.png
  4. Configure Update an Entry Action

    1. Within the Configure Action Step, click the Contentstack connector.
    2. Under Choose an Action tab, select Update an Entry action.
    3. On the Update an Entry Configure Action page, enter the details given below:
      1. Click + Add New Account button to connect your Contentstack account.

        Additional Resource: For more information, refer to the Contentstack Management documentation.

      2. Select a Stack, Branch, Content Type, and Entry from the Lookup list.

        You can fetch the UIDs for all the previously configured automation steps directly from the Suggested Data Element(s) list.

        Update_Entry.png

        Note: By default, the main branch is selected (even if the Branch field is empty).

      3. In the Entry Data field, you can add a predefined schema template for your entry data. This will add a structure to provide your entry data in a particular format for different fields.

        Note: You must configure the entry data for JSON Rich Text Editor, Custom, and Experience Container fields manually.

        For our use case, provide the asset UID created in the Create an Asset step to add the image in the entry.

        Update_Entry_2.png

        Note: Enter the data in JSON format only.

      4. Optionally enable the Show Optional Fields toggle button to display additional fields. Select the Locale and check the Include branch checkbox to fetch these details in addition to the entry details.
    4. Once done, click Proceed.
    5. Click Test Action to test the configured action.Test_Action
    6. On successful configuration, you can see the below output. Click Save and Exit.Save_Exit_buttton.png
    7. Navigate to your entry and refresh the page to see the updated entry.Final_Output.png
Was this article helpful?
^