简体   繁体   中英

Using async/wait functions in webhooks for Dialogflow CX not working

I have linked a function as a webhook to a page on Dialogflow CX and the agent writes out the output of the function correctly.

However, when making the function "async" the chat agent does not write out any text at all. What is the issue here?

So this node.js code functions well:

function serve_hello_world(){
    const answer = "hello world";
    return answer
}

But when running this asynchrous code as the webhook function nothing is written at Dialogflow CX.

async function serve_hello_world(){
    const answer = await "hello world";
    return answer
}

My guess is that the webhook waits too long, and therefore Dialogflow CX chat agent does not write out anything?

I found the error. The webhook function calling serve_hello_world() also needs to use async/await.

So, firstly the webhook function needs to be assigned to be "async" and secondly there needs to be an "await" before the function call.

Hopefully this helps someone else with the same error:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM