A sample Alexa skill that brings the Twitter experience to Alexa. For multimodal devices, you can see Tweets about a certain topic or trends for a city.
This skill demonstrates:
- Use of Twitter APIs - search API and trends API
- Alexa Presentation Language (APL) pager functionality with speak item commands
- Go to the AWS Console and create a Lambda function.
- Select author from scratch and give your function a name (e.g. twitter-skill) and select Java 8 as the runtime.
- Select appropriate role and click create function.
- Build a jar file to upload it into the lambda function:
- Make sure that you replace the Twitter API Keys and tokens in TwitterService.java file
- Using maven: go to the directory containing pom.xml, and run 'mvn assembly:assembly -DdescriptorId=jar-with-dependencies package'. This will generate a zip file named "tweet-buddy-1.0-jar-with-dependencies.jar" in the target directory.
- For Code entry type, select "Upload a .ZIP file" and then upload the jar file created in the previous step from the build directory to Lambda.
- Set the Handler as TweetBuddyStreamHandler
- Increase the Timeout to 30 seconds and make sure memory is set to at least 512 MB under Basic Settings.
- Click add trigger, and select Alexa skills kit. You will add your skill id (from the alexa skill setup section) here.
- Save your settings and copy the ARN from the top right to be used later in the Alexa Skill Setup.
- Go to the Alexa Console and click Create Skill.
- Set "Tweet Buddy" as the skill name, Custom for the model and 'provision your own' for hosting method. Next, select Start from Scratch for the template.
- In the Endpoints tab, select AWS Lambda ARN and paste the arn for your lambda function here.
- From the Interfaces tab, select Alexa Presentation Language and check the Hub Landscape, Small.
- Build the Interaction Model for your skill:
- On the left hand navigation panel, select the JSON Editor tab under Interaction Model. In the textfield provided, replace any existing code with the code provided in the Interaction Model. Click Save Model.
- Click "Build Model".
- Make sure you copy the Skill Id from your developer console and use it as the trigger for your lambda function.
User: "Alexa, open Tweet Buddy"
User: "What's Trending in Seattle"
User: "Give me Tweets about Lamar Jackson"
Read more in the tutorial on DEV.to