Get Inspire insights from former attendees in our AMA discussion thread on Inspire Buzz. ACEs and other community members are on call all week to answer!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Google Chat webhooks via download tool

cgoodman3
14 - Magnetar
14 - Magnetar

Could someone help me understand how to set up the download tool to do a http POST request to publish a post in Google Chat via webhooks?

 

I've found this documentation on how to do it in python, and I've tested it that way and it works fine. But I was wondering if there's a way to replicate this setup using the download tool?

 

I'm passing in a field called JSON which has this string in it:

http_obj.request(uri='url',method='POST',headers={'Content-Type': 'application/json; charset=UTF-8'},body=('test'))

and the URL into the download tool, but I get a 400 bad request response and the following in the DownloadData:

 

{
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unexpected token.\nhttp_obj.request(uri\n^",
"status": "INVALID_ARGUMENT"
}
}

 

Config of the download tool shown in the screenshots below.

Capture3.PNGCapture2.PNGCapture.PNG

 

Thanks in advance

Chris
Check out my collaboration with fellow ACE Joshua Burkhow at AlterTricks.com
3 REPLIES 3
cgoodman3
14 - Magnetar
14 - Magnetar

Ok I've solved it with a little bit of trial and error.

 

From the python script you get these lines for the request:

 

    response = http_obj.request(
        uri
=url,
        method
='POST',
        headers
=message_headers,
        body
=dumps(bot_message),
   
)

 

Then in the download tool the set up is as follows, working from the top of the python code:

 

Set the uri bit up via a text input tool where you put your webhook url, and configure the download tool to take that field.

 

Capture 4.PNG

 

Then the method of the http action is set up as 'POST' in the payload tab

 

Capture 6.PNG

 

The headers to tell the download tool to send the request in json is set up in payload

Capture 5.PNG

 

Then the body is provided in a text input tool (I've used the same text input tool as the uri), and in the payload tab you select 'Take the query/body from a field'

 

Capture 7.PNG

 

 

 

Chris
Check out my collaboration with fellow ACE Joshua Burkhow at AlterTricks.com
AkisM
10 - Fireball
Spoiler
 

@cgoodman3 Doesn't work for me unfortunately, keep getting a "400 bad request" error, specifically:

 

{
"error": {
"code": 400,
"message": "Invalid request token 4akAffK9_AcLjK_39JqG2xvodXM2iSCdEqZ1T4lDwFk%3D",
"status": "INVALID_ARGUMENT"
}
}

 

Followed all your screenshots/instructions and my setup is pretty much the same (except for the URL obviously which i got from my webhook). The URL was copy pasted from the webhook in its entirety, and I checked it manually too, so I don't see how the token could possibly be wrong. Could this have something to do with the way the google suite permissions are set up by my organization?

 

EDIT: Resolved. I didn't noticed I had "encode URL" checked. I have however another query. How do you set this up to not send the msg in a new thread, but just send it to the current thread of the chatroom instead?

cgoodman3
14 - Magnetar
14 - Magnetar

When you make your first post using the web hook in the response from the successful API call is details about the thread id.

 

For example 

"thread": {
        "name": "spaces/{spaceid}/threads/{threadid}"
    }

Where {threaded} is a unique id for your thread. So you can parse this out from the download headers section. Then according to the web hook documentation you need to include a threadKey parameter so the webhook becomes 

 

https://chat.googleapis.com/v1/spaces/SPACE_ID/messages?threadKey=ARBITRARY_STRING

 

Where you include threadKey as a parameter in the download tool.

 

Note: You need the chat room to have threaded replies turned on.

Chris
Check out my collaboration with fellow ACE Joshua Burkhow at AlterTricks.com
Labels