HomeDev guideRecipesAPI Reference
Dev guideUser GuidesLegal TermsNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev guide

Use case: Vercel deployment

Example use case of using Vercel webhooks with Optimizely Graph.

A deploy hook in Vercel lets you programmatically trigger deployments of your projects. Registering this deploy hook with the Optimizely Graph webhook API lets you automate deployments whenever specific events occur, such as content updates or changes to your data source.

Create a deploy hook

To create a deploy hook in Vercel complete the following:

  1. Log in to your Vercel account. You can sign up for free if you do not have an account.

  2. Create a new project or select an existing project on the Vercel dashboard where you want to set up the deploy hook.

  3. Generate a deploy hook URL.

    1. Go to the project settings by clicking on the project name in the Vercel dashboard.
    2. In Deploy Hooks, click Add or Create Deploy Hook to generate a new deploy hook.
  4. Configure the deploy hook.

    1. Provide a name for the deploy hook to identify its purpose (such as Optimizely Graph Deploy).

    2. Set the target branch or branches where the deploy hook should be triggered. You can specify a branch or use a wildcard character to match multiple branches.

  5. Save the deploy hook configuration.

  6. Copy the generated deploy hook URL. This URL registers the webhook with the Optimizely Graph webhook API.

Register deploy hook with Optimizely Graph webhook API

Regeristing the deploy hook with Optimizely Graph lets you create seamless automation in your development workflow. To register the deploy hook with the Optimizely Graph webhook API using the provided endpoint to trigger deployments based on specific events from Optimizely Graph:

  1. Use a tool or library of your choice (such as cURL, Postman, or an HTTP client library) to make a POST request to https://cg.optimizely.com/api/webhooks.
  2. Use either Basic or HMAC authentication within the request.
  3. In the request payload, include the necessary parameters, including the URL endpoint obtained from Vercel for the deploy hook in the previous section and any other configurations specific to your deployment needs.
  4. Send the request and await a response from the Optimizely Graph webhook API.
  5. After registration, the API responds with the details of the registered webhook, including its unique identifier.

Ensure you handle any potential errors or exceptions during the registration process and validate the response from the Optimizely Graph webhook API to ensure a successful integration.

Test the integration

To test the integration between Vercel deploy hooks and the Optimizely Graph webhook API using the Optimizely CMS Dashboard:

  1. Go to the Optimizely CMS Dashboard for your project. Using the Optimizely CMS Dashboard to modify a content item, you can simulate a scenario and validate that the webhook integration between Vercel and the Optimizely Graph webhook API functions correctly. This ensures that deployments are triggered automatically when content changes, streamlining your development workflow.

  2. Make changes to a content item that should trigger a deployment. For example, you can update the content, change metadata, or modify the structure of a content type.

  3. Save the changes in the Optimizely CMS Dashboard. This action triggers a webhook event and notifies Vercel to start the deployment process.

  4. Monitor the Vercel deployment logs or any relevant output to ensure Vercel received and processed the webhook event.

  5. Verify that the deployment of your project occurs as expected on Vercel.

Handle potential errors or exceptions during the webhook event processing and deployment process. Also, you should review the Vercel deploy hooks documentation, the Optimizely Graph webhook API, and Optimizely CMS for information on monitoring and troubleshooting.