Notifications to Chatwork
A notification can go to a Chatwork room (Exment 7.3.0 or later). Exment posts a message to the room with the Chatwork API (v2).
- What is sent: the subject and the body of the notification template, and the link to the data. In Chatwork it arrives in a box with the subject as its title (
[info][title]…[/title]…[/info]) - The body is sent as plain text. An HTML template loses its tags
- Chatwork notation in the text of a template or of the data (such as
[To:…]or[/info]) is shown as text: it cannot change the form of the message
1. Turn the feature on
In "Admin Setting" → "Feature Management", set Notifications to Chatwork to "Use". It is not used at first, because the data leaves the site (for Chatwork). While it is not used, Chatwork is not offered as a notify action and nothing is sent.
2. Set the token of the site
- Log in to Chatwork with the account that will post the notifications, and issue a token in "Service integration" → "API Token"
- We recommend making one account only for the notifications (like a bot) and using its token
- The account must be a member of each room the notifications go to
- In Exment, in "System Setting" (Detail Setting), under Chatwork, put the token in API token (new value) and save
- The token is a secret: it is kept encrypted and not shown on the screen again. Saving with the field empty keeps the token
- To remove it, turn on Delete the API token and save
- The token is not written to the operation log either
3. Make the notification
In a notification (Notification):
- Choose Chatwork as the "Notify Action"
- In Chatwork room ID, enter the number after
ridin the address of the room- Example:
https://www.chatwork.com/#!rid123456→123456
- Example:
- (Optional) In Chatwork API token, enter a token for this notification only
- Use it to post as another account. When it is empty, the token of the system setting (the site token) is used
- Like the site token, it is kept encrypted and not shown on the screen
- (Optional) To mention people, choose users in "Notify target" (see "Mentions" below)
An example message:
[To:1234567] Taro Yamada
[info][title]Issue updated[/title]Status changed to In progress
https://exment.example.com/admin/data/pm_issue/423[/info]Notifications made by a table administrator A person who can make notifications (a table administrator, for example) can make a Chatwork notification without a token of their own. It is then sent with the site token, so it can go to any room the site account is a member of, only by entering its room ID. Keep the site account only in the rooms used for notifications. Do not add it to rooms whose talk should not be seen.
Mentions
A notification can mention people in Chatwork ([To:account ID]).
- In the user table, add a column (one-line text) for the Chatwork account ID (a number), and enter each person's ID
- The account ID is a number: the one in
[To:1234567]that Chatwork puts in the message box when you choose the person with "TO" (not the login e-mail address, nor the "Chatwork ID" in letters)
- The account ID is a number: the one in
- In "System Setting" (Detail Setting), under "Chatwork", choose that column in Column with the Chatwork account ID
- Choose users in "Notify target" of the notification. Those who have an account ID (a number) get
[To:ID] name; those who do not are not mentioned
Sending with a queue is recommended
Without a queue (synchronous execution), the screen waits while the message is sent to Chatwork. So, without a queue, the wait is kept short:
- A request may take 5 seconds, and it is tried once more at most
- When Chatwork answers "too many requests" (429: 10 messages in 10 seconds for a room, 300 requests in 5 minutes for a token), Exment waits only when the limit ends within a few seconds. When it lasts longer, the message is not tried again and the bell tells (below)
For notifications sent often, or that must arrive, set up Delayed execution of notification processing (a queue). With a queue, the screen does not wait, the message is tried up to 3 times (a minute and five minutes apart), and on "too many requests" Exment waits as long as Chatwork says before it sends again.
When it is not sent
When it is still not sent after the tries, the user who made the notification gets a notice in the bell (in-system alert); when that user is not known, the system administrators get it. The notice shows the room ID and the reason, never the token.
- "HTTP 401": the API token is wrong or was deleted
- "HTTP 403", "HTTP 404" or similar: the account of the token is not a member of the room, or the room ID is wrong
- "HTTP 429": too many messages. When it happens often, use a queue
- When nothing happens: check that "Notifications to Chatwork" is set to "Use" in Feature Management, and that a token (the site's or the notification's) is set
