(No Programming Required) How to Create an Alexa ChatGPT Skill
Overview
I have summarized how to create an Alexa ChatGPT skill as quickly as possible without any programming.
Excluding initial setup, it can be created in about 10 to 20 minutes.
Alexa × ChatGPT
— Eito Hijikata@9db (@ryutoway) June 29, 2023
会話の流れを踏まえて会話できるChatGPTのアレクサスキルがなかったので自作してみた。#Alexa pic.twitter.com/vpwGKNFLU4
Why build it yourself?
If you use an existing Alexa skill, you cannot use your own ChatGPT API key, meaning you can only use it for free a few times a month.
Additionally, there are issues such as not being able to get answers while maintaining conversation history, or frequent response errors.
Furthermore, by building it yourself, you can easily update to the latest language models.
Addressing Common Issues
The creation method in this article also addresses the following issues.
Responses do not take previous conversation into account
→ Improved to get answers based on the flow of conversation by maintaining conversation historyFrequent response errors
→ Mitigated by limiting the number of characters in ChatGPT responsesCan only be used a few times a month on the free tier
→ By using the user's own API key, it can be used up to the ChatGPT usage limit (up to 15,000 times per month)Cannot use the latest language models
→ Also supports the latest ChatGPT-4No automation tools (iPaaS) like IFTTT or Make used
→ Knowledge and account creation required for setup can be kept to a minimum
Issues with using ChatGPT on Alexa
Alexa has a limitation where it errors out if it cannot prepare a response within 8 seconds, so it will error if the ChatGPT response is slow.
Therefore, the compatibility between Alexa and ChatGPT is not good.
While you can mitigate response errors by limiting the number of characters in the response, it is currently impossible to eliminate them completely.
Initial Setup
Please obtain the following two accounts (both free) required to link Alexa and ChatGPT in advance.
Amazon Developer Account
This is the account required to register a skill (in this case, a conversation app with ChatGPT) to Alexa.
Please register using the Amazon account you use for Alexa.
https://developer.amazon.com/ja/
OpenAI Account
Required to use ChatGPT.
https://platform.openai.com/signup?launch
In the following sections, I will explain the steps to link Alexa and ChatGPT.
Once linked, you will be able to enjoy conversations with Alexa, so let's do our best!
Skill Registration (Approx. 4–7 minutes)
Register a new Alexa skill in the Alexa Developer Console.
While logged into Amazon Developer, open the link below.
https://developer.amazon.com/alexa/console/ask
1. Click the Create Skill button

2. Set the required information and proceed
Skill Name: Chat
Primary Locale: Japanese

3. Enter the required information and proceed
Experience Type: Games & Trivia
*Leave other settings as they are

4. Import the skill
Click the "Import Skill" button, enter the URL below into the text box on the screen that appears, and click the "Import" button.
https://github.com/Eito-H/AlexaGPT.git

5. Skill complete
If a screen like the image below is displayed, the ChatGPT skill is complete.

Skill Configuration (Approx. 4–7 minutes)
1. Obtain an API key
Obtain the API key required to use ChatGPT.
While logged into OpenAI, open the link below.
https://platform.openai.com/account/api-keys
① Click "Create new secret key"
② Leave Name (My Test Key) blank and click "Create secret key"
③ Copy the displayed string

2. Set the API key
Select the Code Editor tab from the top of the created skill screen to open the editor screen.

Open key.js.

Replace the part of module.exports.OPEN_AI_KEY that says "Enter API key here" with the API key you copied earlier.
3. Deploy
To apply the settings, click the "Deploy" button in the top right corner of the screen.
After waiting a few seconds, "Deployment successful" will appear in the bottom right corner of the screen (this message will disappear quickly).
Testing (approx. 2–6 minutes)
With this, your Alexa skill for using ChatGPT is complete.
You can test it on the Alexa Developer Console, so let's give it a try.
1. Open the Test tab and change the status from "Off" to "Development".

2. Type "Chat" and press Enter.

3. Type your question and press Enter.

4. Check if a response is returned.

This concludes the test.
If you are using an Alexa device registered with the same account as your Amazon Developer account, you should already be able to use ChatGPT, so go ahead and try it out.
Supplementary Information
How to use GPT-4
The integration in this article uses the "gpt-3.5-turbo" language model, but you can get more accurate answers by using the latest GPT-4.
As of June 28, 2023, to use GPT-4, you must subscribe to the paid version called "ChatGPT Plus".
The paid version also has faster response speeds, which reduces the frequency of Alexa timeouts.
To change Alexa to GPT-4, please replace the "mode" section in key.js with "gpt-4".
Troubleshooting response errors
Alexa has a response time limit of 8 seconds, so if the response from ChatGPT is too long, an error may occur.
If you encounter frequent response errors, you may be able to improve the situation by tightening the character limit.
Please change the "system_message" section in key.js to something like "Answer in 30 characters."
How to change the speaking style, such as using Kansai dialect
You can change the speaking style by adding phrases like "in Kansai dialect" to the "system_message" in keys.js.
However, please note that this may slow down the response speed and increase the frequency of response errors.
