Webhook+OpenAi+Webhook

I’m using webflow as my frontend and the make scenario is as follows-
Webhook+openai (chat completion)+webhook response

However the make scenario is running perfectly I’m not getting output in my webflow site. These are the custom codes I used in webflow-

Please help me correct this, everytime I run the scenario it shows “accepted” in the website rather than the response.

Welcome to the Make community!

We can’t see your code in your post body because it seems like there is some HTML tags.

1. Format your code

Could you format your code by editing three backticks ``` before and after the code, like this:

```
input/output bundle goes here
```

or use the format code button in the editor:
Screenshot_2023-10-02_191027

2. Webflow site links

Can you please provide the project preview/share link AND the published page link of your site?

3. Scenario blueprint

Please export the scenario blueprint file to allow others to view the mappings and settings. At the bottom of the scenario editor, you can click on the three dots to find the Export Blueprint menu item.

Screenshot_2023-08-24_230826
(Note: Exporting your scenario will not include private information or keys to your connections)

Uploading it here will look like this:

blueprint.json (12.3 KB)

4. And most importantly, Output bundles

Please provide the output bundles of the modules by running the scenario, then click the white speech bubble on the top-right of each module, save the bundle contents in your text editor as a bundle.json file, and upload it here into this discussion thread.
Screenshot_2023-10-06_141025

Providing the output bundles will allow others to replicate what is going on in the scenario even if they do not use the external service.

Following these steps will allow others to assist you here. Thanks!

2 Likes
  1. These are the codes
<script>
// Select the form element and the loader elements 
const form = document.querySelector('#wf-form-generator');
const resultWrap = document.querySelector('#statement-component');
const resultLoader = document.querySelector('#statement-loader');
const resultText = document.querySelector('#statement-text');

// Add a submit event listener to the form
form.addEventListener('submit', (event) => {
    // Prevent the default form submission behavior
    event.preventDefault();
    
    // Show the div that will contain the response and scroll to it
    resultWrap.style.display = "block";
    resultLoader.style.display = "flex";
    resultWrap.scrollIntoView({behavior: "smooth"});
    
    // Get the values of the form fields
    const income = document.getElementById('income').value;
    const debt = document.getElementById('debt').value;
    const monthlysavings = document.getElementById('monthlysavings').value;
    const risktolerance = document.getElementById('risktolerance').value;
    const anynote = document.getElementById('anynote').value;
    const profession = document.getElementById('profession').value;
    const age = document.getElementById('age').value;

    
    // Create the prompt string using the form field values
    const prompt = `Generate an investment stratgey for an Indian who's profession is ${profession}, age is ${age} and income is ${income}. Their monthly savings are ${monthlysavings} and risk tolerance is ${risktolerance}. Keep in mind ${anynote}. The output should be in similar format : Sensex or nifty ₹1000, any individual high performing stocks ₹200, Gold ₹100, Silver ₹50 and mutual funds smalll cap, medium cap and large cap ₹500 etc. Note that these amounts should add upto the amount of ${monthlysavings}.`;
	
		// Make an API call to our Make cenario
    fetch('https://hook.eu2.make.com/7ruo5nlopv8cos93xx6bpqcw9mqnxwdu', {
        method: 'POST', 
        headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ 
        	prompt: prompt, 
          max_tokens: 512
        })
    })
    // Then get the API response object, covert it to text and display it
    .then(response => response.text())
    .then(result => {
    	resultText.value = result;
    	resultLoader.style.display = "none";
    });   
});
</script>
  1. segmentize.co/dashboard

blueprint.json (13.6 KB)
4. The output bundle shows “none”

Thank you so much for replying. Waiting for your response.

Looks like it’s working on your site, something to do with the OpenAI module then?

Take a look at the execution history of the scenario and see what’s sent in the webhook response

Screenshot_2023-11-18_151141

Please provide the following details:

Please provide the output bundles of the ChatGPT module by going to the latest execution, then click the white speech bubble on the top-right of the module, save the bundle contents in your text editor as a bundle.json file, and upload it here into this discussion thread.
Screenshot_2023-10-06_141025

Providing the output bundles will allow others to replicate what is going on in the scenario even if they do not use the external service.

Following these steps will allow others to assist you here. Thanks!

2 Likes

Sometimes it shows timeout error in “History” but otherwise everything is successful in the make scenario.

These are the output bundles for openai module.
bundles.json (2.1 KB)

Waiting for your response. Thanks for your assistance.

For Webhook response, it must be sent within 40 seconds. If the OpenAI module takes too long, your Webhook trigger will send the default “Accepted” text only.

This is your prompt:

Generate an investment stratgey for an Indian who’s profession is other, age is 30 and income is 5000. Their monthly savings are 5000 and risk tolerance is high. Keep in mind none. The output should be in similar format : Sensex or nifty ₹1000, any individual high performing stocks ₹200, Gold ₹100, Silver ₹50 and mutual funds smalll cap, medium cap and large cap ₹500 etc. Note that these amounts should add upto the amount of 5000.

Sometimes there is this error, resulting in the termination of the scenario. The Webhook response module was not run, so the Trigger responded with the default “Accepted” message.

I can see that you are using the model gpt-3.5-turbo-0613 — You should try try a different OpenAI model that allows more tokens.

Using the model gpt-3.5-turbo-16k-0613 with 1000 max tokens did not encounter this error, and it took about 25 seconds to complete.

2 Likes

I checked the history after trying this a few times.
It solved the timeout error but I still can’t see the output in the website.
It still shows “accepted” even though the scenario was completed in under 30 seconds.

Hey bro. I know you are busy
It would be really nice if you could reply.

If its a timeout issue you can use an HTTP module and call the API manually which removes the timeout issue

2 Likes

Please upload your latest blueprint export again/or provide screenshots of the changes you made.

2 Likes

bundles2.json (2.7 KB)

I’ve changed the model to gpt-3.5-turbo-16k-0613 with 1000 max tokens as you suggested.
Is there any other way I can make this work out or should I continue with fixing this only?

But wouldn’t that showcase my api keys in the public code since I’m building with webflow?

No, it shouldn’t. Because you are calling OpenAI from Make, not your website, which does not contain OpenAI keys.

2 Likes

Understood.

Will I’ve to change anything else in the custom code with I go with http?
Also, I went through the http tutorial. Can you tell me how the make scenario will look?

Thanks for your help. Looking forward for your response.

Hey,
seems like it isn’t a timeout error. I’m getting response in 10-20 seconds. Still it just shows “accepted”.
I’d request to you help me out.
Waiting for response.