How to use the botframework-schema.ActivityTypes.Handoff function in botframework-schema

To help you get started, we’ve selected a few botframework-schema examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / botframework-solutions / lib / typescript / botbuilder-skills / src / skillCallingRequestHandler.ts View on Github external
const body: string = bodyParts.join();
                    // eslint-disable-next-line @typescript-eslint/tslint/config
                    const activity: Activity = JSON.parse(body);
                    if (activity === undefined) {
                        throw new Error('Error deserializing activity response!');
                    }

                    if (activity.type === ActivityTypes.Event && activity.name === TokenEvents.tokenRequestEventName) {
                        if (this.tokenRequestHandler !== undefined) {
                            await this.tokenRequestHandler(activity);

                            return { id: '' };
                        } else {
                            throw new Error('Skill is requesting for token but there\'s no handler on the calling side!');
                        }
                    } else if (activity.type === ActivityTypes.Handoff) {
                        if (this.handoffActivityHandler !== undefined) {
                            await this.handoffActivityHandler(activity);

                            return { id: '' };
                        } else {
                            throw new Error('Skill is sending handoff activity but there\'s no handler on the calling side!');
                        }
                    } else {
                        return this.turnContext.sendActivity(activity);
                    }
                }
            }