Creating the app

Create a new Meya app from the command line.

To begin, we'll need to create an app and download it to our local development environment.

1. Create the virtual environment

Let's start by creating a folder for our project. Open up the command line, cd to a directory where you'd like to store your code, then run the following commands:

mkdir pizza-bot
cd pizza-bot
brew install [email protected] libgit2
python3 -m venv venv

❗️

Python2 is not supported

Notice we're using Python3 in the above command. Python2 reached end-of-life status on Jan 1, 2020, and is not supported on the Meya platform.

We'll need your personal Meya auth token for the next step. You can find it in the Meya console by clicking the profile icon in the top right corner and selecting Profile. Click the Copy button to copy your auth token.

781781

Back on the command line, create an environment variable for your auth token:

MEYA_AUTH_TOKEN=your_meya_auth_token

Now you're ready to install the Meya SDK and Meya CLI:

. venv/bin/activate
pip3 install --upgrade \
  --extra-index-url https://meya:[email protected]/registry/pypi \
  "pygit2==1.5.0" \
  "meya-sdk>=2.0.0" \
  "meya-cli>=2.0.0"
meya auth add \
  --grid-url https://grid.meya.ai \
  --auth-token $MEYA_AUTH_TOKEN

When that step is done, you'll see a message indicating you're authenticated:

231231

You only need to authenticate once. Now we can push and pull code from our remote app!

2. Create the app

Next, we'll create the remote app. Open the Grid console. Click Create app and give your app a name, like Pizza Bot. Click Create.

22542254

3. Copy the remote app code to your local environment.

Finally, let's pull our remote app code to our project folder.

APP_ID=your_app_id
meya clone \
  --grid-url https://grid.meya.ai \
  --app-id $APP_ID \
  --directory temp \
  && cp -a temp/. . && rm -rf temp/
meya vault download --file vault.secret.yaml
704704

4. Review the project directory structure

Let's take a moment to review how the project files are laid out. Open the project in your favourite code editor.

453453

.github/workflows/meya.check-test.yaml This is a Github Actions workflow you can use if you're using Github to store your app's remote repo. It includes steps to check your app's formatting, run tests you've written, and even push your code to a production app. Note that you'll need to add some repo secrets within Github for the workflow to run properly. Check out this guide for more details: Workflow

.meya/git/ Meya uses Git to track changes to your app. Every time you push code to the remote repo, a new commit is made. You shouldn't really interact with this repo. If you want to use version control with your app, you should create your own Git repo in the app's root folder.

.meya/connect.yaml This file tells the Meya CLI how to connect to your remote app.

.bot/default.yaml This file configures some basic information about your app, including the name of the bot that appears in the chat widget, an avatar for the bot, and whether or not it supports Markdown.

component/ This folder holds all of your custom components, which are written in Python3. You can also add tests here. Meya uses pytest to run tests, so any command that pytest supports, meya test supports as well.

flow/ This folder stores your flow files. A flow is a related set of actions. Learn more about flows in this guide: Flows

integration/ This folder holds integration configuration files. There should be one file per integration. By default, the Sensitive Data integration is added and enabled.

.gitignore If you've used Git before, you'll be familiar with .gitignore files. It can be used to specify files that shouldn't be committed to version control. We've added some logical defaults to get your started.

.meyaignore This is similar to .gitignore except it's for the internal .meya/git/ repo, not your own Git repo. You shouldn't need to modify this file.

.isort.cfg and pyproject.toml You probably won't need to modify these files. They specify some project configuration data.

pytest.ini Meya uses pytest for testing your Python3 code. This configuration file specifies some configuration values, including the file naming convention for tests, as well as folders to ignore when testing.

README.md This is a Markdown file you can use to explain the purpose of the app as well as how to set it up.

vault.yaml This file is committed to version control. It specifies variables the app needs that should be kept secret (e.g. API tokens, passwords, etc.) Since this is committed to version control you should not add the actual secret values here. This file is meant to give other developers a clue about what secret values the app needs in order to work properly. Read more about the vault: Vault

vault.secret.yaml This file is not committed to version control. It should include the same information as vault.yaml except it will have the actual secret values in it. Read more about the vault: Vault


What’s Next

Let's add a couple of flows so our users can start ordering pizza.