# Returning success before API workflow terminates

**URL:** <https://forum.bubble.io/t/returning-success-before-api-workflow-terminates/24844>\
**Category:** Questions\
**Created:** [February 22, 2018, 2:55pm UTC](https://forum.bubble.io/t/returning-success-before-api-workflow-terminates/24844 "2018-02-22T14:55:50Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![levon](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/levon/32/89793_2.png) [@levon](https://forum.bubble.io/u/levon)\
**Post date:** [February 22, 2018, 2:55pm UTC](https://forum.bubble.io/t/returning-success-before-api-workflow-terminates/24844/1 "2018-02-22T14:55:50Z")

</div>

Does anyone know if it’s possible to somehow return success from API endpoint before it actually terminates? We have a quite complex workflow associated with an endpoint which runs about 10-15 seconds and that triggers time outs on the initiating part.  
I tried return data from API but that trick doesn’t work.  
@emmanuel any suggestions?

Thanks,  
**Levon Terteryan**  
Founder @ Zeroqode & Bubblewits

[let’s stay in touch on twitter!](https://twitter.com/levon377)

[![zeroqode-for-web-160x120](https://us1.discourse-cdn.com/bubble/original/3X/c/6/c6688372752f4234938c3c4d11fbfa761509eb1f.png)](https://zeroqode.com)

[Bubble Templates](https://zeroqode.com)  
[Bubble Plugins](https://zeroqode.com/plugins)  
[Bubble Courses](https://zeroqode.com/courses)  
[Convert Web to iOS & Android](https://zeroqode.com/native)  
[No-code Development Services](https://bubblewits.com)

---

<div class="post-metadata">

**Author:** ![jarrad](https://avatars.discourse-cdn.com/v4/letter/j/ecae2f/32.png) [@jarrad](https://forum.bubble.io/u/jarrad)\
**Post date:** [February 22, 2018, 2:58pm UTC](https://forum.bubble.io/t/returning-success-before-api-workflow-terminates/24844/2 "2018-02-22T14:58:30Z")

</div>

If you purely just need a success response check the return 200 checkbox in the endpoint properties.

---

<div class="post-metadata">

**Author:** ![levon](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/levon/32/89793_2.png) [@levon](https://forum.bubble.io/u/levon)\
**Post date:** [February 22, 2018, 2:59pm UTC](https://forum.bubble.io/t/returning-success-before-api-workflow-terminates/24844/3 "2018-02-22T14:59:44Z")

</div>

there is only this  
 ![image](https://us1.discourse-cdn.com/bubble/original/3X/7/d/7dd3e15c46ca0596540033b78092fcc5afe4a542.png)  
the condition is always met, the problem is in the waiting time to get it 🙂

---

<div class="post-metadata">

**Author:** ![jarrad](https://avatars.discourse-cdn.com/v4/letter/j/ecae2f/32.png) [@jarrad](https://forum.bubble.io/u/jarrad)\
**Post date:** [February 22, 2018, 3:00pm UTC](https://forum.bubble.io/t/returning-success-before-api-workflow-terminates/24844/4 "2018-02-22T15:00:35Z")

</div>

are you writing the calls to the endpoint or using the connector/ 3rd party?

---

<div class="post-metadata">

**Author:** ![levon](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/levon/32/89793_2.png) [@levon](https://forum.bubble.io/u/levon)\
**Post date:** [February 22, 2018, 3:05pm UTC](https://forum.bubble.io/t/returning-success-before-api-workflow-terminates/24844/5 "2018-02-22T15:05:29Z")

</div>

Telegram sends webhooks to that endpoint, and when you click a button in the telegram bot it shows as pending and in Telegram X is even giving a “bot not responding” error. Even though user already received a reply, but the workflow still processes some important actions

---

<div class="post-metadata">

**Author:** ![jarrad](https://avatars.discourse-cdn.com/v4/letter/j/ecae2f/32.png) [@jarrad](https://forum.bubble.io/u/jarrad)\
**Post date:** [February 22, 2018, 3:20pm UTC](https://forum.bubble.io/t/returning-success-before-api-workflow-terminates/24844/6 "2018-02-22T15:20:09Z")

</div>

I have not played with telegram before, I just had a look at it. how are you implementing the bot? ie. are you writing the script or using api calls to push data and defining the web hooks elsewhere? If the user has already received a reply is this suggesting that the error is not that the call doesn’t finish in time but more that the call runs and perhaps the sign/verify web hook or a needed peram is not returning correctly?

---

<div class="post-metadata">

**Author:** ![levon](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/levon/32/89793_2.png) [@levon](https://forum.bubble.io/u/levon)\
**Post date:** [February 22, 2018, 3:22pm UTC](https://forum.bubble.io/t/returning-success-before-api-workflow-terminates/24844/7 "2018-02-22T15:22:33Z")

</div>

it all works fine, except that it takes too much time, and until the workflow runs till the end Telegram shows a rotating circle on the button as if the message was not yet received, although it was, and the user received the reply, but the endpoint contains other actions which are processed after sending the reply.  
the bot is simply API calls made to Telegram to send message, photo etc, and then Telegram sends back a webhook with users inputs…

---

<div class="post-metadata">

**Author:** ![jarrad](https://avatars.discourse-cdn.com/v4/letter/j/ecae2f/32.png) [@jarrad](https://forum.bubble.io/u/jarrad)\
**Post date:** [February 22, 2018, 3:44pm UTC](https://forum.bubble.io/t/returning-success-before-api-workflow-terminates/24844/8 "2018-02-22T15:44:40Z")

</div>

I know you said you tried returning some data but have you tried returning the default success response in JSON format as the first action?

So as JSON by default,

```
{
    'status': 'success',
    'response': {
        'response': 200
    }
}
```

![image](https://us1.discourse-cdn.com/bubble/original/3X/a/e/ae4df1049613817a0e7087b7a3e61a51495a70b6.png)

---

<div class="post-metadata">

**Author:** ![levon](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/levon/32/89793_2.png) [@levon](https://forum.bubble.io/u/levon)\
**Post date:** [February 22, 2018, 3:48pm UTC](https://forum.bubble.io/t/returning-success-before-api-workflow-terminates/24844/9 "2018-02-22T15:48:03Z")

</div>

> [@jarrad](#):
>
> {  
> ‘status’: ‘success’,  
> ‘response’: {  
> ‘response’: 200  
> }  
> }

yes, i tried that but still same

---

<div class="post-metadata">

**Author:** ![jarrad](https://avatars.discourse-cdn.com/v4/letter/j/ecae2f/32.png) [@jarrad](https://forum.bubble.io/u/jarrad)\
**Post date:** [February 22, 2018, 3:48pm UTC](https://forum.bubble.io/t/returning-success-before-api-workflow-terminates/24844/10 "2018-02-22T15:48:37Z")

</div>

so what does the bot look for as a success response or value?

---

<div class="post-metadata">

**Author:** ![levon](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/levon/32/89793_2.png) [@levon](https://forum.bubble.io/u/levon)\
**Post date:** [February 22, 2018, 3:50pm UTC](https://forum.bubble.io/t/returning-success-before-api-workflow-terminates/24844/11 "2018-02-22T15:50:18Z")

</div>

not sure what Bubble sends, when i insert terminate this workflow, then it’s fine. there’s clearly some difference between what Bubble sends at the end of the workflow, and what Bubble sends with “return data from API”

---

<div class="post-metadata">

**Author:** ![jarrad](https://avatars.discourse-cdn.com/v4/letter/j/ecae2f/32.png) [@jarrad](https://forum.bubble.io/u/jarrad)\
**Post date:** [February 22, 2018, 3:51pm UTC](https://forum.bubble.io/t/returning-success-before-api-workflow-terminates/24844/12 "2018-02-22T15:51:47Z")

</div>

ok, this is a terminate response,

```
{
    'status': 'success',
    'response': {}
}
```

---

<div class="post-metadata">

**Author:** ![levon](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/levon/32/89793_2.png) [@levon](https://forum.bubble.io/u/levon)\
**Post date:** [February 22, 2018, 3:54pm UTC](https://forum.bubble.io/t/returning-success-before-api-workflow-terminates/24844/13 "2018-02-22T15:54:17Z")

</div>

tried that too 🙂 same

---

<div class="post-metadata">

**Author:** ![jarrad](https://avatars.discourse-cdn.com/v4/letter/j/ecae2f/32.png) [@jarrad](https://forum.bubble.io/u/jarrad)\
**Post date:** [February 22, 2018, 3:56pm UTC](https://forum.bubble.io/t/returning-success-before-api-workflow-terminates/24844/14 "2018-02-22T15:56:09Z")

</div>

have you got somewhere to write code on the telegram side of things?

---

<div class="post-metadata">

**Author:** ![levon](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/levon/32/89793_2.png) [@levon](https://forum.bubble.io/u/levon)\
**Post date:** [February 22, 2018, 3:56pm UTC](https://forum.bubble.io/t/returning-success-before-api-workflow-terminates/24844/15 "2018-02-22T15:56:29Z")

</div>

nope, it’s all preconfigured

---

<div class="post-metadata">

**Author:** ![jarrad](https://avatars.discourse-cdn.com/v4/letter/j/ecae2f/32.png) [@jarrad](https://forum.bubble.io/u/jarrad)\
**Post date:** [February 22, 2018, 4:04pm UTC](https://forum.bubble.io/t/returning-success-before-api-workflow-terminates/24844/16 "2018-02-22T16:04:36Z")

</div>

what im looking through, if its configured right, including the certificate/signing side of things then a return of,

```
{
  "status": "success"
}
```

---

<div class="post-metadata">

**Author:** ![jarrad](https://avatars.discourse-cdn.com/v4/letter/j/ecae2f/32.png) [@jarrad](https://forum.bubble.io/u/jarrad)\
**Post date:** [February 22, 2018, 4:06pm UTC](https://forum.bubble.io/t/returning-success-before-api-workflow-terminates/24844/17 "2018-02-22T16:06:24Z")

</div>

Have you got something setup that i can fire some responses at it manually?

Maybe try responding with 201 instead of 200?

---

<div class="post-metadata">

**Author:** ![emmanuel](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/emmanuel/32/27657_2.png) [@emmanuel](https://forum.bubble.io/u/emmanuel)\
**Post date:** [February 22, 2018, 4:59pm UTC](https://forum.bubble.io/t/returning-success-before-api-workflow-terminates/24844/18 "2018-02-22T16:59:09Z")

</div>

A way to work around this is by scheduling an API workflow to do the long operation. The the response is very fast

---

<div class="post-metadata">

**Author:** ![levon](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/levon/32/89793_2.png) [@levon](https://forum.bubble.io/u/levon)\
**Post date:** [February 22, 2018, 5:10pm UTC](https://forum.bubble.io/t/returning-success-before-api-workflow-terminates/24844/19 "2018-02-22T17:10:40Z")

</div>

yes, we thought about this, it’ll just make things a bit more complex, but probably we’ll have to go down that way. Thanks

---

<div class="post-metadata">

**Author:** ![maurice](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@maurice](https://forum.bubble.io/u/maurice)\
**Post date:** [April 8, 2019, 11:50pm UTC](https://forum.bubble.io/t/returning-success-before-api-workflow-terminates/24844/20 "2019-04-08T23:50:08Z")

</div>

Hi, I’ve had a similar issue while using Slack API, as I need to respond to user input from Slack immediately.

Since I’m just learning how all this works I’m a little lost with how to do this last part. Are you referring to creating a new API call in the API connector that uses a specific POST method, which I then use when I schedule API workflow?

I currently need to return a application/json format that looks a little like this when the user puts in an email that doesnt exist in my bubble app, or a name;

> {  
> “errors”: [  
> {  
> “name”: “email\_address”,  
> “error”: “Sorry, this email domain is not authorized!”  
> },  
> {  
> “name”: “username”,  
> “error”: “Uh-oh. This username has been taken!”  
> }  
> ]  
> }

[Next page](https://forum.bubble.io/t/returning-success-before-api-workflow-terminates/24844.md?page=2)
