Open dcsan opened 4 years ago
actually even the above doesn't seem to work, something to do with calling context?
I'm using some async request/response express routes, would that break the DF library?
(node:11008) UnhandledPromiseRejectionWarning: Error: Unknown response type: "undefined"
at WebhookClient.addResponse_ (/Users/dc/dev/considr/demoflow/server/node_modules/dialogflow-fulfillment/src/dialogflow-fulfillment.js:287:13)
at WebhookClient.add (/Users/dc/dev/considr/demoflow/server/node_modules/dialogflow-fulfillment/src/dialogflow-fulfillment.js:254:12)
at /Users/dc/dev/considr/demoflow/server/src/stories/CoachReply.ts:31:13
at WebhookClient.handleRequest (/Users/dc/dev/considr/demoflow/server/node_modules/dialogflow-fulfillment/src/dialogflow-fulfillment.js:313:44)
at Object.<anonymous> (/Users/dc/dev/considr/demoflow/server/src/stories/CoachReply.ts:34:11)
at step (/Users/dc/dev/considr/demoflow/server/src/stories/CoachReply.ts:33:23)
at Object.next (/Users/dc/dev/considr/demoflow/server/src/stories/CoachReply.ts:14:53)
at fulfilled (/Users/dc/dev/considr/demoflow/server/src/stories/CoachReply.ts:5:58)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:11008) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:11008) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
seems this is the doc: https://dialogflow.com/docs/reference/fulfillment-library/webhook-client#new_webhookclientoptions
this seems to work (in case helps someone else)
const intentHandler = (agent) => {
let output = `${HEADER} \n ${reply.text}`
agent.add(output)
}
agent.handleRequest(intentHandler)
this seems to work (in case helps someone else)
const intentHandler = (agent) => { let output = `${HEADER} \n ${reply.text}` agent.add(output) } agent.handleRequest(intentHandler)
This only works for a single intent, bc of this line: https://github.com/dialogflow/dialogflow-fulfillment-nodejs/blob/master/src/dialogflow-fulfillment.js#L296
If you would like to use multiple intents, you need to either go with the Map
, if you want to follow the flow.
probably the most basic question, but the docs (?) suck. I want to send a basic text response from an agent. something like:
this works but its dufus
I don't want to use the
intentMap.set
or ideallyagent.handleRequest(intentMap)
And I certainly don't want to use google cloud funcs, plain express is fine.