Using Webhook / Deal Property Changed - Deal Stage

deals

#1

I’m trying to use the UI to set up a webhook that will trigger on a change in the Deal Stage.

I have setup to monitor the following:

Object: Deal
Event: propertyChange
Property Name: Deal Stage

and also tried…

Object: Deal
Event: propertyChange
Property Name: dealstage

Neither is triggering when I drag a deal to a new stage or even if I open the deal manually and set the deal to a different stage.

Both subscriptions are active, and the “test” webhook works properly. I’m using Zapier if that matters to catch the hook.

Any idea what could cause them to not be triggered? How can I fix?


#2

@cre Have you installed the app into the portal you wish to watch? Because dev portals can be used for multiple instances of HubSpot you need to install it into which portal/instance you want to watch.


#3

i have not! this is just supposed to be an internal app for our own use. i cannot find any documentation on how to implement the solution this way. how do i install in a dev app, and then (more importantly) can i install in our own production instance, or once it’s produced does it have to be released to the entire world?


#4

@cre You can install in in a test portal or your production portal. No it does not have to be released to the entire world. No one else would have your client ID or secret to be able to install it anyways. Here are some docs on our oauth 2.0 set up. You will need to use oauth to install it and log in to which hubspot portal you wish to install it into.


#5

okay… so i am using the following URL:

https://app.hubspot.com/oauth/authorize?client_id=[CLIENT-ID]&scope=contacts&redirect_uri=https://www.hubspot.com

the app is setup to use the following scope: Read from and write to my Contacts

i have authorized the app in both a test/trial portal AND our production portal (low risk since i’m just sending a webhook)

the app still shows zero installs and is not triggering any webhooks.

also, i cannot find out where to “de-authorize” the app or any indication that the app is installed in my instance. is there somewhere i can look to confirm this and/or de-authorize?


#6

If it says there are no installs then you must not have set up the oauth connection correctly to install it. When you make the connection you would need to pass the client secret along as well.


#7

I don’t see any instructions on how to pass the client secret on the page you referenced above. How is this done?


#8

Remember, I’m not trying to create a full-featured app in this scenario, I really ONLY need to be able to trigger webhooks.


#9

@cre When I go through an app install for ex., I write it in NodeJS. I use passport as the middle ware which allows you to create a hubspot strategy in which you can pass along the secret with the ID.

I’ve also posted some example code in a previous post on the forum.


#10

okay, i get that you are doing all this for an app that is installed somewhere. for that use case, the oauth 2.0 logic makes sense to me fine.

but here, i’m ONLY trying to trigger webhooks.

i have NO code at all to process anything.

so… when i follow the instructions on your oauth 2.0 page, my callback is really hubspot itself, no?

so my URL is correct, right?

https://app.hubspot.com/oauth/authorize?client_id=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&scope=contacts&redirect_uri=https://www.hubspot.com (X’s replace real data)

and after going to that and authorizing, i get redirected to the following URL:

https://www.hubspot.com/?code=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX (X’s replace real data)

presumably, the querystring “code” is the “token” to be used for future calls… IF i was writing an app that needed a token.

but, i’m not making any calls at all. in fact, there are no inbound, external calls at all to the hubspot system. this is literally only to entice hubspot to make an external, outbound call to another system once triggered.

this webhook idea is extremely helpful to us, if we can get it to work, b/c right now we have to poll hubspot frequently to find out when deals are moved between stages to trigger workflows in different areas.

but it is starting to sound like you didn’t really intend on just supplying the pure webhook functionality, but instead meant it to be part of some other app ecosystem? maybe our use case just isn’t supported yet?

all i want is to be able to trigger a webhook every time a deal is moved from one stage to another. maybe there’s a simpler way and i jumped in a bit too deep at the beginning?


#11

@cre I do not have a full app. I am just referring to the oauth flow of how to install your hubspot dev app that contains your webhook. I am sorry if you do not find this user friendly. Also the “code” is not the token which you are right you do not need. Your use case is most definitely supported but you will need to write some code to pull it off.


#12

i’m still not following how the nodeJS code and/or passport fit into the equation.

to be clear, i AM getting the “authorization” dialog when i use the URL indicated in the link you sent entitled “Initiate an Integration with Oauth 2.0”

let me see if i can explain better what’s happening.

you sent the following link: http://developers.hubspot.com/docs/methods/oauth2/initiate-oauth-integration

on that link it says:

Sending a user to this URL will ask the user to approve access to contacts and workflows:
https://app.hubspot.com/oauth/authorize?client_id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&scope=contacts%20automation&redirect_uri=http://www.hubspot.com

If they grant access, the user would be redirected to this URL:
http://www.hubspot.com?code=xxxx

If there are any problems with the authorization, you’ll get the error parameters instead of the code:
http://www.hubspot.com?error=error_code&error_description=Human%20readable%20description%20of%20the%20error

okay, so here’s what i do…

i created a link similar to the first one shown in the instructions. it looks like this: https://app.hubspot.com/oauth/authorize?client_id=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX&scope=contacts&redirect_uri=https://www.hubspot.com

when i go to that link in a browser, i get:

seems like it’s working…

after i click “grant access” i get this page:

this has my token code.

now, if i go back and try to re-authorize, by going to the original URL, i get this:

and then this… (via redirect)

so this tells me that i have already authorized the app for this portal.

if i create a new portal, then i have to start all over again, but once it’s been authorized, i never get the “grant access” button again for the same app in the same portal. as i have mentioned before, i still don’t see how to “revoke access” once it’s been granted.

either way, when i go back to the developer portal, i’m still not seeing any installs.

so again, i’m not following what on earth the nodeJS code does for me.

the only line of code that seems to do anything is this one:
User.findOrCreate({ email: json_response.user, hub_id:json_response.hub_id, access_token:accessToken, refresh_token: refreshToken }, function (err, user,created) { return done(err, user); }

i don’t see any documentation on the hubspot api page referencing the User.findOrCreate function either.

i’m guessing that this is some internal function that somehow adds the email address of the USER into the APP somehow and pairs them up in some way.

if that’s the case, isn’t there some REST URL i can use instead of trying to implement this nodeJS code? or maybe send it back to hubspot using postman or something like that?

if i try to hit this URL using postman with a GET: https://api.hubapi.com/oauth/v1/access-tokens/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX (using the token received above)

then i get the following response…

{
  "status": "error",
  "message": "The access token must have the correct format",
  "correlationId": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
  "requestId": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}

if i then try to use POST via postman on the same URL, but attempt to populate the JSON and send as a RAW Body, something like this:

{
"email":"my@email.com",
"hub_id":"test-portal-hub-id",
"access_token":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"refresh_token":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
}

i get an error back: 405 Method Not Allowed

perhaps you could share with me how to implement this via postman using a REST API call instead of using nodeJS and passport?

it seems like i’m missing one small piece here in the middle of this to add the hub_id and the email to the app somehow.


Install an App from hubspot into clients hubspot account
#13

@cre
Yes, you can use postman to finish off this flow. Once you receive the code you then have to make the call to the next(and final) endpoint in oauth.

This is part of a normal Oauth2 flow. Passport handles all of this for you. My apologies if it was coming across as to complicated or overly-complicated. Here is an example of a call in postman in addition to the docs I linked above.

and the headers


Trouble Installing Developer App - Bad Auth Code
Need Data Connection String
#14

ok so once i have the tokens… then what? how do i link up the hub_id and the email to the app?

i feel like i’m missing some small piece in here that is probably really simple.


#15

@cre It should be installed now! Please check your dev portal and see if the app was installed.


How to deploy an app with a webhook?
#16

i’m not sure i follow. i show zero installs, zero subscriptions, and zero events.

did you do something on the back-end that i’m missing?


#17

@cre I did not. I hit that first url to get the code and then I used the code to generate the install with the call i posted above in Postman.


#18

when i follow your instructions in postman, i get:

{
  "status": "INTERNAL_SERVER_ERROR",
  "message": "internal server error",
  "correlationId": "7ba33a03-2bfd-48b3-bff3-e88599d062f5",
  "requestId": "13d5669d0be72b36c221866de3ecfb45"
}

i tried it with several different code values from both live and test portals.

same result.

here are my postman settings:


#19

Is that a fresh code you are using? I would try and run both steps, one right after the other. The only time i’ve ever received that error is when I have an old code as they expire.


#20

yes i just re-ran.

HOWEVER… remember i’m not getting the “grant access” button anymore b/c they are already authorized.

i will try with a fresh test portal and see if it works…