Here is a project using Twilio to control Spark Core. Using Twilio we can easily create powerful IVRs. Twilio provides TwiML (Twilio Markup Language) to create IVRs. We can attach a TwiML file to a number, when a incoming call detected Twilio reads this XML file and process the XML file. We provide some texts that will speak out to the caller, gather digits from the caller, etc... Since this is not related to Spark Core, refer to this link for more details about the TwiML and how to attach to a number.
We instruct the Twilio speak some texts and gather digits from the caller. When the caller enters some digits, the Twilio will call a request URL. The entered digits will be passed to the URL. We can create a server side script to process these digits.
In this process the when the user enters a secret PIN then the Spark Cloud API is called to turn on a light, in this project the light is attached to the Digital Pin D7. The Spark Core is flashed with default Tinker firmware. In this demo if you input `55231#` then the light will be turned on, if it is `55230#` then the light will be turned off.
The following TwiML and PHP Script is used in this demo.
How to use
- Create Twilio account,
- Purchase a Twilio Number (optional, you can use the general demo number),
- Copy and upload the above TwiML and PHP Script to the server,
- Configure the Number Properties (TwiML, see below image)