Skip to main content

Hello! I have a Zapier Integration in which some actions (requests to my backend) require more time to respond (up to one minute), and when I'm testing a new Zap with this action, I encounter an error message: 'The app did not respond in time. It may or may not have completed successfully.'

I'm trying to create an action with a callback URL, but I'm not receiving any response at the next step.

Here is my action code:

module.exports = {
key: "prediction",
noun: "Prediction",
display: {
label: "Create Prediction",
description: "Creates a new prediction.",
},
operation: {
inputFields: [
{
key: "question",
required: true,
type: "string",
helpText: 'Provide a "Yes" or "No" question to ask the Magic 8-Ball.',
},
],
perform: (z, bundle) => {
const promise = z.request({
url: "https://83a7-38-54-105-8.ngrok.io/v1/zapier/test",
method: "POST",
body: {
url: z.generateCallbackUrl(),
},
headers: {
"content-type": "application/json",
"X-API-Key": "secret",
},
});

return promise.then((response) => ({ ...response.data, extra: "data" }));
},

performResume: (z, bundle) => {
const { extra, ...originalOutput } = bundle.outputData;

return { ...originalOutput, ...bundle.cleanedRequest };
},
sample: {
callbackUrl: "http://zapier.com/hooks/catch/-1234/abcdef/",
status: "success",
result: "Ask again later.",
},
outputFields: [
{ key: "callbackUrl", label: "Callback URL" },
{ key: "status", label: "Status" },
{ key: "result", label: "Predicted Result" },
],
},
};

and test request of my API code
 

  @Post('/test')
async testCallback(@Body('url') url) {
setTimeout(() => {
fetch(url, {
method: 'POST',
body: JSON.stringify({
callbackUrl: 'http://zapier.com/hooks/catch/-1234/abcdef/',
status: 'success',
result: 'Ask again later.',
}),
});
}, 30000);

return { callbackUrl: url, status: 'loading' };
}