Webhooks not being created with shopify_app

rs
Tourist
23 0 1

I am trying to create webhooks like so 

  config.scope = "read_orders, read_products, read_customers"
  config.webhooks = [
    {topic: 'customers/create', address: 'https://{url}.ngrok.io/shopify/app/customers_create'}, 
    {topic: 'checkouts/update', address: 'https://{url}.ngrok.io/shopify/app/checkouts_update'},
    {topic: 'orders/create', address: 'https://{url}.ngrok.io/shopify/app/orders_create'}
  ]

But when i install the app and try to create a contact to activate the 'customers/create' webhook, i get no webhooks sent.

 

Im trying to fetch all the webhooks like this and its just empty

		webhooks = ShopifyAPI::Webhook.find(:all, :params => {:limit => 10})
		p webhooks

[]

Am i missing something?

 

UPDATE: I reinstalled the gem and my console says 

RDoc detects ERB file. Skips it for compatibility:
lib/generators/shopify_app/add_webhook/templates/webhook_job.rb

could this be the reason? 

Replies 4 (4)

Alex
Shopify Staff
1561 81 341

Hey Richard.

Let's continue speaking here.

RDoc is a ruby documentation system. There's ERB in that file and it's only a generator used to add webhooks to your config file, I believe it's just skipping the composition of documentation for that file.

I would strongly suggest using a debugger gem like pry to place one or more breakpoints in your code to inspect variables as they execute, or if you could provide me with a request-id that would also be helpful.

It's certainly not a permissions issue, since you're not getting a 401 unauthorized error returned seemingly when outputting your webhooks variable to stdout.

The WebhooksManager kicks off a job which creates webhooks in a fairly standard way, maybe you can try executing this manually in a console session: https://github.com/Shopify/shopify_app/blob/master/lib/shopify_app/jobs/webhooks_manager_job.rb#L8

Cheers.

Alex | Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit the Shopify Help Center or the Shopify Blog

rs
Tourist
23 0 1

Hey Alex! thanks for the reply i was able to make it work by executing the code manually

 

i just ran this

		webhooks = [
			{topic: 'customers/create', address: 'https://85bcff59.ngrok.io/shopify_webhooks/new_contact'}, 
			{topic: 'checkouts/update', address: 'https://85bcff59.ngrok.io/shopify_webhooks/checkouts_update'},
			{topic: 'orders/create', address: 'https://85bcff59.ngrok.io/shopify_webhooks/orders_create'}
		]

		ShopifyApp::WebhooksManagerJob.perform_now(shop_domain: shopify_domain, shop_token: shopify_token, webhooks: webhooks)

And now the webhooks are being created on install, everything seems to work fine now, thank you for helping me out!

pz
Shopify Partner
2 0 1

I have this same issue, but manually executing the WebhooksManagerJob did not work. Even when I create the webhooks with the admin, they still don't show up. They only way Webhook.all will show anything is when I create a Webhook with Webhook.create(hash). Any help would be appreciated.

MougheesHaider
Shopify Partner
11 0 2

Facing same issue, shopify_app gem does queue a job to create webhooks, but it never creates one(at-least i can't see one in the notifications page of the shop)