Webhooks not being created with shopify_app

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? 

0 Likes
Shopify Staff
Shopify Staff
1555 79 244

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.

1 Like
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!

0 Likes
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.

1 Like
Highlighted
Tourist
5 0 1

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)

0 Likes