Connecting DeepSeek Chat to Alice

In this article, you will learn how to integrate GPT into Alice's speaker without foreign servers, using DeepSeek. We will show step-by-step setup of PHP hosting, explain where to get the necessary keys, and how to configure the skill in Yandex.Dialogs. The result is a smart assistant capable of answering questions using the power of GPT.

Background

In the previous article, we configured a skill for Alice using OpenAI GPT, which required foreign hosting and created many difficulties. Now there is a simpler way: use the DeepSeek API — a solution for which you can use any suitable hosting.

Links to materials

Requirements

  1. Hosting with PHP 7.4 support and above.

  2. Composer for dependency management.

  3. cURL extension for PHP (included by default on many hostings).

  4. DeepSeek API key (obtained when registering for the DeepSeek service).

Tip: Pay attention to the presence of HTTPS (SSL certificate). Yandex.Dialogues do not accept requests over an unsecured connection. If your hosting does not have a certificate, use the free Let’s Encrypt.

Step 1. Create a website on hosting

  1. Prepare the environment:

    • Make sure your hosting supports the required PHP version and Composer is installed.

    • Make sure the domain name is linked and available via HTTPS.

  2. Add the site to the hosting control panel:

    • Create a new domain or subdomain.

    • Set up an SSL certificate (e.g., Let’s Encrypt).

  3. (If necessary) configure DNS:

    • If the domain was recently purchased, wait for the DNS records to update.

Step 2. Connect via SSH and clone the repository

  1. Connect to the server via SSH:

ssh username@your-domain.com
  1. Go to your site folder and clone the repository:

git clone https://github.com/zabarov/alice-deepseek.git .
  1. Make sure the repository files (e.g., index.php, composer.json, etc.) appear in the root of the site.

Step 3. Install dependencies

Go to the project root and run:

composer install

This will pull in all the necessary libraries and packages. If the command does not work, check that Composer is installed and available in PATH.

Step 4. Configuring the .env file

  1. Create a .env file based on the example file:

cp .env.example .env
  1. Open the .env file with any editor (e.g., nano .env) and insert your DeepSeek API key:

DEEPSEEK_API_KEY=your_deepseek_api_key
  1. Save the changes.

Important: The .env file should not be included in the public repository to prevent the API key from being accessible to third parties.

Step 5. Configuring the skill in Yandex.Dialogs

  1. Create a new skill in Yandex.Dialogs.

  2. Main settings:

    • Skill name: come up with a short, easily recognizable name.

    • Backend: specify the address of your website (e.g., https://your-domain.com/index.php).

    • Voice: you can choose any voice to make the skill different from Alice's "voice".

  3. Publish the skill. Yandex will check the configuration and, if set up correctly, will allow you to test it.

Testing the skill

  1. In the Yandex.Dialogs interface:

    • Click "Test" and enter any phrase to make sure the skill works.

    • Check the response logs to ensure correct operation.

  2. In the Alice column or app:

    • Invoke the skill with a voice command, for example: "Alice, launch [your skill name]" or "Alice, ask [skill name]".

    • Make sure the response comes from GPT via DeepSeek.

Common errors and their solutions

  1. No secure connection (HTTPS)

    • Without HTTPS, Yandex.Dialogs reject requests. Check that the certificate is installed correctly.

  2. Backend is incorrectly specified

    • Make sure that the index.php address is specified correctly and accessible from the outside (404/403 error indicates lack of access).

  3. DNS issues

    • If the domain is new, wait for the DNS to update (usually from 1 to 24 hours).

  4. API key not found

    • Check that the DEEPSEEK_API_KEY is correctly specified in the .env.

    • Make sure that the .env file is not ignored by Git or missed when uploading to the server.

Comments