Script to process inbound webhook

Just looking for some assistance on writing a script that will process the following inbound JSON into something that RC recognizes. Specifically, I want the message to come through to RC looking like this (going to use variables here so it makes sense what specifically from the JSON I’m looking for):

New Ticket: $client_name/$site_name

Contact: $user_name

Subject: $ticket.$summary


I’m thinking that $details would have to have something like replace(/<a\b[^>]>(.?)</a>/i,"$details") to clean it up. Any help would be appreciated.

  "method": "POST",
  "path": "/",
  "query": {},
   "body": {
    "id": "xxxx",
    "webhook_id": "yyyy",
    "notification_id": 6,
    "escmsg_id": "1234",
    "event": "new ticket logged",
    "message": "New ticket logged for Clever Company ID:001.",
    "object_id": 10011,
    "timestamp": "2021-12-29T21:49:39.6810696Z",
    "ticket": {
      "id": 10011,
      "dateoccurred": "2021-12-29T21:48:07.437",
      "summary": "Windows Issue",
      "details": "Attachment\r\nThere is a Windows issue\r\n\r\nAttachments\r\nScreenshot_tuzj1vgh.jpeg",
      "client_name": "Clever Company",
      "site_name": "Main",
      "user_name": "Benjamin"

Hi! I believe this will help you:

the resulting message will be, in Portuguese :upside_down_face:

you can basically receive any kind of json payload on an incoming webhook, then hack the resulting return as you need.

Documentation for reference:

Yes, thank you, that’s very helpful for the formatting. The only thing it doesn’t help me determine is how to reference the second level of JSON. For example:

   "body": {
    "object_id": 10011,
    "ticket": {
      "id": 10011

How would I access object_id and id since they are levels below. and request.content.body.object_id or something like that?

1 Like

Yup, my guess was right. Thanks I should have it from here!