set assignee from webhook data
Asked by fishern:

a bit of an odd request, but we have a live chat tool that I can extract data from a webhook when the chat ends. I am using this to create a ticket in Jira, however I am not able to map the assigned technician easily.

I am able to post the agent's name in the description of the newly created ticket so I thought I would try to setup a table to map this. I've tried email and Atlassian ID but no dice.  
![table.png](/t5/image/serverpage/image-id/334138iC89E715C80EE308F/image-size/large?v=v2&px=999 "table.png")  

here is a snippet from the edit part of the rule  
![edit.png](/t5/image/serverpage/image-id/334139i7E37270335C90EDB/image-size/large?v=v2&px=999 "edit.png")  

looking for any ideas how to pull this in for editing the assignee of the tickets.   

ps. this works fine and displays the agent name:  
![description update.png](https://community.atlassian.com/t5/image/serverpage/image-id/334140i8E740ABB1E0D1920/image-size/large?v=v2&px=999 "description update.png")


Answers:
author: Mikael Sandberg
body: Is the lookup returning the agent based on the webhookData? If not, could it be the case that you have a white space in the result from the webhookData for the assignee? If you add .trim does that change anything?

comments: author: fishern
body: The payload is presenting the agent name which is what I'm using to post in the description.   
im struggling to sort out how to use that with the table/assignee part of the automation. I figured this was the only way to grab the agent name and change the assignee in Jira


author: Mikael Sandberg
body: You could do a web request to [Find users](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-user-search/#api-rest-api-3-user-search-get) endpoint instead of using a lookup table. The endpoint can search both on displayName and emailAddress.


author: fishern
body: I like this idea, but the user lookup I think would be different as the chat tool uses a different display name than what is showing in Atlassian. Why I figured the table was a good way to go as it seemed to be the only way I can match up the unique information from chat/jira and pump out what i assign.


author: Mikael Sandberg
body: Are you able to get the email address of the assignee from the chat tool?

Have you done a log action to see that data is returned from the lookup table? If it is returning the Atlassian Id of the user then it should work to set the assignee. I am using lookup table to collect data about the reporter that we are using for different things.


author: fishern
body: no, the only thing I can get from the payload is the display name from the chat tool that they are using. The lookup smartvalue I am using is not working at all, just the payload dump is in the description.


author: Mikael Sandberg
body: Okay, so it sounds like there might be a whitespace or something in the payload that is causing the lookup table to not return the Atlassian Id. Depending on how big your team is you may want to use the if/else condition and the smart value compare instead. You could then use {{webhookData.payload.agents.name}} and use the contain compare to set the assignee.


author: fishern
body: this worked like a charm, thank you


author: Iryna Ihnatiuk _Appfire_
body: Hello [@fishern](/t5/user/viewprofilepage/user-id/3939980) ,

Have you ever considered using apps like our [Chat for JSM](https://marketplace.atlassian.com/apps/1218891/chat-for-jira-service-management?hosting=cloud&tab=overview) as a live chat solution? With this app, you can add a live chat widget to Jira Customer Portal or any website/ app. Jira tickets will be created automatically, and all messages will be synchronized with comments, so you won't need to do it manually.

Let me know if you're interested and we can arrange a quick demo.

Thanks,  
Iryna  
Appfire

comments: author: fishern
body: thank you, but we are looking to enhance our chat with a chatbot interlaced before chat. I don't think your tool shows that as a function.


author: said kouzibry
body: Just adding the name like that will not work, you need to use the **accountId** of the user, **[@Mikael Sandberg](/t5/user/viewprofilepage/user-id/853579) provided the solution** , I will expand on that. Do a web request to the user search end point (<https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-user-search/#api-rest-api-3-user-search-get>) then extract the accountId of your user and use that to set the Assignee.

Making a web request to your own site's rest api will require the Authorization header, you will find more information on that here [Basic auth for REST APIs.](https://developer.atlassian.com/cloud/jira/platform/basic-auth-for-rest-apis/)

comments: author: fishern
body: I have tried to use the account ID directly in the table. My issue is the Display name in our Chat tool (where the webhook payload is coming from) does not match the name in Atlassian user list. This is why I wanted to manage this manually.

I am not sure if this is a limitation within Atlassian as I can use the chat tool's automation to create a similar table, spit out the assignee with no issues. I just have to pay for the automation to run so I was hoping to save some cost doing the same thing in Jira.  

I seem to be able to post to the description with the information with no issues, just can't seem to have the Assignee smart value fully correct.


Tags: cloud

jira-service-management

jira-service-management-cloud