Back to n8n Workflows

Morpheus: Run AskRally From Custom GPT

Rhys Fisher Rhys Fisher

Describe your situation, complication, and question so you can let Morpheus decide which or your audience of AI personas is most relevant and what to ask them. Get a synthetic data driven recommendation delivered into a Google Sheet.

Morpheus: Run AskRally From Custom GPT n8n workflow diagram

Click to expand

Summarize in
OR

Overview

Morpheus is an AI agent that lives in n8n and can be triggered via HTTP, so you can bring him anywhere to help you navigate simulation. When given a situation, complication, and question, Morpheus looks through your AskRally account for relevant audience and runs a simulation before delivering you a synthetic data recommendation into a Google Sheet. 

🎯 Pro Tips & Secret Sauce

Create a Custom GPT

Name: Morpheus (Powered by AskRally)
Description: Describe your situation, complication, and question. Let Morpheus guide you through the simulation.
Instructions: You are an executive assistant automating simulation-based testing for your client. Your purpose is to take his queries and send the information to the webhook url provided in the schema. The data sent via the webhooks will be received in n8n, you will return the response of the webhook to the user.
Code Interpreter & Data Analysis: (togged on)

Custom Action
{
  "openapi": "3.1.0",
  "info": {
    "title": "Custom GPT Webhook",
    "description": "Sends situation, complication, and question data to a webhook endpoint. Optionally includes an email address for sending results later.",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "ADD YOUR N8N SERVER URL",
      "description": "Production server"
    }
  ],
  "paths": {
    "ADD YOUR N8N SERVER URL PATH": {
      "post": {
        "operationId": "sendWebhookData",
        "summary": "Send data to the webhook",
        "description": "Sends situation, complication, and question data. Optionally include an email address to receive the result asynchronously.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "situation": {
                    "type": "string",
                    "description": "The current situation the user is in."
                  },
                  "complication": {
                    "type": "string",
                    "description": "The challenge or complication involved in the situation."
                  },
                  "question": {
                    "type": "string",
                    "description": "The key question or decision the user needs help with."
                  }
                },
                "required": ["situation", "complication", "question"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Data successfully sent to the webhook"
          }
        }
      }
    }
  }
}

📋 Requirements

  • GPT credentials
  • Gsheet API authentication
  • Custom GPT setup
  • AskRally API key

🚀 n8n Workflow Template

{
  "active": true,
  "connections": {
    "Morpheus (by AskRally)": {
      "main": [
        [
          {
            "index": 0,
            "node": "Set Response",
            "type": "main"
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "index": 0,
            "node": "Morpheus (by AskRally)",
            "type": "ai_languageModel"
          }
        ]
      ]
    },
    "RallyChatTool": {
      "ai_tool": [
        [
          {
            "index": 0,
            "node": "Morpheus (by AskRally)",
            "type": "ai_tool"
          }
        ]
      ]
    },
    "RallyListAudiences": {
      "ai_tool": [
        [
          {
            "index": 0,
            "node": "Morpheus (by AskRally)",
            "type": "ai_tool"
          }
        ]
      ]
    },
    "Set Response": {
      "main": [
        [
          {
            "index": 0,
            "node": "Google Sheets",
            "type": "main"
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "index": 0,
            "node": "Morpheus (by AskRally)",
            "type": "ai_memory"
          }
        ]
      ]
    },
    "Think": {
      "ai_tool": [
        [
          {
            "index": 0,
            "node": "Morpheus (by AskRally)",
            "type": "ai_tool"
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "index": 0,
            "node": "Morpheus (by AskRally)",
            "type": "main"
          },
          {
            "index": 0,
            "node": "Respond With Gsheet",
            "type": "main"
          }
        ]
      ]
    }
  },
  "id": "gkc79JHjpHzMX6oN",
  "meta": {
    "instanceId": "7921b3cd29c1121b3ec4f2177acf06fe1f1325838297f593db7db4e9563eb98d",
    "templateCredsSetupCompleted": true
  },
  "name": "Morpheus (by AskRally)",
  "nodes": [
    {
      "id": "e7ef9614-a13b-436f-b646-2a3b5e5545e1",
      "name": "Webhook",
      "parameters": {
        "httpMethod": "POST",
        "options": {},
        "path": "99d46f82-2721-4768-8d13-3ff159a191c7",
        "responseMode": "responseNode"
      },
      "position": [
        140,
        -200
      ],
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "webhookId": "99d46f82-2721-4768-8d13-3ff159a191c7"
    },
    {
      "credentials": {
        "openAiApi": {
          "id": "5LyzIG7SUcgxGxlz",
          "name": "OpenAi account 2"
        }
      },
      "id": "d1ae7d61-ac05-437d-ab7d-38e2ff5dc893",
      "name": "OpenAI Chat Model",
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "position": [
        80,
        220
      ],
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2
    },
    {
      "id": "c63e251d-4c3f-47fe-864e-4dbca495bb98",
      "name": "Simple Memory",
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $(\u0027Webhook\u0027).item.json.headers[\"openai-conversation-id\"] }}"
      },
      "position": [
        240,
        220
      ],
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3
    },
    {
      "id": "4c089d58-7eaa-4b32-860c-8a4cb59c59ff",
      "name": "Think",
      "parameters": {
        "description": "Use this tool to perform internal reasoning or chain-of-thought reflection.\nIt does not retrieve external data or modify any state, but simply logs a detailed internal thought to guide next actions.\n\nUse it when:\n\nYou need to break down a complex problem\n\nYou\u0027re uncertain and want to reflect before acting\n\nYou want to clarify your reasoning for traceability\n\nReturn a clear, self-contained thought explaining what you\u0027re considering, why it\u0027s important, and what you plan to do next."
      },
      "position": [
        380,
        220
      ],
      "type": "@n8n/n8n-nodes-langchain.toolThink",
      "typeVersion": 1
    },
    {
      "id": "73bdf0e2-a19a-4470-ae10-b1a603b71734",
      "name": "Morpheus (by AskRally)",
      "parameters": {
        "options": {},
        "promptType": "define",
        "text": "=You are an AI strategist that uses AskRally tools to simulate audience-based reasoning before giving advice.\n\nGiven the situation, complication, and question from the user, follow these steps below.\n\n#situation\n{{ $json.body.situation }}\n\n#complication\n{{ $json.body.complication }}\n\n#question\n{{ $json.body.question }}\n\n0. If the situation is ambiguous or complex, call the `Think` tool to reflect first.\n1. First, use the RallyListAudiences tool to get available audiences.\n2. Review the audience names and descriptions. Choose the most relevant audience for the request and get it\u0027s audienceId.\n3. Use the RallyChatTool to run a simulation with that audienceId. Your query should aim to gather insights that help resolve the combine the situation, complication, and question.\nUse the RallyChatTool to run a simulation. You must pass two parameters:\n   - `audience_id`: the ID of the chosen audience (e.g. from RallyListAudiences output)\n   - `query`: a question that combines the situation, complication, and user question.\n4. Carefully analyze the simulated responses. Look for surprising, counter-intuitive, or insightful feedback.\n5. Return a formatted answer like this:\n\nRecommendation: {the recommended action that is grounded in evidence from the simulation and resolves the situation/complication/question}  \nEvidence: {a short summary citing the key evidence from the simulation responses}  \nSampled Response: {a few persona responses from the simulation}\n\n#RULES\n- You have access to tools: RallyListAudiences and RallyChatTool. Do not simulate reasoning manually \u2014 instead, use these tools step-by-step.\n- Use the `Think` tool when:\n- You are unsure how to proceed\n- You are deciding between multiple audience options\n- You want to reflect or cache reasoning for reuse\n- To make sure you call any calls with teh correctly structured parameters\n\nThe `Think` tool will not return external data, but lets you write intermediate thoughts to memory.\n\nFormat like this:\n{ \"thought\": \"I\u0027m considering audience A and B, but A fits better because...\" }\n"
      },
      "position": [
        420,
        -200
      ],
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2
    },
    {
      "credentials": {
        "httpBearerAuth": {
          "id": "wSoUK2sXm0c8MCMq",
          "name": "Bearer Auth account 2"
        },
        "httpHeaderAuth": {
          "id": "nIInIL9RlBRoMNiE",
          "name": "Header Auth account"
        }
      },
      "id": "0c3c581d-e63b-43c9-abb7-2594a36e83e9",
      "name": "RallyListAudiences",
      "parameters": {
        "authentication": "genericCredentialType",
        "dataField": "user_audiences",
        "fields": "id, name, description",
        "fieldsToInclude": "selected",
        "genericAuthType": "httpBearerAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "optimizeResponse": true,
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        },
        "sendHeaders": true,
        "toolDescription": "Retrieves a list of available AI-generated audiences, each with a name and description. Use this to find which audience is most relevant to the user\u0027s situation.",
        "url": "https://api.askrally.com/api/v1/audiences"
      },
      "position": [
        620,
        200
      ],
      "type": "n8n-nodes-base.httpRequestTool",
      "typeVersion": 4.2
    },
    {
      "credentials": {
        "httpBearerAuth": {
          "id": "wSoUK2sXm0c8MCMq",
          "name": "Bearer Auth account 2"
        },
        "httpHeaderAuth": {
          "id": "nIInIL9RlBRoMNiE",
          "name": "Header Auth account"
        }
      },
      "id": "48f22f9d-d197-4459-b7e2-b758fd136819",
      "name": "RallyChatTool",
      "parameters": {
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "audience_id",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI(\u0027parameters0_Value\u0027, ``, \u0027string\u0027) }}"
            },
            {
              "name": "query",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI(\u0027parameters1_Value\u0027, ``, \u0027string\u0027) }}"
            }
          ]
        },
        "genericAuthType": "httpBearerAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "method": "POST",
        "options": {
          "response": {
            "response": {
              "responseFormat": "json"
            }
          }
        },
        "sendBody": true,
        "sendHeaders": true,
        "toolDescription": "Sends a query to a specific audience of AI personas and simulates their responses. Requires an audience_id and query.\n\n| Name          | Type   |\n| ------------- | ------ |\n| `audience_id` | string |\n| `query`       | string |\n",
        "url": "https://api.askrally.com/api/v1/chat"
      },
      "position": [
        800,
        200
      ],
      "type": "n8n-nodes-base.httpRequestTool",
      "typeVersion": 4.2
    },
    {
      "id": "2538e51b-b037-421f-b1ae-648b2c6e8819",
      "name": "Set Response",
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "79ec8c8c-8208-45e1-9aac-0ce29f3710c5",
              "name": "response",
              "type": "string",
              "value": "={{ $json.output }}"
            }
          ]
        },
        "options": {}
      },
      "position": [
        800,
        -200
      ],
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4
    },
    {
      "id": "3537e849-dcd7-4692-a1fb-873e45812c33",
      "name": "Respond With Gsheet",
      "parameters": {
        "options": {},
        "respondWith": "text",
        "responseBody": "Your simulation has started. The results will be added here in 2 to 3 minutes. https://docs.google.com/spreadsheets/d/1BL4VesOM3ex2K6OeRp5vBhhY8h6_aCvJbe9DQ3EWE80/edit?usp=sharing\n\n"
      },
      "position": [
        420,
        -360
      ],
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.4
    },
    {
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "MhuRP8vpmWB2rcz3",
          "name": "Google Sheets account 2"
        }
      },
      "id": "9178f664-eb11-40d9-b0bc-37a1eeab972b",
      "name": "Google Sheets",
      "parameters": {
        "columns": {
          "attemptToConvertTypes": false,
          "convertFieldsToString": false,
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "Response"
          ],
          "schema": [
            {
              "canBeUsedToMatch": true,
              "defaultMatch": false,
              "display": true,
              "displayName": "Response",
              "id": "Response",
              "removed": false,
              "required": false,
              "type": "string"
            }
          ],
          "value": {
            "Response": "={{ $json.response }}"
          }
        },
        "documentId": {
          "__rl": true,
          "cachedResultName": "Morpheus (by AskRally)",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1BL4VesOM3ex2K6OeRp5vBhhY8h6_aCvJbe9DQ3EWE80/edit?usp=drivesdk",
          "mode": "list",
          "value": "1BL4VesOM3ex2K6OeRp5vBhhY8h6_aCvJbe9DQ3EWE80"
        },
        "operation": "append",
        "options": {},
        "sheetName": {
          "__rl": true,
          "cachedResultName": "Sheet1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1BL4VesOM3ex2K6OeRp5vBhhY8h6_aCvJbe9DQ3EWE80/edit#gid=0",
          "mode": "list",
          "value": "gid=0"
        }
      },
      "position": [
        1020,
        -200
      ],
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.6
    }
  ],
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "tags": [],
  "versionId": "855bb73e-201b-4289-96f2-9ff5696a4cdc"
}

About the Author

Rhys Fisher

Rhys Fisher

Rhys Fisher is the COO & Co-Founder of Rally. He previously co-founded a boutique analytics agency called Unvanity, crossed the Pyrenees coast-to-coast via paraglider, and now watches virtual crowds respond to memes. Follow him on Twitter @virtual_rf