jacobytes
jacobytes

Reputation: 3251

Dialogflow endpoint type in typescript

I've implemented a webhook for Dialogflow in Typescript and I would like my endpoint for Google to only support the Dialogflow SDK object. Currently my controller looks something like this:

import {dialogflow, DialogflowConversation} from "actions-on-google";

export class GoogleController {
  public endpoint: any;

constructor() {
  this.endpoint = dialogflow();
  this.endpoint.intent("Welcome", (conv: DialogflowConversation) => {
    return conv.ask("Hey There");
  });
};

Currently I've made the endpoint be of type any, but I would like to change this to a Dialogflow object. I've tried importing DialogflowApp objects from the SDK, but those don't seem to work. Either they don't match the object returned by the dialogflow() call or the interface doesn't have the .intent function.

Does anyone know how to achieve this?

Upvotes: 0

Views: 243

Answers (1)

Nick Felker
Nick Felker

Reputation: 11968

Opening up a project in VSCode, I wrote:

import { dialogflow } from 'actions-on-google'

const endpoint = dialogflow()

Hovering over endpoint, VSCode shows me some metadata on the variable:

const endpoint: OmniHandler & BaseApp & DialogflowApp<{}, {}, Contexts, DialogflowConversation<{}, {}, Contexts>>

Maybe your DialogflowApp declaration needs the generics, or maybe you can just copy that string directly.

Upvotes: 1

Related Questions