Docs‎ > ‎Training‎ > ‎Espresso Chat Sample‎ > ‎

Setup

Configuring Espresso Chat using Logic Designer will run us through an advanced project setup in just a couple minutes. I'll be illustrating each step with several screenshots, but there are essentially only 4 stages:
  1. Setting up our database
  2. Importing the conversations project
  3. Uploading + Configuring our Logic Designer custom authentication library
  4. And pointing Espresso Chat to our API base URL
All project files are available on github: https://github.com/EspressoLogicCafe/espresso-chat

The Database:
Included in the project files is the schema for Espresso Chat. Upload "conversations.sql" to your instance of MySQL.

Logic Designer
When starting a project from scratch, we can use the "Connect Wizard" to point Logic Designer to the project database, however, we have project JSON package included in the github repository with most of the API already configured.

From the header section, open the project drop down, and upload the "conversations-project.json".

We will also want to update our database authentication configuration, which we can do from within the "Database" section linked from the Designer sidebar. Re-populate your username, and password, and database name as needed.

Espresso Chat uses a custom authentication library, which we will have to upload and configure from within the "Projects" section.
Navigating to the custom libraries section:
 
A sample of the upload dialog when importing "authProvider.js":
Make sure to check that your uploaded library is "used", by default Logic Designer does not assume your new library needs to be enabled yet.

Because this library handles custom authentication, we will have to tell Designer what to look for by adding a provider:

Explaining how our custom providers works within Espresso Chat will require another tutorial, but in it we provide a JavaScript object returned from the "AppAuthenticationProviderCreate" function. In that object we've defined a set of options which the sample app will use to determine if a user deserves an API key on login. After saving the provider in the previous screenshot, we can then populate our configurable fields:
This sample points Logic Designer to a database with the expectation that it has a "users" table with usernames and passwords. There are no restrictions to how a custom authentication provider can validate credentials, though for simplicity, this example uses the database we have already uploaded.

Finally, we will have to explicitly tell Logic Designer to use our new Authentication Provider, by going to the "Details" tab:

Espresso Chat
Our sample application will need to know where the API is, which we can find a number of ways. Potentially the most interesting place is from within "RestLab" in the Designer sidebar. RestLab is something of a playground for our generated API endpoints, where we can debug, retool, and test the project. From here, we can copy our API URL ...

... and insert just the API base into Espresso Chat.

In review, we uploaded the database from our project files, pointed Logic Designer to our database, configured our custom authentication library, and then pointed Espresso Chat to Logic Designer. In this example, we explored each side step, and now that the sample is up, we can take a closer look at the rules and security.
Comments