How to use the botbuilder-core.ActivityTypes.Invoke function in botbuilder-core

To help you get started, we’ve selected a few botbuilder-core 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 / botbuilder-js / libraries / botbuilder-skills / src / skillHostAdapter.ts View on Github external
const pair = kv.split('=');
                    switch (pair[0]) {
                        case 'cid':
                            args['conversationId'] = decodeURIComponent(args[1]);
                            break;
                        case 'url':
                            args['serviceUrl'] = decodeURIComponent(args[1]);
                            break;
                    }
                });
            }
        }

        // Map to invoke activity
        let activity: Partial = { 
            type: ActivityTypes.Invoke,
            name: method,
            value: args
        };
        
        // Add body contents to args
        switch (method) {
            case BotFrameworkInvokeMethods.CreateConversation:
                activity.value.parameters = await parseBody(req);
                break;
            case BotFrameworkInvokeMethods.SendConversationHistory:
                activity.value.history = await parseBody(req);
                break;
            case BotFrameworkInvokeMethods.UploadAttachment:
                activity.value.attachmentUpload = await parseBody(req);
                break;
            case BotFrameworkInvokeMethods.SendToConversation:
github microsoft / botbuilder-js / libraries / botbuilder / src / teamsActivityHandler.ts View on Github external
protected async onTurnActivity(context: TurnContext): Promise {
        switch (context.activity.type) {
            case ActivityTypes.Invoke:
                const invokeResponse = await this.onInvokeActivity(context);
                // If onInvokeActivity has already sent an InvokeResponse, do not send another one.
                if (invokeResponse && !context.turnState.get(INVOKE_RESPONSE_KEY)) {
                    await context.sendActivity({ value: invokeResponse, type: 'invokeResponse' });
                }
                break;
            default:
                await super.onTurnActivity(context);
                break;
        }
    }
github microsoft / botbuilder-js / libraries / botframework-streaming / src / adapters / streamingAdapter.ts View on Github external
status = 400;
            const request = await parseRequest(req);

            // Authenticate the incoming request
            status = 401;
            const authHeader: string = req.headers.authorization || req.headers.Authorization || '';
            await this.authenticateRequest(request, authHeader);

            // Process received activity
            status = 500;
            const context: TurnContext = this.createContext(request);
            context.turnState.set(BotCallbackHandlerKey, logic);
            await this.runMiddleware(context, logic);

            // Retrieve cached invoke response.
            if (request.type === ActivityTypes.Invoke) {
                const invokeResponse: any = context.turnState.get(INVOKE_RESPONSE_KEY);
                if (invokeResponse && invokeResponse.value) {
                    const value: InvokeResponse = invokeResponse.value;
                    status = value.status;
                    body = value.body;
                } else {
                    status = 501;
                }
            } else {
                status = 200;
            }
        } catch (err) {
            // Catch the error to try and throw the stacktrace out of processActivity()
            processError = err;
            body = err.toString();
        }
github microsoft / botbuilder-js / libraries / botbuilder / src / botFrameworkAdapter.ts View on Github external
const authHeader: string = req.headers.authorization || req.headers.Authorization || '';

            const identity = await this.authenticateRequestInternal(request, authHeader);
            
            // Process received activity
            status = 500;
            const context: TurnContext = this.createContext(request);
            context.turnState.set(this.BotIdentityKey, identity);
            const connectorClient = await this.createConnectorClientWithIdentity(request.serviceUrl, identity);
            context.turnState.set(this.ConnectorClientKey, connectorClient);

            context.turnState.set(BotCallbackHandlerKey, logic);
            await this.runMiddleware(context, logic);

            // Retrieve cached invoke response.
            if (request.type === ActivityTypes.Invoke) {
                const invokeResponse: any = context.turnState.get(INVOKE_RESPONSE_KEY);
                if (invokeResponse && invokeResponse.value) {
                    const value: InvokeResponse = invokeResponse.value;
                    status = value.status;
                    body = value.body;
                } else {
                    status = 501;
                }
            } else {
                status = 200;
            }
        } catch (err) {
            // Catch the error to try and throw the stacktrace out of processActivity()
            processError = err;
            body = err.toString();
        }
github microsoft / botbuilder-js / libraries / botbuilder-dialogs / src / prompts / oauthPrompt.ts View on Github external
private isTeamsVerificationInvoke(context: TurnContext): boolean {
        const activity: Activity = context.activity;

        return activity.type === ActivityTypes.Invoke && activity.name === 'signin/verifyState';
    }