strakers / zendesk-drupal-webform

Adds the ability to create Zendesk tickets from Drupal Webforms
https://packagist.org/packages/strakez/zendesk-webform
MIT License
2 stars 4 forks source link

Allow to set a group instead of an agent as the assignee #47

Open jlariza opened 2 years ago

jlariza commented 2 years ago

Good day,

Right now, we may only select an agent as the assignee of the ticket. However, Zendesk allows to set whole groups as the assignees.

Ideally, the handler configuration should list and allow the group to be used as the assignee along with the agent.

Right now, the only alternative would be to select one of the group's agent as the assignee but this is not ideal considering that if there are a lot of tickets, that agent may be overwhelmed.

I tried extending the current functionality, editing src/Plugin/WebformHandler/ZendeskHandler.php:160 with

            $response_agents = $client->users()->findAll([ 'role' => 'agent' ]);
            $response_admins = $client->users()->findAll([ 'role' => 'admin' ]);
            $response_groups = $client->groups()->findAll();
            $users = array_merge( $response_agents->users, $response_admins->users, $response_groups->groups);

it list the groups properly. However, when sending the ticket to zendesk, the API response message is 422 Unprocessable Entity:Assignee: is not a member of the group this is the whole message received by src/Plugin/WebformHandler/ZendeskHandler.php:604

Client error: `POST https://ncarbhelp.zendesk.com/api/v2/tickets.json` resulted in a `422 Unprocessable Entity` response:<br />
{&quot;error&quot;:&quot;RecordInvalid&quot;,&quot;description&quot;:&quot;Record validation errors&quot;,&quot;details&quot;:{&quot;assignee&quot;:[{&quot;description&quot;:&quot;Assignee: is no (truncated...)<br />
 [details] {&quot;error&quot;:&quot;RecordInvalid&quot;,&quot;description&quot;:&quot;Record validation errors&quot;,&quot;details&quot;:{&quot;assignee&quot;:[{&quot;description&quot;:&quot;Assignee: is not a member of the group&quot;}]}}

Thank you,

jlariza commented 2 years ago

I created this PR to add this feature https://github.com/strakers/zendesk-drupal-webform/pull/48

strakers commented 2 years ago

Hi @jlariza, thanks for this contribution. Before accepting, I'm going to run a couple tests to verify that the unique interactions of Zendesk groups and assignees play nicely together. Once this passes, I'll accept the pull request. Thanks again!

jlariza commented 1 year ago

@strakers any news about this feature?