Create AI response from prompt and return result
Send a prompt to ChatGPT from another Zap and get the finished answer back, checked every five minutes until it is ready.
Install it
Set up this Zap for me, read how here: https://zapier.sh/zapier/awesome-zaps/create-ai-response-from-prompt-and-return-result/
Paste into Claude, ChatGPT, Cursor or any agent.
- Author
- Zapier
- Source
- zapier/awesome-zaps, folder zaps/create-ai-response-from-prompt-and-return-result
Set it up with the CLI
- Add it. Copies the folder into
zaps/create-ai-response-from-prompt-and-return-result/. Outside a project, it makes one first.npx zap-pack add awesome-zaps/create-ai-response-from-prompt-and-return-result - Fill in the values in
config.ts, and in any other file the list marks. Replace each one as its comment and SKILL.md say. - Deploy it. Asks for any value still left, signs you in to Zapier if you aren't, then publishes it to your account.
npx zap-pack deploy create-ai-response-from-prompt-and-return-result - Check it. Its recent runs, with status and errors.
npx zap-pack logs create-ai-response-from-prompt-and-return-result
zaps/create-ai-response-from-prompt-and-return-result/
- README.mdWhat it does, for people
- SKILL.mdHow an agent sets it up: what to ask you, and how to test it
- config.tsIts settings
- connections/chatgpt.tsThe
chatgptaccount it uses - connections/sub-zap-by-zapier.tsThe
sub-zap-by-zapieraccount it uses - triggers/start-subzap.tsWhat starts it:
sub-zap-by-zapierstart_subzap - workflow.tsThe code; each
ctx.stepis a step in the Zap
Agents: add --yes to any command so it never prompts. When it needs an answer only the user can give, it stops and names the flag that supplies it.
SKILL.md
View MarkdownWhat it does
- Trigger: a calling Zap or workflow starts this sub-zap in Sub-Zap by Zapier (
sub-zap-by-zapier,start_subzap) with aprompt, optionalinstructions, and an optionalmodel. The sub-zap returns its output to the caller. - Sanitize: control characters are removed from the prompt and instructions, and the model defaults to
gpt-4owhen the caller sends none. An empty prompt returns right away without calling ChatGPT. - ChatGPT (
chatgpt) submits the prompt as a Responses API request and keeps the response ID. - Wait and check: the workflow waits five minutes, then fetches the stored response from ChatGPT. It repeats until the response has text or the check limit is reached.
- Return: the generated text goes back to the caller as
{ ok: true, text, responseId }. If there is no text after the last check, it returns{ ok: false, error }instead.
Ask the user
This zap has no per-person values, so nothing is filled in before deploying. Ask the user these:
- Which ChatGPT (OpenAI) connection the sub-zap should use. It must be connected before the workflow can run.
- Whether to keep the defaults, which are worth reviewing with them:
DEFAULT_MODELinconfig.ts: the model used when the caller sends none. Defaults togpt-4o.POLL_INTERVAL_SECONDSandMAX_POLLSat the top ofworkflow.ts: the wait before each check (300 seconds, five minutes) and how many checks to make (12, so one hour) before returning an error.
Build it
If you can run shell commands, set it up with zap-pack: run npx zap-pack add awesome-zaps/create-ai-response-from-prompt-and-return-result, replace each REPLACE_… value as this file says, then run npx zap-pack deploy create-ai-response-from-prompt-and-return-result, which signs the user in to Zapier when it gets there. Otherwise build with Zapier MCP, as the steps below say. No Zapier MCP tools? Read https://docs.zapier.com/mcp/get-started/quickstart.md and follow the page for the app you are running in to get the user connected, then continue with this build.
- Accounts: bind
chatgptto the user's ChatGPT (OpenAI) connection, which the workflow uses to submit the prompt and fetch the response. Sub-Zap by Zapier needs no connection, so bindsub-zap-by-zapierto none. - Source: publish
workflow.tsandconfig.ts, with eachREPLACE_…replaced by the user's answer.triggers/start-subzap.tsandconnections/are settings, not code: set the workflow's trigger and connection bindings from them. The trigger file names the app by its slug; for the trigger'sselected_api, callsearch_triggerswith that slug, find the row whosekeyis the trigger'sevent, and use<app_key>@<app_version>from it. - Build guide: load Zapier's build guide with
get_zapier_skill("zapier:build-workflows")and follow it to create, test and publish the workflow. - Fields: inspect each action's fields with the user's connections (and sample the trigger, if it has one) before the first test run, and fix any key in
workflow.tsthat doesn't match.
Test it
Run this sample as a draft test before publishing:
{
"prompt": "Write a two-sentence thank-you note to a customer who renewed their plan.",
"instructions": "Keep a warm, plain tone. No emojis.",
"model": "gpt-4o"
}
Check that the run first submits the request, then waits, then fetches the response. The returned object should be { ok: true, text, responseId } with a non-empty text, and responseId should match the response ID shown in the run's submit step. Also run it with an empty prompt and confirm it returns { ok: false, error: "empty-prompt" } without calling ChatGPT.
If run-status tools aren't available, check the result in ChatGPT directly. Ask the user to delete any test responses there; the agent does not delete them.
Notes
- Each check is one journaled step, so a retry resumes where it stopped instead of submitting the prompt again.
- The wait between checks uses the workflow's own timer, so no step holds a connection open while it waits.
- The model and the wait can be changed at the top of
workflow.tsand inconfig.tswithout touching the rest of the flow. - Once the trigger is active, give the user its trigger details so they can call it from their own Zap or workflow.
- To route the final text to a review channel before it returns, add a Slack or email step between the last check and the return. To label tone or safety first, add a classification step before the return.