[PYTHON] [Choregraphe] Created a box where you can post any message to ChatWork

Introduction

I created my own box with Python Script so that I can post a message from Pepper to ChatWork, so I will introduce it. By using this box, you can put a mechanism in your application to send arbitrary message data to ChatWork.

For example, if you are using Pepper at the reception desk, if you select a person who is making an appointment, a message addressed to that person will be sent to the chat work, or Pepper's murmur will be sent to the chat work at regular intervals in the solitary state. Various uses are possible.

How to use

We have prepared a link at the bottom and published the sample application and box on Github, so please refer to that. I won't put it here, but the box code itself is very simple. (Please feel free to expand)

What to prepare

Sample box configuration

スクリーンショット 2015-09-15 12.58.43.png

input

output

Enter an arbitrary string in "Text Edit" and send the value to the box called "ChatWork POST". After that, use the Python module called urllib2 from that box on the receiving side to set the header information and data and send the request.

Handle exceptions with except.

For detailed information on ChatWork API such as endpoints, please refer to this document.

ChatWork API documentation

I'm not doing anything special, so I think GET and other public Web APIs are also typed.

Box parameters

When sending, it is necessary to set the endpoint and API token, but here it is possible to input the dialog as a "variable" of the box. Click the spanner icon in the box and enter each.

スクリーンショット 2015-09-15 13.59.07.png

name type detail
Room String Room ID
API-Token String Used for authentication

Please also refer to the "ChatWork API documentation" for how to obtain an API token. The room ID has a unique value set for each chat room.

Run

It will be executed when it is ready.

スクリーンショット 2015-09-15 14.40.51.png

** Character strings flow from "TextEdit" ~ **

スクリーンショット 2015-09-15 14.54.27.png

** Posted on "ChatWork" ~ **

スクリーンショット 2015-09-15 14.41.58.png

** The response is returned in the following JSON format ~ **


{
  "message_id": 1234
}

** End ~ **

Sample project

https://github.com/king-panda/chatwork_post

Operation check environment

Recommended Posts

[Choregraphe] Created a box where you can post any message to ChatWork
What you can understand because you are a beginner How to create a file (first post)
Post a message to Google Hangouts Chat with a thread (Python)
[Free to use] 7 learning sites where you can study Python
Post a message from IBM Cloud Functions to Slack in Python
Created a Discord bot to notify you of updates to become a novelist
I made a LINE stamp where you can study Linux commands
Check if you can connect to a TCP port in Python
Created a service that allows you to search J League data