Giter VIP home page Giter VIP logo

cookiecutter-pywebex-teams-bot's Introduction

cookiecutter-pywebex-teams-bot

published

A cookiecutter template to easily create deployable Webex Teams bots in python.

Features

Features include

How to use

Create a new project based on this cookiecutter by issuing the following command

$ cookiecutter https://github.com/sQu4rks/cookiecutter-pywebex-teams-bot

For development

In order to develop your bot you will want to make it able to receive webhooks. To do so you need a way of receiving http requests i.e. ngrok or serveo. You will also need a bot access token that you can obtain from developer.webex.com.

To setup your local machine for development just run

$ source developer_setup.sh

This script will ask you for your bot access token and your remote prefix i.e. https://d342d393.ngrok.io (no trailing slash).

The template code comes prepared with functions to handle all webhooks available within the Webex Teams API and you can automate the setup of the webhooks using webhooksimple. To setup all webhooks simply run

$ python3 -m webhooksimple sync

inside of your project directory.

Your bot code is ready to be modified in bot.py. Happy coding!

For deployment

Once you have finished your bot you can create a docker image using the deployment_setup.sh script.

This script will

  1. Log you into docker hub
  2. Create a new build of your bot image
  3. Push the newly created image to docker hub.

When deploying the container make sure to set the WEBEX_TEAMS_ACCESS_TOKEN and REMOTE_PREFIX environment variables. The entrypoint.sh script used by the container upon start will setup the webhooks according to these environment variables.

Additional options

Customizing which webhooks are setup

You can customize the webhooks you want to use. In order to keep your deployment and development environment the same you should not edit the vars.yml file that is created during the developer setup but rather edit the vars.yml.conftpl file that will be used during deployment on your remote host.

  1. Delete the vars.yml file (i.e. rm vars.yml)
  2. Edit the vars.yml.conftpl file. In the webhooks section at the bottom of the file you can find the list of resources (i.e. messages, rooms, memberships) and events (i.e. created, deleted). Delete (or comment out) all events and or resources you don't need.
  3. Run config templater to create a new vars.yml file by issuing the python3 -m config_templater command.
  4. Run python3 -m webhooksimple setup to delete all webhooks currently registered for your bot and overwrite them with the newly specified webhooks.

Customize the function skeletons provided by the bot

In the bot directory is a file called template.py that can be used to create new function stubs for each of the webhooks specified in vars.yml. Simply run the script and copy&paste the resulting code into the bot.py file.

cookiecutter-pywebex-teams-bot's People

Contributors

squ4rks avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.