Skip to content

joncolas/alexa-chatgpt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Alexa + Chatgpt

image

Description

Alexa Skill to make conversations with ChatGPT.

Features

  • Send prompts to ChatGPT
  • Conversational interaction, ChatGPT prompts are saved in the skill session.
  • Supported languages English(en-US) and Spanish(es-ES)

Usage

Interaction example:

User > "Alexa, open chat gpt"
Alexa > "What do you need? start your question with 'ask' or 'search' words."
User > "Search ¿how much is 3+7?"
Alexa > "The result is 10"
Alexa > "More questions?, remember to start with 'ask' or 'search' words, if not, say 'end'."
User > "Search, and if we replace 7 number by 2 ?"
Alexa > "The result is 5"

How to setup this skill to your Alexa Developers Console

Using the Alexa Developers Console

To import an Alexa-hosted skill from a public Git repository

  1. Open the Alexa developer console and log in.
  2. Click Create Skill. The Create a new skill page appears.
  3. For Skill name, use "chat gpt".
  4. For Default language, choose language, this skill is compatible with English(en-US) and Spanish(es-ES).
  5. For Choose type of experience, select Other.
  6. For Choose a model to add to your skill, select Custom.
  7. For Choose a method to host your skill's backend resources, select Alexa-Hosted (Python).
  8. For Hosting region, select one of your preference, the closer the better.
  9. Click Create Skill. The Choose a template to add to your skill page appears.
  10. Click Import skill. The Import skill dialog appears. Enter "https://github.com/joncolas/alexa-chatgpt.git"
  11. Click Continue. The message Creating your Alexa-hosted skill appears. If Alexa validates that the Git repository contains an Alexa skill that it can import Alexa creates your Alexa-hosted skill.

Reference:

Final skill setup

Once the skill was imported to your Alexa Developer Console, enter inside and do this steps:

  • Replace YOUR_OPENAI_API_KEY by your OpenAi ApiKey in chatgpt.py file. If you don't have it yet you can create a new one from https://platform.openai.com/account/api-keys.
  • In order to allow your Alexa devices run Chat gpt skill ensure that Skill testing is enabled in Development mode, go to Test tab and Select Development.

Now you can start using Chat GPT skill in your alexa devices!

Test ChatGPT python module localy

You can test ChatGPT python module from your local machine in the following way:

  1. Change to the lambda/py directory
    cd lambda/py/
    
  2. Set your OpenAI apiKey environment variable
    cp .env.template .env
    
  3. Load environment
    source .env
    
  4. Prepare a virtualenvironment for OpenAI
    pip install virtualenv
    virtualenv chatgpt_skill_module
    source chatgpt_skill_module/bin/activate
    pip install openai
    
  5. Execute the script
    python test_chatgpt.py
    

Limitations

By definition, Alexa can not wait more than 10 seconds to get response from a skill so if your prompt takes more than 10 seconds to resolve Chat GPT skill will give you error.

Troubleshooting

You can check logs in CloudwatchLogs from the Code tab in the Alexa Developers Console.

About

This is an Alexa skill to ask things to chatGPT

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages