|
| 1 | +/** |
| 2 | + * Copyright 2016-2019 IBM Corp. All Rights Reserved. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +import Botkit = require('botkit'); |
| 17 | +import AssistantV1 = require('ibm-watson/assistant/v1'); |
| 18 | +import { MessageParams, MessageResponse } from 'ibm-watson/assistant/v1'; |
| 19 | +import { Context } from 'ibm-watson/assistant/v1'; |
| 20 | +import { BotkitMessage } from 'botkit'; |
| 21 | +export interface WatsonMiddlewareConfig extends AssistantV1.Options { |
| 22 | + workspace_id: string; |
| 23 | + minimum_confidence?: number; |
| 24 | +} |
| 25 | +/** |
| 26 | + * @deprecated please use AssistantV1.MessageParams instead |
| 27 | + */ |
| 28 | +export declare type Payload = MessageParams; |
| 29 | +export declare type BotkitWatsonMessage = BotkitMessage & { |
| 30 | + watsonData?: MessageResponse; |
| 31 | + watsonError?: string; |
| 32 | +}; |
| 33 | +export interface ContextDelta { |
| 34 | + [index: string]: any; |
| 35 | +} |
| 36 | +export declare class WatsonMiddleware { |
| 37 | + private readonly config; |
| 38 | + private conversation; |
| 39 | + private storage; |
| 40 | + private readonly minimumConfidence; |
| 41 | + private readonly ignoreType; |
| 42 | + constructor(config: WatsonMiddlewareConfig); |
| 43 | + hear(patterns: string[], message: Botkit.BotkitMessage): boolean; |
| 44 | + before(message: Botkit.BotkitMessage, payload: MessageParams): Promise<MessageParams>; |
| 45 | + after(message: Botkit.BotkitMessage, response: MessageResponse): Promise<MessageResponse>; |
| 46 | + sendToWatson(bot: Botkit.BotWorker, message: Botkit.BotkitMessage, contextDelta: ContextDelta): Promise<void>; |
| 47 | + receive(bot: Botkit.BotWorker, message: Botkit.BotkitMessage): Promise<void>; |
| 48 | + interpret(bot: Botkit.BotWorker, message: Botkit.BotkitMessage): Promise<void>; |
| 49 | + readContext(user: string): Promise<Context>; |
| 50 | + updateContext(user: string, context: Context): Promise<{ |
| 51 | + context: Context; |
| 52 | + }>; |
| 53 | + deleteUserData(customerId: string): Promise<void>; |
| 54 | +} |
0 commit comments