Simple bots and examples

Teamwire provides several bot examples for demonstration and learning purposes. Some of them can be executed as docker container to quickly run and test in your environment.

If you are interested on learning the internals of bots or want to make your own, you may want to download the source code as zip file.

Teamwire Docker Images Access

Access to Teamwire docker images is reserved to Teamwire Partners on Teamwire's Harbor Registry, please request access to our support team.

Running bots from docker containers

Every bot will require that you first create an API key in your Teamwire installation.

You will also need an authorized account in Teamwire's Harbor Registry in order to directly download and run the bots.

Always start logging in with docker:

docker login

Then pull the container by running:

docker pull bot_container:tag

e.g.:

docker pull harbor.teamwire.eu/bots/rssbot:1.6.0

Then run the bot container specifying the API key, secret and server where is hosted:

docker run --rm --name my-example-bot \
-e TW_API_APPID="your app id" \
-e TW_API_SECRET="your secret" \
-e TW_API_HOST="your backend hostname" \
example-bot

ie.:

docker run -d --restart always --network host --name barcodebot \
-e TW_API_APPID="*************************************" \
-e TW_API_SECRET="***************" \
-e TW_API_HOST="https://backend.teamwire.eu" \
harbor.teamwire.eu/bots/rssbot:1.6.0

bots/echobot

The echobot is a good entrypoint for developers getting into the Teamwire SDK. It just echoes every message and attachment received.

The echobot is included with the SDK as echobot.py, no need to download the examples source code file.

Topics covered

  • How to listen for new messages
  • How to receive messages
  • How to check for attachments received
  • How to send attachments
  • How to send new messages
  • How to check for alert messages

bots/flicbot

flicbot is a bot that easily integrates with flic buttons, so when the user performs an action on the button it sends a message to a chat. Both the message and the chat are configured via flic app and are unique per button.

Topics covered

  • How to listen for https requests from the bot and react accordingly
  • How to get information from the request
  • How to search chats by title
  • How to send messages to an existing chat

You can test the bot using curl:

curl -H "Authorization: #YOUR_AUTH_KEY#" \
     -d "hello from flicbot" \
     -X POST https://YOUR_SERVER/flicbot/chats/CHAT_TITLE/message

Replace #YOUR_AUTH_KEY# by the bot secret obtained in the Teamwire admin panel, YOUR_SERVER by the name of the machine running the bot (i.e. localhost) and CHAT_TITLE by the title of an existing chat.

Setup flic buttons

Once the flicbot is running, you need to set up your Flic button:

  1. Install the flic app in your phone and pair the flic button following their instructions.
  2. In the flic app, select the flic button and you will see a list of actions (Click, Double Click, Hold). Select Click pressing the "+" button.
  3. In the list of apps shown, go to "Advance" and select "Internet Request". Fill the fields with this data:

    • URL: https://YOUR_SERVER/flicbot/chats/CHAT_TITLE/message. (Replace YOUR_SERVER with your backend url and CHAT_TITLE with the title of your chat defined above.)

    • Method: select POST

    • Body: Insert here the message you want to receive when the button is clicked
    • HTTP Headers: we need 2 headers, add each of them and press INSERT:
      • Key: Authorization, value: copy here the bot SECRET from the admin panel
      • Key: HOST, value: flicbot

Press "Done" in the top-right corner (otherwise changes won't get saved) and you are ready to test the button!

Now close the flic app and click the flic button. If everything was correctly set, you should receive the button message.


bots/gitlab-bot

gitlab-bot integrates Teamwire chats with GitLab. It allows members of a chat to view, list and create issues in gitlab using commands in a Teamwire chat.

Topics covered

  • How to receive commands
  • How to connect to a 3rd party API

Supported commands

/help shows info about supported commands /view project#issue_id shows info about given issue in given project /view project!merge_request_id shows info about given merge request in given project /new project issue "issue_title" "issue_description" creates a new issue with given title and description in given project /list project issues label:actual_label show info about all the opened issue with given label in given project


bots/giphybot

giphybot connects with Giphy API to return a random animated gif of any specified topic

Topics covered

  • Receive commands
  • Connect to a 3rd party API
  • Send gallery attachments

Add giphybot to a chat, then send /gif topic to receive an animated gif related to that topic.


bots/barcodescannerbot

barcodescannerbot scans a picture received and looks up for barcodes contained in it. If a barcode is found, it responds with the content of the barcode.

Topics covered

  • Receive gallery attachments
  • Integrate with 3rd party libraries
  • Send messages

Add barcodescannerbot to a chat, then use the Teamwire camera to capture a picture containing a barcode and send it.


bots/tvbot

This example demonstrates how Teamwire bots can be used to show information in displays in open spaces and common areas. This kind of sollution can be used in control rooms, showrooms, hospitals, etc. where we want to allow some special users to share information in a public way in a place everybody can see it.

tvbot extracts alert messages received by the bot and shows them in a website. The bot itself serves this website, designed to run fullscreen in a large display.

The only thing required is a browser pointing to the bot URL.

Apart of the usual environment variables, set a new TW_WEB_PORT env var with the port where it should be listening for requests:

docker run -d --restart always --network host  --name tvbot \
-e TW_API_APPID="YOUR APP ID" \
-e TW_API_SECRET="YOUR API SECRET" \
-e TW_API_HOST="https://backend.teamwire.eu" \
-e TV_WEB_PORT="8081"  \
harbor.teamwire.eu/bots/tvbot:1.6.0

Once the bot is running, point your browser to the bot's machine, indicating the port (i.e. http://localhost:8081) and send some alert message to the bot. The website should be updated with the message received.

Download source code