首页 > 解决方案 > 使用 TypeScript 在 Google 上操作:如何开始?

问题描述

我正在使用操作控制台。当用“HookIntent”调用我的动作时,我总是得到:

{
    "error": "No intent was provided and fallback handler is not defined."
}

我的 index.ts:

import * as functions from 'firebase-functions'
import {
    dialogflow
} from 'actions-on-google'

const app = dialogflow({debug: true});

app.intent('HookIntent', (conv) => {
    const response = "Hello Test"
    conv.add(response)
})

exports.playMusicFunction = functions.https.onRequest(app);

杰森:

{
    "handler": {
        "name": "HookIntent"
    },
    "intent": {
        "name": "HookIntent",
...

我找不到任何带有打字稿的工作示例。来自 google 的所有示例和培训都使用 Javascript。

标签: typescriptactions-on-google

解决方案


我将同意 Jordi 的评论,您应该改用@assistant/conversation并重构您的一些代码以使用 Actions Builder 平台 webhook。

import * as functions from 'firebase-functions'
import {
    conversation
} from '@assistant/conversation'

const app = conversation({debug: true})

app.handle('HookIntent', (conv) => {
    const response = "Hello Test"
    conv.add(response)
})

exports.playMusicFunction = functions.https.onRequest(app)

推荐阅读