Alexa Skill to make conversations with ChatGPT.
- Send prompts to ChatGPT
- Conversational interaction, ChatGPT prompts are saved in the skill session.
- Supported languages English(en-US) and Spanish(es-ES)
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"
To import an Alexa-hosted skill from a public Git repository
- Open the Alexa developer console and log in.
- Click Create Skill. The Create a new skill page appears.
- For Skill name, use "chat gpt".
- For Default language, choose language, this skill is compatible with English(en-US) and Spanish(es-ES).
- For Choose type of experience, select Other.
- For Choose a model to add to your skill, select Custom.
- For Choose a method to host your skill's backend resources, select Alexa-Hosted (Python).
- For Hosting region, select one of your preference, the closer the better.
- Click Create Skill. The Choose a template to add to your skill page appears.
- Click Import skill. The Import skill dialog appears. Enter "https://github.com/joncolas/alexa-chatgpt.git"
- 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:
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!
You can test ChatGPT python module from your local machine in the following way:
- Change to the lambda/py directory
cd lambda/py/
- Set your OpenAI apiKey environment variable
cp .env.template .env
- Load environment
source .env
- Prepare a virtualenvironment for OpenAI
pip install virtualenv virtualenv chatgpt_skill_module source chatgpt_skill_module/bin/activate pip install openai
- Execute the script
python test_chatgpt.py
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.
You can check logs in CloudwatchLogs from the Code tab in the Alexa Developers Console.