probably the most basic question, but the docs (?) suck. I want to send a basic text response from an agent. something like:
router.post('/api/webhook', async (request, response) => {
const agent = new WebhookClient({ request, response })
agent.add('hello world')
// now how do i tell dialogflow to handle the response? none of these work:
response.send(agent)
agent.resolve()
this pretty dumb code seemed to work but now has problems
let intentMap = new Map()
intentMap.set('reply', () => {
agent.add('hello world')
})
agent.intent = 'reply'
agent.handleRequest(intentMap)
I don't want to use the intentMap.set or ideally agent.handleRequest(intentMap)
And I certainly don't want to use google cloud funcs, plain express is fine.
can't really find any docs that aren't shoving google cloud functions down your throat.
abstract docs, no example code https://dialogflow.com/docs/reference/fulfillment-library/webhook-client#new_webhookclientoptions
client libs - no use https://github.com/googleapis/nodejs-dialogflow
answer: https://blog.dialogflow.com/post/fulfillment-library-beta/
function intentHandler(agent) {
agent.add('This message is from Dialogflow\'s Cloud Functions for Firebase editor!');
agent.add(new Card({
title: 'Title: this is a card title',
imageUrl: 'https://developers.google.com/actions/assistant.png',
text: 'This is the body text of a card. You can even use line\n breaks and emoji! ????',
buttonText: 'This is a button',
buttonUrl: 'https://assistant.google.com/'
})
);
agent.add(new Suggestion('Quick Reply'));
agent.add(new Suggestion('Suggestion'));
}
agent.handleRequest(intentHandler);