Display data from Zapier on Softr custom code block

Hi! I have successfully set up a Softr/ zapier integration that takes some data from Softr and then generates resultant data in zapier.

I would like to send that resultant data back to Softr and display it in a custom code block.

Does anyone know how I could do this?

The data is actually generated in a python flask app in remplit.

I have done this with a webhook in Make. Here is some sample code for how to send the webhook.

In the part that handles the response, you will want to modify the text of some <div> or <span>. There are good examples of that elsewhere in this forum as well, but if you can’t find it, let me know and I’ll dig it up.

@thomasoliver is zapier able to send data back ? Make can do it.

no in zapier the zap can only let me create or delete a user in softr.

so with make i can send the CATCH webhook from a user entering a question in softr

then send that question with a POST webhook to my flask app in replit and generate a response

and then send that response back to be displayed in softr?

thanks for help yesterday @artur @dcoletta - been trying this again today.

so specifically, I am trying to display a response generated in a flask app in a softr custom code block.

the flask app defines an endpoint (to which I am sending - via CATCH and PUSH webhooks in Zapier - a question entered by a user in softr)

Now i basically want to fetch the response generated from the flask app and am trying code to do this but for some reason it is not working…

am i missing something?

the reason I think this is possible is because I saw this hot seat session where the guest says that they are pulling a python flask app from replit into a custom code block in softr.

Can you post the JavaScript that calls the webhook?

What I had expected you’d do is call the webhook, then the webhook would send back a response with the content you want to display in the custom code block. So I was expecting that the JavaScript would have a completion function that is passed the response from the webhook.

That sounds simpler than what I am trying and it is of course possible I am overcomplicating …

What I’ve currently done -

  • user enters question in form block
  • question sent to zapier (catch webhook)
  • question sent from z to flask app run in replit (push webhook)
  • flask app runs python code that generates response

The next bit I’m trying to do is fetch the response from the flask app endpoint. All I’m trying is custom code in Softr block (immediately beneath the form block).

But perhaps your solution gives me a simpler way to do this?

Take a look at the sample code I linked to above. I think you should be able to do the same kind of thing, assuming Zapier supports sending response content in a webhook. I don’t know what CATCH and PUSH are, but I’m guessing CATCH means when you make the request to Zapier, and PUSH is the opposite?

Thanks -

Here is my JS.

Still not working but I am doing this with the help of gpt so maybe that’s why …

any help welcome!

<div id="answer"></div>
<script>
  fetch('http://https://endpoint/display_answer', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      answer: ''
    })
  })
  .then(response => response.json())
  .then(data => {
    document.getElementById('answer').innerHTML = data.display_text;
  });
</script>

Are you familiar with how to use Chrome Developer Tools to see where the error might be?

Thank you @dcoletta.

FINALLY done this. See attached screenshot.

User enters question in normal form block.

Question generates a response in a flask app using OpenAI API with my own GPT customizations.

Response displays in a custom code block in second half of screen (CSS’d to match the top half of the screen).

Thank you!

2 Likes

Thats great, can you help me in hiw to do? I have similar challenge

yes sure!

Looks great @thomasoliver
That said, really hoping Softr provide us with more AI blocks types out of the box that are able to work with the various AI models. So at least a more chat-like interface, where multiple subsequent questions can be ask and that’s able to plugin to chatGPT for example.
Also a custom code generator that’s auto-magically gets feeded the current html/js/css code of the current page your working on, alongside the user request!

@J_1 coming soon :slight_smile:

1 Like

Nov 23’

This is what I need, would love some explaination in the thread on how to achieve it