How to use the botframework-connector.JwtTokenValidation.assertValidActivity function in botframework-connector

To help you get started, we’ve selected a few botframework-connector 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 / samples / echobot-connector-es6 / app.js View on Github external
server.post('/api/messages', (req, res, next) => {
    console.log('processReq:', req.body);

    let activity = req.body;

    // authenticate request
    JwtTokenValidation.assertValidActivity(activity, req.headers.authorization, authenticator).then(() => {

        // On message activity, reply with the same text
        if (activity.type ===  ActivityTypes.Message) {
            var reply = createReply(activity, `You said: ${activity.text}`);
            const client = new ConnectorClient(credentials, activity.serviceUrl);
            client.conversations.replyToActivity(activity.conversation.id, activity.id, reply)
                .then((reply) => {
                    console.log('reply send with id: ' + reply.id);
                });
        }

        res.send(202);
    }).catch(err => {
        console.log('Could not authenticate request:', err);
        res.send(401);
    });
github microsoft / botbuilder-js / samples / redux-bot-es6 / app.js View on Github external
server.post('/api/messages', (req, res) => {

    console.log('processReq:', req.body);

    let activity = req.body;

    // authenticate request
    JwtTokenValidation.assertValidActivity(activity, req.headers.authorization, authenticator).then(() => {

        // dispatch the inbound activity to redux
        store.dispatch({ type: activity.type, activity: activity });

        res.send(202);
    }).catch(err => {
        console.log('Could not authenticate request:', err);
        res.send(401);
    });
});