Creating a skill

Now that you have completed the preceding steps, let's follow these steps to create an Alexa skill.

Let's create a file called alexa_ros_test.py and copy the code into our repository at https://github.com/PacktPublishing/ROS-Robotics-Projects-SecondEdition/blob/master/chapter_7_ws/alexa_ros_test.py into it. Let's look at the important details of the code here:

...threading.Thread(target=lambda: rospy.init_node('test_code', disable_signals=True)).start()pub = rospy.Publisher('test_pub', String, queue_size=1)app = Flask(__name__)ask = Ask(app, "/")logging.getLogger("flask_ask").setLevel(logging.DEBUG)@ask.launchdef launch():    welcome_msg = render_template('welcome')    return question(welcome_msg)@ask.intent('HelloIntent')def hello(firstname): ...

Get ROS Robotics Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.