Search code examples
node.jsibm-cloudwatson-assistantopenwhiskibm-cloud-functions

IBM Watson Assistnat: Extend the Webhook's time when sending a webhook to a Cloud Function


While developing a client application that uses its own styling, but also IBM Watson Assistant under the hood, problems have been discovered when the webhook's time is exceeded. The composition is as follows: a client app sends a request to Watson Assistant, from there the Assistant triggers a webhook, which after that triggers an IBM Cloud Function.

Following this link, a man can see that in one of the FAQs is stated, that the time limit (8 seconds) can not be extended. Does it include also the case when a call is made to a IBM Cloud Function?

Update:

async function main(){
    try {
        const orders = await db.getOrders();
        if(orders.quantity > 0){
            return {data: 'there are some orders'};
        } else {
            return {data: 'there are no orders'};
        }
    } catch(err) {
        return {error: err.message};
    }
}

Solution

  • Apologies if you are already doing this, but why not return a promise from your cloud function. That way the return is almost immediate falling within your 8 seconds, but the processing would become asynchronous.

    eg.

    function main (args) {
        return new Promise((resolve, reject) => {
          ...
        });
    }