This summer I (Ivan Galakhov) attended Wolfram Summer Camp where, in two weeks, I created a project which uses the Twilio API to allow a user to both use the capabilities of Wolfram|Alpha and execute Wolfram Language code through SMS and MMS text messaging. The project also provides a convenient entity and function storage system, which provides better accessibility to complex computations. This post first outlines how the project works, describes the commands that the project allows one to use, and then explains how one could set up the project for their own personal use.
As mentioned before, this project uses the Twilio API. Though Twilio is integrated with the Wolfram Language, the service only allows one to send messages, rather than receive them. For this reason, in order to properly receive messages, one must set up a Twilio webhook. The data sent by this webhook can be read through a CloudObject. Effectively, this project boils down to a single function that can receive data from the Twilio webhook, and properly respond.
Before I explain what each command does, its important to discuss the general format of each one. Every command falls into the general pattern:
[Command] ||| [Arguments]
‘ALPHA ’ is the first and simplest command in this project. All it does is send the text given by the argument and returns its result using the WolframAlpha function. Note that this function is coded in such a way that if Wolfram|Alpha returns something that can be interpreted as an image, an MMS message will be sent, and an SMS message will be sent otherwise. For example, the input “ALPHA ||| What does Stephen Wolfram look like?” will return and MMS image of Stephen Wolfram, while the input “ALPHA ||| How old is Stephen Wolfram?” will return an SMS message with the correct answer.
‘CODE’ is probably one of the most powerful commands available to the users of this project. It effectively allows the user to submit a Wolfram Language expression, whose result will be returned to them after it is evaluated on the cloud. Similar to the ‘ALPHA’ command, this command can return both SMS and MMS results, as shown in the images above.
One of the things that make the Wolfram Language extra powerful is its functionality with entities. While an entity is usually specified by pressing Ctrl-equals, this is clearly not possible when you are writing a text message, the project provides another way of using entities in your code.
This function allows the user to create their own entity that can later be used in the computation. It can be seen from the above image that if the argument entered by the user is valid, an entity will be created, along with an ID that can be prepended with “:::” and used in the computation to specify an entity in its place (see image below).
This function allows the user to see all of their currently existing entities, along with their IDs.
This command deletes all user created entities
This command deletes a specific user created entity based on its ID.
Functions are another powerful tool that can be used by users of this project. They are in this project because, when I was originally testing the ‘CODE’ command, I noticed that I was reusing the same piece of code many times in my input, which was clearly inefficient. Functions can be defined by the user, and then be used in computation done with the ‘CODE’ command.
This command creates a function that can be used in a later computation. Note that all user created functions are automatically defined before computation.
This command lists all user created function signatures, along with their IDs. Note that unlike entities, function IDs can’t actually be used in code and are instead only used in the context of the “FUNCTION_DELETE” command.
This command deletes all user-created functions.
This command deletes a specific function based on its ID.
(I will update this post later about how the code works and how one can set this project up for their own use. For now, I am just attaching the raw code notebook.)