Scanning a barcode to Coda using webhooks

When we launched support for Webhook-triggered automations a few weeks ago I knew I wanted to create a fun demo to show off the feature. I had used the Tasker app for previous projects, so quickly reinstalled it and picked the first action and data point that struck my fancy. The result: I shake my phone and my latitude and longitude is logged to a Coda doc (see video here).

A week ago the official Coda account playfully pointed out the questionable utility of such an integration, while another user asked about the potential of scanning a barcode to a Coda doc. Challenge accepted!

I’ve had a few folks ask how I set it up, so here’s a breakdown:

Create the Coda doc

  1. Create a Coda doc to recieve the scanned barcodes.
  2. Add a table that includes a number column to receive the numerical value of the scanned value of the scanned barcode, called “Barcode”.
  3. Optionally add a Timestamp column which uses the formula Now() for new rows.
  4. Optionally add an Image URL column to contain the rendered barcode, which uses a formula from the Barcode Pack. In my case I used EAN13() formula, but it depends on the type of barcode being scanned.

Copy this template to get my exact setup.

Create the webhook

  1. Add a new automation to the doc, using the trigger Webhook invoked.
  2. Click the Create API token button to get a new token.
  3. Copy the webhook URL and API token and place them somewhere you can access on your phone later (perhaps in the same Coda doc?).

The template doc above has the webhook added, but you’ll need to create your own API token.

Install the mobile apps

  1. Install Tasker (Android only).
  2. Install the AutoBarcode plugin for Tasker.
  3. Open both apps, granting them all of the permissions they need.

These apps are not free, and Android-only.

Configure Tasker

  1. In Tasker, create a new Profile selecting the source as Event > Plugin > AutoBarcode
  2. Click the pencil icon next to the Configuration to open the AutoBarcode settings for the event.
  3. Keep all of the defaults, and click the checkbox icon at the top to save the settings.
  4. Click the back arrow at the top to return to the profile.
  5. Add a new Task for the profile, and name it “Send to Coda”.
  6. Click the plus icon at the bottom to add a new action to the task, selecting Net > HTTP Request.
  7. Set the Method to POST.
  8. Set the URL to the webhook URL of the automation.
  9. In the Headers field, enter the value:
    Authorization: Bearer <API token>
    
    Replacing <API token> with the API token you generated for your webhook.
  10. In the Body field enter the following JSON message:
    { "barcode": "%abmessage" }
    
    The structure of the JSON message can be whatever we want, as we’ll also be writing the formula to parse it later in the automation. The variable %abmessage comes from the AutoBarcode plugin, and will be replaced with the numerical value of the scanned barcode.
  11. Click the back arrow to save the action.

I’ve exported my Tasker configuration, which you can download here. After import you’ll need to edit it to set you own webhook URL and API token.

Finish the automation

  1. Returning to the Coda doc, in the Then section of the automation choose Add row.
  2. For the Table select the table created earlier.
  3. In Set values, set the Barcode column using the formula:
    ParseJSON(thisRow.[Step 1 Result], "barcode")
    
    The field "barcode" here must match the field created in the JSON body in Tasker.
  4. Turn on the automation.

The template doc has this setup already as well.

Trying it out

  1. Add a new widget to your home screen, selecting AutoBarcode > AutoBarcode Scan.
  2. Click on the the widget to launch the barcode scanner.
  3. Scan a barcode.

I hope you find this useful, and let me know if you have any questions or feedback. Happy scanning!

18 Likes

Hello @Eric_Koleda ,
Thank you very much for this elaborate set of instructions. I know what I will be doing tonight :-).
Greetings, Joost

3 Likes

well done @Eric_Koleda, my man

thanks for the instructions

and thanks to the coda team responsible for the webhook triggeted automations

i’m hooked ;o)

max

4 Likes

This is exactly what I have been looking for! Only I need this for iOS. We have Security Officers that check fire extinguishers on their rounds and they have QR codes on them. We have an app that will read them but it won’t transfer the data to Coda which is what I really want…

2 Likes

Hello @Eric_Koleda ,

With some effort, but I got it to work, thank you very much. For some reason it kept crashing and I turned to Tasker for help - they gave me an alternative version of Tasker and I got it to work pretty quickly afterwards. If it weren’t for your tutorial I would have never thought about a problem with Tasker, since both Tasker and Webhooks were already working for a location task.

Thanks again,
Greetings, Joost

3 Likes

Dear @Eric_Koleda ,

Although your instructions are detailed, somehow I am not able to get the scanning of barcodes working.
Therefore I decided just to use the copies of your work provided, so far so good.
The Tasker configuration is a text file and should be *.xml from what I see as file format, isn’t it?

If you or @joost_mineur have come across potential pitfalls or have additional suggestions, I will really appreciate.

Hi @Jean_Pierre_Traets - It was tricky the first time around too, and I may have forgotten a step somewhere. The file does seem to contain XML, but for some reason the app uses the .txt extension, not sure if that makes a difference at all.

Airtable had this built in where you could use your phone’s camera to simply scan and have it search a table. This isnt possible natively on Coda?

1 Like

Dear @Eric_Koleda,

Just to let you know that this morning, “with a fresh head”, I managed to get it working. :grinning:
It came out that I did type “Authorization:” in the Headers.

Special thanks for @joost_mineur for sharing his settings with me :handshake:

2 Likes

@coda Please build an ios workaround :pensive:

1 Like

Hey @MK_2109 you can trigger webhooks in Coda from Shortcuts on iOS which allows you to bring in data from most places on iOS.

1 Like