[SF1] Update on that Echo/Salesforce Stuff

My Echo demo is nearing the end of a evolution, I think. When I first showed it, it was utter demoware. The authentication required an API user with a fixed username and password, which was a problem in its own right. That also means that multi-user was going to be problematic since the API user was going to have to figure out which Echo user was requesting cases and what cases they should have access to manipulate (basically it didn't try to care).

Then Amazon added an OAuth flow and slowly updated it to the point where I could create an npm package for Express to create a bridge between the two services. This allowed me to start to decouple the previous authentication into a proper OAuth flow where a user was actually able to log in via the Alexa app.

That kicked off some small refactors which were going one of two ways:

  1. Have the Heroku application serve as a middleware which would hold user sessions. This would save some API calls for redudant requests (like what case is being worked on).

  2. Have the middleware be completely free of holding session state and serve only as a traffic cop.

I leaned towards the second as that would make the Heroku layer much more scalable and in theory much more stable. The convenience of being able to retain a brief history of user activity didn't seem to outweigh bolting on a user subsystem.

But you also never want to make more API calls than you need to make and asking the same question (What Case Am I On?) seemed exactly like that.

It was Apex REST to the rescue. With this last refactoring, which included cleaning up a lot of code structure itself, I added two main REST endpoints which would use SOQL to find a list of recently searched/updated cases and then DML the updates. So instead of one REST API to find the related case and another to update it, it's now just.

The last step will be to fix the Chrome extension which allows you to see the updates in real time in your browser as you speak to the Echo. That funcationality is roughly the same, but will get updated to match the new object model and some new features as well.

Once that is out, and I get the Heroku stuff buttoned up, I will need test subjects AKA beta users.

Check this space probably about the same time next week for more.

comments powered by Disqus