如何使用节点SDK /实现库从DialogFlow发送基本的“ hello world”响应?

可能是最基本的问题,但是文档(?)很烂。 我想从代理发送基本的文本回复。 像这样:

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云功能的文档。

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);

yitianshici 回答:如何使用节点SDK /实现库从DialogFlow发送基本的“ hello world”响应?

我找到了一种不太冗长的方法,以防万一有人发现它

请注意,从DF中的GUI代码中删除对默认后备的答复也很重要

  function intentHandler(agent) {
    agent.add('Hello World');
  }

  agent.handleRequest(intentHandler);
本文链接:https://www.f2er.com/3130750.html

大家都在问