ITZone

Chatwork forwarder – The solution to laziness

Chatwork Forwarder is an opensource developed with Laravel framework, helping your project solve the following problems

  1. Send message to Chatwork (private or room)
  2. Receiving payload from another service, extracting data according to user’s conditions and config.
  3. Mapping data to send messages is friendly and easier to understand for readers.
  4. Send a lot of messages at the same time for multiple rooms or private, depending on the user’s config.

If your project is working with chatwork, you need to handle sending messages when receiving input, or simply happening every day when each member in the project sends a Pull Request, they have to TO on the project box. The project requires Review merge Pull, which is repetitive and boring but time-consuming. Chatwork forwarder will help your project solve those problems extremely quickly, just need a few easy config steps.

Let’s take a look at how to use the Chatwork forwarder.

1. Landing page & login

First access the url https://cw-forwarder.sun-asterisk.vn/ is the landing page of Chatwork forwarder, here when not logged in we will see a Login button, you can use any account. Google account to login and start using.

2. Dashboard

After successful login is the dashboard interface showing statistics

  1. Number of webhooks created
  2. Payload number sent
  3. Number of messages sent
  4. Number of bots in use

3. Bots

This is the part of managing and adding a chatwork bot to the system, as we know to be able to send messages to a chatwork requires you to have a chatwork account as a bot, and must get its API token to execute. currently send a message.

Bot Key or API token of the Bot account, you can go to the API settings of the chatwork to get it.

We will use this bot for our example of sending a Pull Request check message in the following sections.

4. Webhooks

At the webhook list screen are the created webhooks, here we can create new webhooks or edit existing webhooks.

For example, I will create a webhook for project XYZ to send a Pull Request message when a member sends Pull. Use the bot that was created at the beginning and TO come to yourself (If you want to go to room, you can choose type room as Group instead of Private )

After the save, immediately we will cross the screen edit webhook , here is a place that allows config components as important as the payload will receive and the conditions for the message to be sent when the payload satisfied and convert data, if necessary in the mapping section

The webhook primary url is created to provide the services we want to receive the payload. copy this url and go to webhook setting on the project github (Only the admin of the project can access this setting)

Note the Content type section will default to applicationi/x-www-form-urlencoded we need to switch back to application / json.

In order to receive payloads every time we have a Pull Request, we need to check the option to Pull requests in github’s settings.

Click Update webhook

5. Payload

This is the most important part that allows config payload, conditions and content to be sent to the chatwork, at each section there will be an example (in green) for you to understand.

For Github to get the sample params payload, we go back to the webhook setting, at the Recent Deliveries section depending on the event that github will return different payloads, here our event is Pull Request.

After copying the sample payload of a PR, we will paste it into the input Payload params. The condition and content sections we can follow are examples so the system can find and read the data you want to retrieve in the pasted payload. For example:

Note: We can use the $ params prefix or not.

So after saving and waiting for a PR, we will receive the TO message to the chatwork

6. Mapping

This is the part that helps you convert data from one value to another, understand simply as the example above we have the user id of 38203330, but you do not want to display that but want instead of 38203330 will display The town is Quach Dai Phuc. Simply config in the mapping section as follows:

In the content of the payload, we can completely configure the mapping value at any time, and not always

Keep the value {!! $ params.user.display_name !!}

Data you want to map {{$ params.user.display_name}}

7. Conclusion

So we have the solution for the mundane daily tasks with a new experience with Chatwork forwarder, in addition to the above example, you can completely use the chatwork forwarder to do many other things if your project has are using chatwork. Above is the entire user guide before use, hoping to be somewhat helpful for you.

8. Contribution

Github https://github.com/sun-asterisk-research/chatwork-forwarder

Share the news now