Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify the TS command bot template #7257

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

therealjohn
Copy link
Contributor

@therealjohn therealjohn commented Dec 15, 2022

A simplification of the command bot template and make it easier to get started and understand. This also cleans up some language to try and make things clearer.

Some shortcuts were taken to reduce the number of files and concepts introduced so that it's simpler for developers to understand where to start/explore first. i.e. index.ts contains code for the restify server and the command bot configuration instead of using separate files and naming like "internal" - which weren't very clear on their intent.

The result in the scaffold:

Before After
image image

@codecov
Copy link

codecov bot commented Dec 15, 2022

Codecov Report

Merging #7257 (76e0e33) into dev (9073fcc) will not change coverage.
The diff coverage is n/a.

❗ Current head 76e0e33 differs from pull request most recent head c0770c8. Consider uploading reports for the commit c0770c8 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##              dev    #7257   +/-   ##
=======================================
  Coverage   76.69%   76.69%           
=======================================
  Files         578      578           
  Lines       39361    39361           
  Branches     7694     7694           
=======================================
  Hits        30186    30186           
  Misses       5934     5934           
  Partials     3241     3241           

@therealjohn therealjohn force-pushed the therealjohn/templates/command-bot-ts branch from c686440 to c0770c8 Compare January 3, 2023 15:01
Copy link

@garrytrinder garrytrinder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this new simplified structure.

Removing the folders makes it less opinionated leaving the structure up to the developer to decide what is best for them and without having to unpick an existing folder structure.

It would be nice to implement an empty TeamsActivityHandler in index.ts as well to make it easier for developers to implement handlers for Teams events where there are no TeamsFx abstractions.

// teams activity handler setup, override methods to handle incoming activities from Teams
class ConversationBotActitivityHandler extends TeamsActivityHandler {
  constructor() {
    super();
  }
}

// create an instance of your activity handler
const conversationBotActitivityHandler = new ConversationBotActitivityHandler();

// bot framework endpoint to receive incoming activities
server.post("/api/messages", async (req, res) => {
  await conversationBot.adapter.process(req, res, (context) => conversationBotActitivityHandler.run(context))
});

title: "Your Hello World Bot is Running",
body: "Congratulations! Your hello world bot is running. Click the documentation below to learn more about Bots and the Teams Toolkit.",
// An example Adaptive Card that defines the response message of this helloWorld command.
const cardJson = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would consider keeping this as an external file rather than bringing it inline.

You lose the context that there is a card definition from briefly looking at the project structure and also lose the ability to view the card in the Adaptive Cards Designer VSCode extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants