Search code examples
typescriptactions-on-google

Actions On Google with TypeScript: How to start?


I'm using the Actions Console. When invoking my action with "HookIntent" I always get:

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

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

Json:

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

I cannot find any working example with typescript. All examples and trainings from google are with Javascript.


Solution

  • I'm going to agree with Jordi in the comments you should instead use @assistant/conversation and refactor a bit of your code to use the Actions Builder platform 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)