Skip to content
Using Webhooks with...
 
Notifications
Clear all

Using Webhooks with OpenAI

15 Posts
3 Users
0 Reactions
6 Views
Vedant_Verma
(@vedant_verma)
Posts: 9
Active Member
Topic starter
 

I'm using Webflow for my frontend, and the callin.io scenario is set up like this:

Webhook + OpenAI (Chat Completion) + Webhook Response

Although the callin.io scenario runs perfectly, I'm not receiving the output on my Webflow site. Here are the custom codes I've implemented in Webflow:

Could someone please help me fix this? Every time I run the scenario, it displays "accepted" on the website instead of the actual response.

 
Posted : 16/11/2023 4:39 am
samliew
(@samliew)
Posts: 293
Reputable Member
 

Welcome to the callin.io community!

We can’t see your code in your post body as it appears to contain some HTML tags.

1. Format your code

Could you please format your code by enclosing it within three backticks (```) before and after the code, like this:


<sup>_input/output bundle goes here_</sup>

or by using 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 for your site?

3. Scenario blueprint

Please export the scenario blueprint file so others can review the mappings and settings. You can find the Export Blueprint option by clicking the three dots at the bottom of the scenario editor.

Screenshot_2023-08-24_230826

(Note: Exporting your scenario will not include private information or connection keys)

Uploading it here will display as follows:

blueprint.json (12.3 KB)

4. And most importantly, Output bundles

Please provide the output bundles for the modules. To do this, run the scenario, then click the white speech bubble on the top-right of each module. Save the bundle contents to a bundle.json file and upload it to this discussion thread.

Screenshot_2023-10-06_141025

Providing the output bundles will enable others to replicate the scenario's behavior, even if they don't use the external service.

Following these steps will help others assist you. Thanks!

 
Posted : 16/11/2023 6:22 am
Vedant_Verma
(@vedant_verma)
Posts: 9
Active Member
Topic starter
 
  1. Here are the code snippets:
<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 callin.io scenario
    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

  2. 3.

blueprint.json (13.6 KB)

  1. The output bundle displays "none".

Thank you for your reply. I look forward to your response.

 
Posted : 17/11/2023 1:35 pm
samliew
(@samliew)
Posts: 293
Reputable Member
 

It appears to be functioning on your end. Is the issue related to the OpenAI module?

Kindly review the scenario's execution history and check the webhook response.

Screenshot_2023-11-18_151141

Please provide the following details:

To help diagnose the issue, please share the output bundles from the ChatGPT module. You can do this by navigating to the latest execution, clicking the white speech bubble in the top-right corner of the module, and saving the bundle contents as a bundle.json file. Then, upload this file to this discussion thread.

Screenshot_2023-10-06_141025

Sharing the output bundles will enable others to replicate the scenario's behavior, even if they don't use the same external service.

Following these instructions will greatly assist others in helping you. Thank you!

 
Posted : 18/11/2023 7:23 am
Vedant_Verma
(@vedant_verma)
Posts: 9
Active Member
Topic starter
 

Occasionally, a timeout error appears in "History," but the callin.io scenario otherwise completes successfully.

Below are the output bundles from the OpenAI module.
bundles.json (2.1 KB)

I look forward to your reply. Thank you for your help.

 
Posted : 18/11/2023 11:09 am
samliew
(@samliew)
Posts: 293
Reputable Member
 

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

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.

Occasionally, this error occurs, leading to the termination of the scenario. The Webhook response module was not executed, 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.

Please provide the rewritten markdown content *it should be in the markdown format.

 
Posted : 20/11/2023 3:31 am
Vedant_Verma
(@vedant_verma)
Posts: 9
Active Member
Topic starter
 

I reviewed the execution history after attempting this a few times. It resolved the timeout issue, but I'm still unable to view the output on the website. The status continues to display "accepted" despite the scenario finishing in less than 30 seconds.

 
Posted : 20/11/2023 4:04 am
Vedant_Verma
(@vedant_verma)
Posts: 9
Active Member
Topic starter
 

Hello there.

I understand you might be occupied, but it would be greatly appreciated if you could respond.

Thank you.

 
Posted : 23/11/2023 5:00 pm
KyleBehrend
(@kylebehrend)
Posts: 14
Active Member
 

If you're encountering a timeout issue, you can utilize an HTTP module to manually invoke the API, which effectively bypasses the timeout problem.

 
Posted : 23/11/2023 10:44 pm
samliew
(@samliew)
Posts: 293
Reputable Member
 

Could you please re-upload your latest blueprint export or share screenshots detailing the modifications you've made?

 
Posted : 24/11/2023 2:19 am
Vedant_Verma
(@vedant_verma)
Posts: 9
Active Member
Topic starter
 

I've adjusted the model to gpt-3.5-turbo-16k-0613 and set the maximum tokens to 1000, as you recommended.

Are there any alternative approaches I could explore to achieve this, or should I focus solely on resolving the current issue?

 
Posted : 24/11/2023 6:59 am
Vedant_Verma
(@vedant_verma)
Posts: 9
Active Member
Topic starter
 

Wouldn't that expose my API keys in the public code, given I'm developing with Webflow?

 
Posted : 30/11/2023 5:55 am
samliew
(@samliew)
Posts: 293
Reputable Member
 

No, that should not happen. This is because you are invoking OpenAI via callin.io, not directly from your website, meaning your website code will not contain the OpenAI keys.

 
Posted : 30/11/2023 6:05 am
Vedant_Verma
(@vedant_verma)
Posts: 9
Active Member
Topic starter
 

Got it.

Will I need to modify anything else in the custom code if I opt for HTTP?

Also, I've reviewed the HTTP tutorial. Could you illustrate how the callin.io scenario would appear?

Thanks for your assistance. I'm eager for your reply.

 
Posted : 30/11/2023 2:40 pm
Vedant_Verma
(@vedant_verma)
Posts: 9
Active Member
Topic starter
 

Hello,
it appears this is not a timeout issue. I am receiving a response within 10-20 seconds, yet it still only displays "accepted".

I would appreciate your assistance.

Awaiting your reply.

 
Posted : 04/12/2023 5:19 am
Share: