Answered

Redirection happens before webhook finishes

  • 21 October 2021
  • 2 replies
  • 197 views

Hi y’all,

We have a webapp that embeds many Typeform surveys, and we have implemented both webhooks and redirections on each survey.

The expected workflow is: 

  1. User accesses the app
  2. The app checks if the user completed the current TypeformSurvey
  3. If not, the app calls Typeform and shows the survey
  4. Once the user completes the survey, Typeform sends  a webhook to our app and then redirects the user to our app.
    1. The webhook endpoint is an API that stores the survey result in our database and sets the survey as completed for the given user.
  5. Since the webhook is slower than the redirection, our app  determines the survey is not completed yet (on step 2 in this list) , and shows it again
icon

Best answer by mathio 22 October 2021, 11:20

View original

2 replies

Userlevel 7
Badge +5

Hi @Active and Thriving Thanks for stopping by the community! The behavior you’re seeing is expected since the webhook sends after the response is submitted. 

The redirection takes place directly after the respondent submits the form, so it would makes sense for them to see the redirection before the webhook is sent, as it’s not possible to send the webhook before they’re redirected. 

I’m not sure if there is a better solution for this, but possibly @mathio has some ideas that can help. 

Userlevel 7
Badge +5

Hello @Active and Thriving, which part of the flow is the issue? I guess this one, right?

Since the webhook is slower than the redirection, our app  determines the survey is not completed yet (on step 2 in this list) , and shows it again

You could use onSubmit callback from embed SDK to determine if the user has completed the form. You will not be able to retrieve their answers, but you can be sure they have completed the form.

If you need to retrieve their answers too, you will need to wait for the webhook (maybe in a loop?).

Reply