[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Successor to CentOS] AlmaLinux OS server construction/migration service

[Successor to CentOS] AlmaLinux OS server construction/migration service

[For WordPress only] Cloud server “Web Speed”

[For WordPress only] Cloud server “Web Speed”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Reservation system development] EDISONE customization development service

[Reservation system development] EDISONE customization development service

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[Global exclusive service] Beyond's MSP in North America and China

[Global exclusive service] Beyond's MSP in North America and China

[YouTube] Beyond official channel “Biyomaru Channel”

[YouTube] Beyond official channel “Biyomaru Channel”

Copy tasks from ChatWork to Backlog

Hello, this is Goto from the Web System Development Department.

Our company uses ChatWork, and even if tasks are assigned on ChatWork,
if there are a large number of tasks, they may get lost, or it may be difficult to understand priorities, deadlines, etc.

On the other hand, Backlog allows you to manage tasks using a Gantt chart, making it easy to understand deadlines, importance levels, etc.

So, I wrote
a process to move tasks from ChatWork to Backlog so I hope it will be helpful for those who are trying to use ChatWork API or Backlog API.

I will introduce each function.

1. Get tasks from ChatWork

Four pieces of information are required to retrieve tasks from ChatWork.

  • Account ID of the person assigned the task
  • Account ID of the person who assigned the task
  • ID of the chat room where the task was assigned
  • Selecting completed or uncompleted tasks

Each of these information can be obtained from below.

  • The number after To: for the person assigned the task
  • The number after To: to the person who assigned the task
  • https://www.chatwork.com/#!ridThe numbers here (rid is not required)
  • Completed done : Not completed open

By attaching these to the URL as GET parameters and making a request, task information will be returned in json format.

function get_tasks_from_cw($account_id, $assigned_by_account_id, $room_id){ $params = array( 'account_id' = $account_id, //ID of the person assigned the task 'assigned_by_account_id' = $assigned_by_account_id, //ID of the person assigned the task ID 'status' = 'open', //unfinished tasks ); $url = 'https://api.chatwork.com/v1/rooms/'.$room_id.'/tasks?'.http_build_query($params ); $headers = array( 'http' => array( 'method' = 'GET', 'header' = implode("rn", $headers), ) ); $json_cw_tasks = file_get_contents($url, false, stream_context_create ($context)); return json_decode($json_cw_tasks); }

2. Register the issue to Backlog

The following items are required to register to Backlog.

  • ID of the registered project
  • ID of issue type
  • priority
  • Assignment subject

Set these as shown below.

    • The ID of the registered project is determined from the URL of the project's "Project Settings" page.

https://byd.backlog.jp/EditProject.action?project.id=Number here

    • For assignment types, see 2-a.
    • Priority 2 is high, 3 is medium, 4 is low
    • Feel free to choose the subject
function add_task_to_backlog($task, $project_id, $backlog_api_key){ $issue_type_id = get_issue_type_id_of_tasks($project_id); //Get issueTypeId of the task mb_regex_encoding('UTF-8'); $params = array( 'projectId' = $project_id, 'issueTypeId' = $issue_type_id, 'priorityId' = 3, //Priority medium 'summary' = 'Task from ChatWork', 'description' = $task['body'], //Contents of the issue to be registered (CW Task text (body)) ); $url = 'https://space_name.backlog.jp/api/v2/issues?apiKey='.$backlog_api_key'&'.http_build_query($params, '&' ); $header = array('Content-Type:application/x-www-form-urlencoded'); $context= array( 'http' => array( 'method' = 'POST', 'header' = $header , 'ignore_errors' = true, ) ); file_get_contents($url, false, stream_context_create($context)); }

2-a. Get the issueTypeId of the issue type "task"

The type of issue depends on the project, so get the issueTypeId for that project from the API.
This time, we will get the issueTypeid of the type "task".

*There is no need to use curl here. I just tried it.

function get_issue_type_id_of_tasks($project_id, $backlog_api_key){ $param = array('apiKey' = $backlog_api_key); $url = 'https://space_name.backlog.jp/api/v2/projects/'.$project_id.'/ issueTypes?'.http_build_query($param); $ch = curl_init(); $options = array( CURLOPT_URL = $url, CURLOPT_HTTPGET = true, CURLOPT_HTTPHEADER = array( 'HTTP/1.0', 'Content-Type: application/x- www-form-urlencoded', ), CURLOPT_RETURNTRANSFER = true, ); curl_setopt_array($ch, $options); $issue_type_json = curl_exec($ch); $issue_types = json_decode($issue_type_json); The return value is the ID of the "task". foreach ($issue_types as $issue_type) { if ($issue_type->name == 'task'){ $issu_type = $issue_type->id; } } return $issu_type; }

It's roughly like this.

ChatWork's tasks can get the due date as a timestamp from the limit_time element, so
I think it would be convenient to convert it when registering the backlog and put it in the dueDate parameter and register it so you can copy the due date as well.
Please try expanding it.

If you found this article helpful , please give it a like!
0
Loading...
0 votes, average: 0.00 / 10
735
X facebook Hatena Bookmark pocket
[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

The person who wrote this article

About the author