👂 Listening To Events

To listen/subscribe to different event types, you can use the event() method. Handlers will be called in the order they are added.

Example: We subscribe to errors that occur in the app.

app.event('error', ({ err, log }) => {
    log.error(err);
});

Example: When a user signs in using OAuth or SSO, use the graph api to fetch their profile and say hello.

app.event('signin', async ({ activity, tokenResponse, send }) => {
    const msgraph = graph(tokenResponse.token);
    const me: MSGraph.User = await msgraph.api('/me').get();

    await send({
        type: 'message',
        text: `👋 Hello ${me.name}`,
    });
});