In this post will learn about How to Integrate Pega 8.5 with Amazon Alexa. lets get started.
Step 1: Installing the Alexa Channel component
- AlexaChannel component is not part of your Pega Platform application. Download a .zip file for that component from Pega Marketplace.
- Import .zip file using Import wizard
- Open Application Definition and in the Enabled components section, click Manage components.
- In the Manage components window select the AlexaChannel and in the status column select Enabled checkbox, click ok and click save.
Step 2: Creating an Alexa skill definition
- To use Pega Intelligent Virtual Assistant (IVA) for Alexa with a Pega Platform application, add a new Amazon Alexa skill in the Amazon developer portal.
- Creating an Amazon Alexa skill generates a unique application ID that you later use to configure the Alexa channel in Pega Platform to function as an IVA for Alexa.
- Log in to the Amazon developer portal.
- Click the Alexa menu, and then create a new skill.
3.Navigate to Alexa Skills Kit and click on the Console to open the alexa developer console
- Click the Create Skill, enter an invocation name for the customers to activate the Amazon skill.
- From the Default language list, click English (US).
- start a new skill definition by choosing the template.
- Display a list of all Alexa skills, and then click View Skill ID for the new skill that you created.
Result:A unique application ID for the new skill appears, for example, amzn1.ask.skill.62beb805-ae2b-493a-a15b-2291xxxxxxxx
- Save the unique application ID to a temporary file
Step 3: Setting up an Alexa channel.
- In the Create new channel interface section, click the icon that represents Alexa channel.
- In the Alexa channel, click the Connection tab.
- In the Alexa application ID field, enter the application ID for the Amazon Alexa skill that you saved to a file when you created an Alexa skill definition.
Step 3: Setting up an Alexa channel.
Update alexachannel Service Package with your appropriate Service access group
Modify AlexaAuthentication activity by save as into your next ruleset version and add below try catch block into the step 6 java code. And comment step 13 – property validate – Note: This is the bug in pega code, so add below piece of code to solve the connection issue.
try(java.io.InputStream inputStream = vRequest.getInputStream()) {
vRequestBody = com.pega.apache.commons.io.IOUtils.toString(inputStream, “UTF-8”);
oLog.infoForced(“* Before REQUEST::”+vRequestBody);
String s1=”\””+”Extensions”+”\”{“;
String s2=”\””+”available”+”\”{“;
String s3=”\””+”aplext:backstack:10″+”\”:{}}},”;
String s=s1+s2+s3; //oLog.infoForced(“SEARCH STRING::”+s);
//oLog.infoForced(“REQUEST::”+vRequestBody);
String rs = vRequestBody.replace(s,””);
vRequestBody=rs;
oLog.infoForced(“* After REQUEST::”+vRequestBody);
} catch(java.io.IOException ex) {
myStepPage.addMessage(ex.getMessage());
}
Step 4: Updating the Alexa Skill configuration
- Update the information for the Alexa skill in the Amazon developer portal so that Pega (IVA) for Amazon can communicate with the Alexa developer portal.
- You enter the skill configuration results that you generated for your IVA for Alexa, the URL for a Pega Platform instance, and the SSL certificate configuration.
- In a web browser, log in to the Amazon developer portal.
- From the list of Alexa skills, open the Alexa skill that you previously created.
- Click the Interaction Model section, and then click JSON Editor.
- Copy the intent schema content that you saved in a temporary file when setting up an Alexa channel, and then paste the data into the Intent Schema section.
- Click Save Model.
6.Select the certificate endpoints for your target customers:
- Click the Endpoint section.
- For the service endpoint type, click HTTPS.
- In the Default Region field, enter the URL for your Pega Platform instance and its Alexa channel in the following format:
https://<PEGA_PLATFORM_INSTANCE>/PRRestService/alexachannel/srv/alexa
- Select the type of the certificate that your organization uses.
- Click Save Endpoints.
- To expose your localhost url into a public https url – use ngrok
- Download and run ngrok.exe
- Execute the command ngrok http 8080
- Set up account linking information:
- Click the Account Linking section.
- Turn on the Do you allow users to create an account or link to an existing account with you? switch.
- Click Implicit Grant.
- Turn off the Allow users to enable skill without account linking switch.
- In the Authorization URI field, enter the URL for your Pega Platform instance and its Alexa channel.
- In the Client ID field, enter the application ID for the Alexa skill that you saved to a file when you created an Alexa skill definition.
- Click Save.
Step 5: Testing the Alexa skill definition
- In a web browser, log in to the Amazon developer portal.
- On the Alexa menu, in the Alexa Skills Kit section, click Get Started, and then and click the name of your Alexa skill.
- Click the Test tab.
- Turn the switch to Enabled.
- In the Service Simulator section, click the Test tab.
- In the Enter Utterance field, enter a sample command for Alexa, and then click Ask <Alexa_Skill>.
- The Service Request and Service Response fields display your request and the generated response from Alexa in JSON format.
The IVA for Alexa is now configured. You can now develop its behavior so that the system responds correctly to voice commands for a Pega Platform application.
Hope In this post you learned about How to Integrate Pega 8.5 with Amazon Alexa. lets get started. If you any doubts feel free to contact admin@pegaks.com