|

|  How to Integrate Microsoft Azure Cognitive Services with Wix

How to Integrate Microsoft Azure Cognitive Services with Wix

January 24, 2025

Learn to seamlessly connect Microsoft Azure Cognitive Services with Wix in this step-by-step guide, enhancing your website's capabilities effortlessly.

How to Connect Microsoft Azure Cognitive Services to Wix: a Simple Guide

 

Set Up Microsoft Azure Cognitive Services

 

  • Go to the Azure Portal and sign in with your Microsoft account. Create a new resource by selecting the "Create a resource" button.
  •  

  • Search for "Cognitive Services" and select the "Cognitive Services" resource type, then click "Create".
  •  

  • Fill in the essential information including Subscription, Resource Group, Region, and Pricing Tier. Note the "Key" and "Endpoint" values provided upon creation—they will be necessary for integration.

 

Choose Your Desired Cognitive Services

 

  • Go to the "Resources" tab and select your cognitive service. Choose the specific API you wish to use, such as Text Analytics, Vision, or Speech Service.
  •  

  • Explore the documentation of the chosen API to understand its endpoint, required parameters, and how to format requests to the service.

 

Prepare Your Wix Website

 

  • Log into your Wix account and navigate to the dashboard of the site you want to integrate with Azure Cognitive Services.
  •  

  • Consider the part of your site where you intend to use the Cognitive Services, such as input fields for text analysis or image uploads for vision processing.

 

Create a Backend Solution with Wix Corvid (Velo)

 

  • Activate Corvid by Wix (Velo) in your site editor by clicking on "Dev Mode" at the top dashboard.
  •  

  • Create a new "Backend" file in your Wix site by navigating to the Code Files section in the Site Structure sidebar.
  •  

  • Use the following JavaScript code to make HTTP requests to Azure using the APIs. Substitute 'YOUR_KEY' and 'YOUR_ENDPOINT' with the actual values provided by Azure.

 

import { fetch } from 'wix-fetch';

export function callAzureCognitiveServices(data) {
    return fetch("https://YOUR_ENDPOINT/vision/v3.1/analyze", {
        method: 'POST',
        headers: {
            'Ocp-Apim-Subscription-Key': 'YOUR_KEY',
            'Content-Type': 'application/json'
        },
        body: JSON.stringify(data)
    })
    .then(response => response.json())
    .then(json => {
        console.log(json);
        return json;
    })
    .catch(error => {
        console.error('Error:', error);
    });
}

 

Integrate Frontend Elements in Wix

 

  • Add user interface elements using Wix's editor, such as text boxes or upload buttons, to gather input data for the API.
  •  

  • Link these UI components to your Corvid backend functions by using event handlers. For example, add a button to trigger the API call from the frontend:

 

$w.onReady(function () {
    $w("#yourButtonId").onClick(() => {
        const data = {
            url: $w('#inputFieldId').value
        };

        callAzureCognitiveServices(data)
            .then(response => {
                $w('#outputFieldId').text = JSON.stringify(response);
            });
    });
});

 

Test and Deploy Your Integration

 

  • Within the Wix editor, test your site to ensure the integration functions correctly. Check console logs and displayed data for any errors or unexpected behavior.
  •  

  • Once confirmed working, publish your site, and the integration will be live and functional for users.

 

Omi Necklace

The #1 Open Source AI necklace: Experiment with how you capture and manage conversations.

Build and test with your own Omi Dev Kit 2.

How to Use Microsoft Azure Cognitive Services with Wix: Usecases

 

Enhance Website Accessibility and Engagement

 

  • Integrate Microsoft Azure Cognitive Services with a Wix website to enhance accessibility features, such as real-time text-to-speech conversion for visually impaired users, and automatic transcription of video content for those with hearing difficulties.
  •  

  • Utilize Azure's Computer Vision API to provide alternative text for images, making the content more accessible and searchable, thereby improving user engagement and SEO rankings.

 

Step-by-Step Implementation

 

  • Create an Azure account and access the Cognitive Services dashboard to generate API keys for the services you plan to use, such as Speech and Computer Vision.
  •  

  • Using Wix Corvid (now Velo by Wix), incorporate the API endpoints within your site's backend code to handle requests and responses, allowing for seamless integration of cognitive services.
  •  

  • Enhance your website with features like real-time text-to-speech or image recognition via JavaScript code snippets in the Wix Editor, utilizing the Azure service endpoints.

 

Benefits

 

  • Increased accessibility enables a broader user base, including individuals with disabilities, thereby enhancing inclusivity and compliance with accessibility standards.
  •  

  • Improved SEO performance due to accessible content and enhanced user experience resulting in longer session durations and reduced bounce rates.

 


// Example of implementing Azure Text-to-Speech in a Wix site
import { getSecret } from 'wix-secrets-backend';

export function processTextToSpeech(text) {
  const subscriptionKey = getSecret('AzureSubscriptionKey');
  const endpoint = `https://<region>.api.cognitive.microsoft.com/sts/v1.0/issueToken`;
  
  return fetch(endpoint, {
    method: 'POST',
    headers: { 'Ocp-Apim-Subscription-Key': subscriptionKey }
  })
  .then(response => response.text())
  .then(token => {
    // Use token to access text-to-speech service
  });
}

 

 

Personalized User Experience through Emotion Detection

 

  • Combine Microsoft Azure Cognitive Services' Emotion Recognition API with Wix to analyze users' emotions through their webcam feed, allowing the website to adapt its content dynamically based on the user's emotional state, thereby providing a personalized experience.
  •  

  • Implement the sentiment analysis feature to assess the tone of user interactions (e.g., comments or feedback) across the website, enabling tailored responses or content suggestions to enhance user satisfaction and engagement.

 

Step-by-Step Implementation

 

  • Register for an Azure account and access the Cognitive Services portal to generate the necessary API keys for the Emotion Recognition and Sentiment Analysis services.
  •  

  • Utilize the Wix Velo platform to establish backend functionality that handles the sending and receiving of data between your Wix site and Azure APIs, ensuring privacy and data security through secure handling of API keys and user data.
  •  

  • Incorporate JavaScript and Velo code into your Wix Editor site to actively interact with users' webcam feeds (with their consent) to detect emotions, and apply sentiment analysis APIs to analyze comments or feedback submitted by the users.

 

Benefits

 

  • Enables a highly personalized user experience by dynamically adjusting content based on real-time emotions, which can increase user engagement and satisfaction.
  •  

  • Gathers insightful data on user sentiment, allowing for improved decision-making in content delivery and user interaction strategies.
  •  

  • Fosters a user-centric online environment where feedback is swiftly acknowledged and acted upon, improving site reputation and user trust.

 


// Example of implementing Azure Emotion Recognition in a Wix site
import { fetch } from 'wix-fetch';

export function analyzeEmotion(imageData) {
  const subscriptionKey = 'yourAzureSubscriptionKey';
  const endpoint = `https://<region>.api.cognitive.microsoft.com/face/v1.0/detect?returnFaceAttributes=emotion`;
  
  return fetch(endpoint, {
    method: 'POST',
    headers: {
      'Ocp-Apim-Subscription-Key': subscriptionKey,
      'Content-Type': 'application/octet-stream',
    },
    body: imageData
  })
  .then(response => response.json())
  .then(data => {
    // Process the emotion data
  });
}

 

Omi App

Fully Open-Source AI wearable app: build and use reminders, meeting summaries, task suggestions and more. All in one simple app.

Github →

Order Friend Dev Kit

Open-source AI wearable
Build using the power of recall

Order Now

Troubleshooting Microsoft Azure Cognitive Services and Wix Integration

How to connect Azure API to Wix website?

 

Integrating Azure API with Wix

 

  • Set Up Azure API: Begin by creating your desired API within Azure, ensuring it returns JSON for easier integration with Wix. Note the base URL and authentication credentials.
  •  

  • Enable Wix Code: Go to the Wix Editor, enable "Dev Mode" to access Wix Code, which allows JavaScript customization and interaction with external APIs.
  •  

  • Create a Backend Function: In the Wix Code panel, create a new JavaScript Web Module file (e.g., `backend/azureApi.jsw`). This file handles server-side HTTP requests.
  •  

    
    // Fetch data from Azure API
    export async function getAzureData() {
      const url = 'YOUR_AZURE_API_URL';
      const headers = {
        'Content-Type': 'application/json',
        'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
      };
    
      try {
        const response = await fetch(url, { headers });
        if (!response.ok) throw new Error('Network response was not ok');
        return await response.json();
      } catch (error) {
        console.error('Azure API call error:', error);
        throw error;
      }
    }
    

     

    • Display Data on Your Site: Use Wix page elements in combination with event handlers to display the fetched data.

     

Why isn't Azure Cognitive Services API working on Wix?

 

Possible Reasons for Issues

 

  • CORS Restrictions: Ensure that your API calls have the necessary CORS headers. Wix might block requests without them.
  •  

  • Wix Velo Server Code: Check your backend implementation on Wix. API keys and sensitive data should always be handled server-side.
  •  

  • Incorrect API Configuration: Double-check if you've configured your Azure Cognitive Services API and keys correctly.

 

Recommended Solutions

 

  • Enable CORS: Include CORS headers in your requests:

    ```javascript
    const fetchWithCORS = async (url) => {
    let response = await fetch(url, {
    headers: { 'Access-Control-Allow-Origin': '*' }
    });
    return response.json();
    };
    ```

  •  

  • Use Velo Backend: Securely manage API keys using server-side functions in Wix Velo.
  •  

  • Check Documentation: Review the Azure Cognitive Services documentation for the latest updates specific to Wix integration.

 

How do I display Azure text-to-speech on my Wix site?

 

Integrate Azure Text-to-Speech

 

  • Set up an Azure account and create a Speech Service resource. Get your API key and endpoint URL.
  •  

  • Wix currently doesn't support server-side scripting or Node.js directly. Use external services to process text-to-speech, then embed the result.

 

Add Audio to Wix

 

  • Upload the generated audio file to Wix's Media Manager.
  •  

  • Use an HTML element to embed the audio.

 

Sample HTML for Audio

 

<audio controls>
  <source src="YOUR_AUDIO_URL" type="audio/mp3">
  Your browser does not support the audio element.
</audio>

 

Important Note

 

  • Always ensure that your usage complies with Azure and Wix terms of service.

 

Don’t let questions slow you down—experience true productivity with the AI Necklace. With Omi, you can have the power of AI wherever you go—summarize ideas, get reminders, and prep for your next project effortlessly.

Order Now

Join the #1 open-source AI wearable community

Build faster and better with 3900+ community members on Omi Discord

Participate in hackathons to expand the Omi platform and win prizes

Participate in hackathons to expand the Omi platform and win prizes

Get cash bounties, free Omi devices and priority access by taking part in community activities

Join our Discord → 

OMI NECKLACE + OMI APP
First & only open-source AI wearable platform

a person looks into the phone with an app for AI Necklace, looking at notes Friend AI Wearable recorded a person looks into the phone with an app for AI Necklace, looking at notes Friend AI Wearable recorded
a person looks into the phone with an app for AI Necklace, looking at notes Friend AI Wearable recorded a person looks into the phone with an app for AI Necklace, looking at notes Friend AI Wearable recorded
online meeting with AI Wearable, showcasing how it works and helps online meeting with AI Wearable, showcasing how it works and helps
online meeting with AI Wearable, showcasing how it works and helps online meeting with AI Wearable, showcasing how it works and helps
App for Friend AI Necklace, showing notes and topics AI Necklace recorded App for Friend AI Necklace, showing notes and topics AI Necklace recorded
App for Friend AI Necklace, showing notes and topics AI Necklace recorded App for Friend AI Necklace, showing notes and topics AI Necklace recorded

OMI NECKLACE: DEV KIT
Order your Omi Dev Kit 2 now and create your use cases

Omi Dev Kit 2

Endless customization

OMI DEV KIT 2

$69.99

Make your life more fun with your AI wearable clone. It gives you thoughts, personalized feedback and becomes your second brain to discuss your thoughts and feelings. Available on iOS and Android.

Your Omi will seamlessly sync with your existing omi persona, giving you a full clone of yourself – with limitless potential for use cases:

  • Real-time conversation transcription and processing;
  • Develop your own use cases for fun and productivity;
  • Hundreds of community apps to make use of your Omi Persona and conversations.

Learn more

Omi Dev Kit 2: build at a new level

Key Specs

OMI DEV KIT

OMI DEV KIT 2

Microphone

Yes

Yes

Battery

4 days (250mAH)

2 days (250mAH)

On-board memory (works without phone)

No

Yes

Speaker

No

Yes

Programmable button

No

Yes

Estimated Delivery 

-

1 week

What people say

“Helping with MEMORY,

COMMUNICATION

with business/life partner,

capturing IDEAS, and solving for

a hearing CHALLENGE."

Nathan Sudds

“I wish I had this device

last summer

to RECORD

A CONVERSATION."

Chris Y.

“Fixed my ADHD and

helped me stay

organized."

David Nigh

OMI NECKLACE: DEV KIT
Take your brain to the next level

LATEST NEWS
Follow and be first in the know

Latest news
FOLLOW AND BE FIRST IN THE KNOW

thought to action

team@basedhardware.com

company

careers

events

invest

privacy

products

omi

omi dev kit

personas

resources

apps

bounties

affiliate

docs

github

help