Solved

How to send an HTTP request to Google Chat when inventory changes?

jamesroberts
Tourist
11 0 3

I'm attempting to set up a workflow that is triggered when inventory quantity changed, and if the total inventory is less than 1, Send HTTP Request to Google Chat.

 

The step I'm having difficulty with is the last "Send HTTP Request".

 

In Google Chat, I go to the space where I want the message posted > Manage Webhooks > Create webhook. I give it a name, and Google Chat only provides the below URL (I've edited some of the characters, so this is not the exact URL).

 

I'm unsure if I need to include something else in the headers (i.e. the token value in the URL, the key value in the URL, etc.). If I include the token and/or key value in the headers, should they be removed from the URL?

 

Shopify Flow Action details:

 

Send HTTP Request

 

HTTP method: POST

 

URL: https://chat.googleapis.com/v1/spaces/ABCDSExMHiU/messages?key=AIzaSyDdI0hCZtE6vyAbCd-WEfRq3CPzqKqqs...

 

HEADERS

Key: Content-Type

Value: application/json; charset=UTF-8

 

Body:

Zero Inventory - {{productVariant.product.title}} {{productVariant.sku}}

 

{{productVariant.inventoryItem.inventoryHistoryUrl}}

Accepted Solution (1)

paul_n
Shopify Staff
1064 136 251

This is an accepted solution.

Cool use case. I think you need to look at the Google Chat API spec. It appears the body must be JSON: https://developers.google.com/chat/api/reference/rest/v1/spaces.messages#Message 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.

View solution in original post

Replies 3 (3)

paul_n
Shopify Staff
1064 136 251

This is an accepted solution.

Cool use case. I think you need to look at the Google Chat API spec. It appears the body must be JSON: https://developers.google.com/chat/api/reference/rest/v1/spaces.messages#Message 

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.
jamesroberts
Tourist
11 0 3

Thanks @paul_n, that worked.

 

I'm not familiar/comfortable with JSON whatsoever, but my first attempt worked. I'll adjust formatting and work on adding more useful information in the body, but thanks again!

 

Updated body:

{
"text": "zero inventory {{productVariant.sku}}"
}

Keemtaker
Shopify Partner
6 0 0

If you want to get order notifications in Google Chat without using webhooks, you can try out the app https://apps.shopify.com/notify-google-chat