Learning Objective
After completing this lesson, you will be able to:
- use modules in KRL
- wrap an extermal API call and make it available from a module
- use the keys pragma for API keys
Prerequisites
You should have done the following before starting this lesson:
- Read the page on User Defined Modules
- Read the page on User-Defined Actions
- Read the page on using keys
- Read the page on the built-in HTTP library
- Study the Twilio API documentation for sending an SMS and making Twilio requests.
- Completed the Pico State Lesson
Contents
Modules
Modules make KRL programming easier. KRL has a powerful parameterized module facility.
In this lesson, we're going to explore how modules can be used to wrap an external API and make it available inside a pico.
## outline
- Create a ruleset to serve as our module called twilio
- write an action that makes an HTTP POST to send an SMS with credentials hard coded
- write ruleset to test it
- pull credentials into keys pragma. Still not great.
- Use module configuration to get keys out of module and into testing ruleset
- use key module to get keys out of testing ruleset.