наверное самый основной вопрос, но документы (?) Отстой. Я хочу отправить базовый текстовый ответ от агента. что-то вроде:
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()
этот довольно тупой код, казалось, работал, но теперь есть проблемы
let intentMap = new Map()
intentMap.set('reply', () => {
agent.add('hello world')
})
agent.intent = 'reply'
agent.handleRequest(intentMap)
Я не хочу использовать intentMap.set
или в идеале agent.handleRequest(intentMap)
И яконечно, вы не хотите использовать облачные функции Google, с простым выражением все в порядке.
не может найти документы, которые не заталкивают вас в облако функций Google.
ответ: 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);