ThingSpeak

TalkBack App

TalkBack enables any device to act upon queued commands. For example, if you have a door that is outfitted with Wi-Fi and a motion sensor, you can queue up commands to open and close the door. When the door senses someone nearby, open the door. After a specified time, close the door. If there are no more commands in the queue, the door does not open when the next person approaches.

Add a TalkBack Command

To add a TalkBack command, send an HTTP POST to https://api.thingspeak.com/talkbacks/TALKBACK_ID/commands, replacing TALKBACK_ID with the actual ID of your TalkBack. There is no limit to the number of commands that a single TalkBack can have.

Valid parameters:

  • api_key (string) - API key for this specific TalkBack (required)

  • command_string (string) - Command to be sent to your device. There is a limit of 255 characters per command_string.

  • position (integer) - The position you want this command to appear in. Any previous commands at or after this position will be shifted down. If the position is left blank, the command will automatically be added to the end of the queue (with the highest position).

Text

Example of POST:

POST https://api.thingspeak.com/talkbacks/3/commands
     api_key=XXXXXXXXXXXXXXXX
     command_string=OPENDOOR
     position=5
The response will be the command ID, for example: 18.

JSON

To add a TalkBack command, send an HTTP POST to https://api.thingspeak.com/talkbacks/TALKBACK_ID/commands.json, replacing TALKBACK_ID with the actual ID of your TalkBack. There is no limit to the number of commands that a single TalkBack can have.

Example of POST:

POST https://api.thingspeak.com/talkbacks/3/commands.json
     api_key=XXXXXXXXXXXXXXXX
     command_string=OPENDOOR
     position=5
The response will be a JSON object of the new command, for example:

{
  "command_string": "OPENDOOR",
  "created_at": "2013-12-29T17:53:40-05:00",
  "executed_at": null,
  "id": 18,
  "position": 5
}

XML

To add a TalkBack command, send an HTTP POST to https://api.thingspeak.com/talkbacks/TALKBACK_ID/commands.xml, replacing TALKBACK_ID with the actual ID of your TalkBack. There is no limit to the number of commands that a single TalkBack can have.

Example of POST:

POST https://api.thingspeak.com/talkbacks/3/commands.xml
     api_key=XXXXXXXXXXXXXXXX
     command_string=OPENDOOR
     position=5
The response will be an XML object of the new command, for example:

<?xml version="1.0" encoding="UTF-8"?>
<command>
  <id type="integer">18</id>
  <command-string>OPENDOOR</command-string>
  <position type="integer">5</position>
  <created-at type="datetime">2013-12-30T16:51:17-05:00</created-at>
  <executed-at type="datetime" nil="true"/>
</command>

Get a TalkBack Command

To show an existing TalkBack command, send an HTTP GET to https://api.thingspeak.com/talkbacks/TALKBACK_ID/commands/COMMAND_ID, replacing TALKBACK_ID with the actual ID of your TalkBack and COMMAND_ID with the ID of the command.

Valid parameters:

  • api_key (string) - API key for this specific TalkBack (required)

Text

Example of GET:

GET https://api.thingspeak.com/talkbacks/3/commands/18?api_key=XXXXXXXXXXXXXXXX
The response will be the command string, for example: OPENDOOR

JSON

To show an existing TalkBack command, send an HTTP GET to https://api.thingspeak.com/talkbacks/TALKBACK_ID/commands/COMMAND_ID.json, replacing TALKBACK_ID with the actual ID of your TalkBack and COMMAND_ID with the ID of the command.

Example of GET:

GET https://api.thingspeak.com/talkbacks/3/commands/18.json?api_key=XXXXXXXXXXXXXXXX
The response will be a JSON object of the new command, for example:

{
  "command_string": "OPENDOOR",
  "created_at": "2013-12-29T17:53:40-05:00",
  "executed_at": null,
  "id": 18,
  "position": 5
}

XML

To show an existing TalkBack command, send an HTTP GET to https://api.thingspeak.com/talkbacks/TALKBACK_ID/commands/COMMAND_ID.xml, replacing TALKBACK_ID with the actual ID of your TalkBack and COMMAND_ID with the ID of the command.

Example of GET:

GET https://api.thingspeak.com/talkbacks/3/commands/18.xml?api_key=XXXXXXXXXXXXXXXX
The response will be an XML object of the new command, for example:

<?xml version="1.0" encoding="UTF-8"?>
<command>
  <id type="integer">18</id>
  <command-string>OPENDOOR</command-string>
  <position type="integer">5</position>
  <created-at type="datetime">2013-12-30T16:51:17-05:00</created-at>
  <executed-at type="datetime" nil="true"/>
</command>

Update a TalkBack Command

To update an existing TalkBack command, send an HTTP PUT to https://api.thingspeak.com/talkbacks/TALKBACK_ID/commands/COMMAND_ID, replacing TALKBACK_ID with the actual ID of your TalkBack and COMMAND_ID with the ID of the command.

Valid parameters:

  • api_key (string) - API key for this specific TalkBack (required)

  • command_string (string) - Command to be sent to your device

  • position (integer) - The position you want this command to appear in. Any previous commands at or after this position will be shifted down.

Text

Example of PUT:

PUT https://api.thingspeak.com/talkbacks/3/commands/18
    api_key=XXXXXXXXXXXXXXXX
    command_string=OPENDOOR
    position=5
The response will be the command string, for example: OPENDOOR

JSON

To update an existing TalkBack command, send an HTTP PUT to https://api.thingspeak.com/talkbacks/TALKBACK_ID/commands/COMMAND_ID.json, replacing TALKBACK_ID with the actual ID of your TalkBack and COMMAND_ID with the ID of the command.

Example of PUT:

PUT https://api.thingspeak.com/talkbacks/3/commands/18.json
    api_key=XXXXXXXXXXXXXXXX
    command_string=OPENDOOR
    position=5
The response will be a JSON object of the updated command, for example:

{
  "command_string": "OPENDOOR",
  "created_at": "2013-12-29T17:53:40-05:00",
  "executed_at": null,
  "id": 18,
  "position": 5
}

XML

To update an existing TalkBack command, send an HTTP PUT to https://api.thingspeak.com/talkbacks/TALKBACK_ID/commands/COMMAND_ID.xml, replacing TALKBACK_ID with the actual ID of your TalkBack and COMMAND_ID with the ID of the command.

Example of PUT:

PUT https://api.thingspeak.com/talkbacks/3/commands/18.xml
    api_key=XXXXXXXXXXXXXXXX
    command_string=OPENDOOR
    position=5
The response will be an XML object of the updated command, for example:

<?xml version="1.0" encoding="UTF-8"?>
<command>
  <id type="integer">18</id>
  <command-string>OPENDOOR</command-string>
  <position type="integer">5</position>
  <created-at type="datetime">2013-12-30T16:51:17-05:00</created-at>
  <executed-at type="datetime" nil="true"/>
</command>

Execute the Next TalkBack Command

To execute the next TalkBack command in the queue (normally in position 1), send an HTTP GET or POST to https://api.thingspeak.com/talkbacks/TALKBACK_ID/commands/execute, replacing TALKBACK_ID with the actual ID of your TalkBack.

Executing a command removes it from the queue, sets executed_at to the current time, sets position to null, and reorders the remaining commands.

Valid parameters:

  • api_key (string) - API key for this specific TalkBack (required)

Text

Example of POST:

POST https://api.thingspeak.com/talkbacks/3/commands/execute
     api_key=XXXXXXXXXXXXXXXX
The response will be the command string, for example: OPENDOOR

If there are no commands left to execute, the response body will be empty.

JSON

To execute the next TalkBack command in the queue (normally in position 1), send an HTTP GET or POST to https://api.thingspeak.com/talkbacks/TALKBACK_ID/commands/execute.json, replacing TALKBACK_ID with the actual ID of your TalkBack.

Example of POST:

POST https://api.thingspeak.com/talkbacks/3/commands/execute.json
     api_key=XXXXXXXXXXXXXXXX
The response will be a JSON object of the executed command, for example:

{
  "command_string": "OPENDOOR",
  "created_at": "2013-12-29T17:53:40-05:00",
  "executed_at": "2013-12-30T17:53:40-05:00",
  "id": 18,
  "position": null
}

If there are no commands left to execute, the response will be an empty JSON object, for example:

{}

XML

To execute the next TalkBack command in the queue (normally in position 1), send an HTTP GET or POST to https://api.thingspeak.com/talkbacks/TALKBACK_ID/commands/execute.xml, replacing TALKBACK_ID with the actual ID of your TalkBack.

Example of POST:

POST https://api.thingspeak.com/talkbacks/3/commands/execute.xml
     api_key=XXXXXXXXXXXXXXXX
The response will be an XML object of the executed command, for example:

<?xml version="1.0" encoding="UTF-8"?>
<command>
  <id type="integer">18</id>
  <command-string>OPENDOOR</command-string>
  <position type="integer" nil="true"/>
  <created-at type="datetime">2013-12-30T16:51:17-05:00</created-at>
  <executed-at type="datetime">2013-12-31T16:51:17-05:00</executed-at>
</command>

If there are no commands left to execute, the response will be an empty XML hash, for example:

<?xml version="1.0" encoding="UTF-8"?>
<hash></hash>

Update a Channel and Execute the Next TalkBack Command

The next TalkBack command in the queue (normally in position 1) can be executed at the same time a Channel is updated by sending an HTTP GET or POST to https://api.thingspeak.com/update.

Executing a command removes it from the queue, sets executed_at to the current time, sets position to null, and reorders the remaining commands.

    Note:   Please note that the parameters for this action are different than other TalkBack commands. Since a Channel is being updated, the api_key parameter refers to the Channel API write key, while the talkback_key refers to the TalkBack API key.

Valid parameters:

  • api_key (string) - API key for the Channel (required)

  • talkback_key (string) - API key for this specific TalkBack (required)

Additional parameters for updating a Channel can be found in Update a Channel.

Text

Example of POST:

POST https://api.thingspeak.com/update
     field1=70
     api_key=XXXXXXXXXXXXXXXX
     talkback_key=XXXXXXXXXXXXXXXX
The response will be the command string, for example: OPENDOOR

JSON

The next TalkBack command in the queue (normally in position 1) can be executed at the same time a Channel is updated by sending an HTTP GET or POST to https://api.thingspeak.com/update.json.

Example of POST:

POST https://api.thingspeak.com/update.json
     field1=70
     api_key=XXXXXXXXXXXXXXXX
     talkback_key=XXXXXXXXXXXXXXXX
The response will be a JSON object of the executed command, for example:

{
  "command_string": "OPENDOOR",
  "created_at": "2013-12-29T17:53:40-05:00",
  "executed_at": "2013-12-30T17:53:40-05:00",
  "id": 18,
  "position": null
}

XML

The next TalkBack command in the queue (normally in position 1) can be executed at the same time a Channel is updated by sending an HTTP GET or POST to https://api.thingspeak.com/update.xml.

Example of POST:

POST https://api.thingspeak.com/update.xml
     field1=70
     api_key=XXXXXXXXXXXXXXXX
     talkback_key=XXXXXXXXXXXXXXXX
The response will be an XML object of the executed command, for example:

<?xml version="1.0" encoding="UTF-8"?>
<command>
  <id type="integer">18</id>
  <command-string>OPENDOOR</command-string>
  <position type="integer" nil="true"/>
  <created-at type="datetime">2013-12-30T16:51:17-05:00</created-at>
  <executed-at type="datetime">2013-12-31T16:51:17-05:00</executed-at>
</command>

Get the Last Executed Command

To show the most recently executed TalkBack command, send an HTTP GET to https://api.thingspeak.com/talkbacks/TALKBACK_ID/commands/last, replacing TALKBACK_ID with the actual ID of your TalkBack.

Valid parameters:

  • api_key (string) - API key for this specific TalkBack (required)

Text

Example of GET:

GET https://api.thingspeak.com/talkbacks/3/commands/last?api_key=XXXXXXXXXXXXXXXX
The response will be the command string, for example: OPENDOOR

JSON

To show the most recently executed TalkBack command, send an HTTP GET to https://api.thingspeak.com/talkbacks/TALKBACK_ID/commands/last.json, replacing TALKBACK_ID with the actual ID of your TalkBack.

Example of GET:

GET https://api.thingspeak.com/talkbacks/3/commands/last.json?api_key=XXXXXXXXXXXXXXXX
The response will be a JSON object of the new command, for example:

{
  "command_string": "OPENDOOR",
  "created_at": "2013-12-29T17:53:40-05:00",
  "executed_at": "2013-12-30T17:53:40-05:00",
  "id": 18,
  "position": null
}

XML

To show the most recently executed TalkBack command, send an HTTP GET to https://api.thingspeak.com/talkbacks/TALKBACK_ID/commands/last.xml, replacing TALKBACK_ID with the actual ID of your TalkBack.

Example of GET:

GET https://api.thingspeak.com/talkbacks/3/commands/last.xml?api_key=XXXXXXXXXXXXXXXX
The response will be an XML object of the new command, for example:

<?xml version="1.0" encoding="UTF-8"?>
<command>
  <id type="integer">18</id>
  <command-string>OPENDOOR</command-string>
  <position type="integer" nil="true"/>
  <created-at type="datetime">2013-12-30T16:51:17-05:00</created-at>
  <executed-at type="datetime">2013-12-31T16:51:17-05:00</executed-at>
</command>

Delete a TalkBack Command

To delete an existing TalkBack command, send an HTTP DELETE to https://api.thingspeak.com/talkbacks/TALKBACK_ID/commands/COMMAND_ID, replacing TALKBACK_ID with the actual ID of your TalkBack and COMMAND_ID with the ID of the command.

Valid parameters:

  • api_key (string) - API key for this specific TalkBack (required)

Text

Example of DELETE:

DELETE https://api.thingspeak.com/talkbacks/3/commands/18
       api_key=XXXXXXXXXXXXXXXX
The response will be the deleted command string, for example: OPENDOOR

JSON

To delete an existing TalkBack command, send an HTTP DELETE to https://api.thingspeak.com/talkbacks/TALKBACK_ID/commands/COMMAND_ID.json, replacing TALKBACK_ID with the actual ID of your TalkBack and COMMAND_ID with the ID of the command.

Example of DELETE:

DELETE https://api.thingspeak.com/talkbacks/3/commands/18.json
       api_key=XXXXXXXXXXXXXXXX
The response will be a JSON object of the command before it was deleted, for example:

{
  "command_string": "OPENDOOR",
  "created_at": "2013-12-29T17:53:40-05:00",
  "executed_at": null,
  "id": 18,
  "position": 5
}

XML

To delete an existing TalkBack command, send an HTTP DELETE to https://api.thingspeak.com/talkbacks/TALKBACK_ID/commands/COMMAND_ID.xml, replacing TALKBACK_ID with the actual ID of your TalkBack and COMMAND_ID with the ID of the command.

Example of DELETE:

DELETE https://api.thingspeak.com/talkbacks/3/commands/18.xml
       api_key=XXXXXXXXXXXXXXXX
The response will be an XML object of the command before it was deleted, for example:

<?xml version="1.0" encoding="UTF-8"?>
<command>
  <id type="integer">18</id>
  <command-string>OPENDOOR</command-string>
  <position type="integer">5</position>
  <created-at type="datetime">2013-12-30T16:51:17-05:00</created-at>
  <executed-at type="datetime" nil="true"/>
</command>

List All TalkBack Commands

To show all of a TalkBack's commands, send an HTTP GET to https://api.thingspeak.com/talkbacks/TALKBACK_ID/commands, replacing TALKBACK_ID with the actual ID of your TalkBack.

Valid parameters:

  • api_key (string) - API key for this specific TalkBack (required)

Text

Example of GET:

GET https://api.thingspeak.com/talkbacks/3/commands?api_key=XXXXXXXXXXXXXXXX
The response will be the command strings in a comma-separated quoted list, for example: "OPENDOOR","CLOSEDOOR"

JSON

To show all of a TalkBack's commands, send an HTTP GET to https://api.thingspeak.com/talkbacks/TALKBACK_ID/commands.json, replacing TALKBACK_ID with the actual ID of your TalkBack.

Example of GET:

GET https://api.thingspeak.com/talkbacks/3/commands.json?api_key=XXXXXXXXXXXXXXXX
The response will be a JSON array of all the commands, for example:

[
  {
    "command_string": "OPENDOOR",
    "created_at": "2013-12-29T17:53:40-05:00",
    "executed_at": null,
    "id": 18,
    "position": 1
  },
  {
    "command_string": "CLOSEDOOR",
    "created_at": "2013-12-30T17:53:40-05:00",
    "executed_at": null,
    "id": 19,
    "position": 2
  }
]

XML

To show all of a TalkBack's commands, send an HTTP GET to https://api.thingspeak.com/talkbacks/TALKBACK_ID/commands.xml, replacing TALKBACK_ID with the actual ID of your TalkBack.

Example of GET:

GET https://api.thingspeak.com/talkbacks/3/commands.xml?api_key=XXXXXXXXXXXXXXXX
The response will be an XML list of all the commands, for example:

<?xml version="1.0" encoding="UTF-8"?>
<commands type="array">
  <command>
    <id type="integer">18</id>
    <command-string>OPENDOOR</command-string>
    <position type="integer">1</position>
    <created-at type="datetime">2013-12-29T16:51:17-05:00</created-at>
    <executed-at type="datetime" nil="true"/>
  </command>
  <command>
    <id type="integer">19</id>
    <command-string>CLOSEDOOR</command-string>
    <position type="integer">2</position>
    <created-at type="datetime">2013-12-30T16:51:17-05:00</created-at>
    <executed-at type="datetime" nil="true"/>
  </command>
</commands>

Delete All TalkBack Commands

To delete all of a TalkBack's commands, send an HTTP DELETE to https://api.thingspeak.com/talkbacks/TALKBACK_ID/commands, replacing TALKBACK_ID with the actual ID of your TalkBack. Commands that have already been executed will not be deleted.

Valid parameters:

  • api_key (string) - API key for this specific TalkBack (required)

Text

Example of DELETE:

DELETE https://api.thingspeak.com/talkbacks/3/commands
       api_key=XXXXXXXXXXXXXXXX
The response body will be empty.

JSON

To delete all of a TalkBack's commands, send an HTTP DELETE to https://api.thingspeak.com/talkbacks/TALKBACK_ID/commands.json, replacing TALKBACK_ID with the actual ID of your TalkBack. Commands that have already been executed will not be deleted.

Example of DELETE:

DELETE https://api.thingspeak.com/talkbacks/3/commands.json
       api_key=XXXXXXXXXXXXXXXX
The response will be an empty JSON array, for example:

[]

XML

To delete all of a TalkBack's commands, send an HTTP DELETE to https://api.thingspeak.com/talkbacks/TALKBACK_ID/commands.xml, replacing TALKBACK_ID with the actual ID of your TalkBack. Commands that have already been executed will not be deleted.

Example of DELETE:

DELETE https://api.thingspeak.com/talkbacks/3/commands.xml
       api_key=XXXXXXXXXXXXXXXX
The response will be an empty XML array, for example:

<?xml version="1.0" encoding="UTF-8"?>
<nil-classes type="array" />

TalkBack Example

The following steps control a door that opens only once:

  1. Create a new TalkBack using the web interface.

  2. Add some queued commands using the web interface or API, such as "OPENDOOR", "CLOSEDOOR".

  3. If the door (with Wi-Fi and a connected motion sensor) senses someone nearby, execute the next command from ThingSpeak™: "OPENDOOR".

  4. After 5 minutes of no motion detected, execute the next command from ThingSpeak: "CLOSEDOOR".

  5. When someone else approaches the door, execute the next command from ThingSpeak, which will be empty--the door won't open again until more commands are added to the queue.

Was this topic helpful?