Does anyone know of a good tutorial for creating a webhook that syncs Prismic data with Algolia?
I know it can be done by using a webhook that's triggered on content change but I've had trouble finding a walkthrough on how that webhook is created in the first place. I'd appreciate if someone knows of a tutorial.
I am also looking for the same since we have a poor search functionality in prismic.
Hello @dhayes, @todeepthydon. Thanks for opening this conversation.
I'll add a ping to the backlog for new learning resources.
Hi, is there an update on this request? This looks something I'll need in coming future. It would be great to have an idea how this can work together: Next, Prismic, Algolia. Thank you
There's been no change here. I'm reaching out to our team to see if they have any experience or tips.
@Phil Can you bump this up for us? Given the fact that Prismic's full text search seems to have a permanent seat on the struggle bus, it'd be nice to get some help in hooking up the webhook to Algolia.
I'm assuming that (given the fact that prismic.io uses Algolia), this integration has been done, so even if we could get some pointers about how that integration happened, that'd be swell. Thanks!
Hey @jason.clark. Here are some recommendations from our DevX team!
Whenever a website is rebuilt, send all documents from the Prismic repository to Algolia for indexing. This can take the form of a script that runs before or after the website’s primary
npm run build script. The script should perform the following:
- Query all Prismic documents. If only certain documents map to pages within the website, only query those documents.
- Assign an
objectID property to each document (required by Algolia). The Prismic document’s
id property should be sufficient depending on your Algolia index’s setup
- Assign a
url mapping the document to a URL within the website. If the website uses a Prismic Link Resolver to generate URLs, that Link Resolver should be used in this step.
- Prune any document properties that should not be indexed. For example, the
alternate_languages properties may cause issues when searching.
- Push the documents to an Algolia index.
The index is now available for searching via one of Algolia’s packages.
I wrote this article that explains pretty much the above process but with an agnostic approach and code examples (not relying on Prismic):
We hope you find this information useful!
Thank you, I'll have a look