Setup
How to set up an API & Webhook integration
Learn how to setup the webhook integration and get fine-grain control over what entry types are sent and received.
Before you begin
This guide assumes you already have a your local environment set up for development on the Meya platform and that you’re connected to a test app you can experiment with.
If you’re using a virtual environment, make sure it’s activated.
If you haven’t setup your local environment yet, check out Getting started with local Meya development.
Add integration secrets
- Open
vault.yaml
and add the following lines:
webhook.postback_url: xxx
webhook.api_key: xxx
- Open
vault.secret.yaml
and add the following lines:
webhook.postback_url: <YOUR_WEBHOOK_URL>
webhook.api_key: <API_KEY>
Save the files. Open a terminal in your app’s folder and run this command:
meya vault upload --file vault.secret.yaml
Create the integration
- In your app’s main folder, create a folder called
integration
, if it doesn’t already exist. Inside, create a file calledwebhook.yaml
and enter this code:
type: meya.webhook.integration
postback_url: (@ vault.webhook.postback_url )
api_key: (@ vault.webhook.api_key )
Save the file, and push the code to the Grid using this command in your terminal:
meya push
Test the integration
- In the chat simulator, trigger a flow. Go to the Logs page and search for your webhook URL using this query:
url:"<YOUR_WEBHOOK_URL>"
You should see some meya.http.entry.request
and meya.http.entry.response
entries.
You should now have a working webhook integration. Keep reading to learn how to customize the types of entries that are sent to your webhook.
Filtering webhook entries
You can easily configure the webhook integration to only send or receive certain entry types.
String filters
You can use GridQL queries to create complex filters. Here’s how:
- Open
integration/webhook.yaml
and add the following lines:
filter:
tx: >
meya.text.event
AND NOT text:*purple*
This tells the app to only send tx
entries to the webhook if they are meya.text.event
type entries and that do not include the word purple
.
Save, then push the code:
meya push
- In the chat simulator type
purple
and then check the logs using this search query:
url:"<YOUR_WEBHOOK_URL>"
You should see a single meya.http.entry.request
and meya.http.entry.response
which is the bot saying that it didn’t understand the input.
If any of your flows has a trigger setup to handle input like
purple
, you may see a different number ofmeya.http.entry.*
entries for your webhook, but you won’t see one with"text":”purple”
.
Boolean filters
In addition to specifying a string query, you can also use a boolean value to disable sending or receiving entries via the webhook integration.
This filter, for example, disables sending entries to the webhook altogether:
filter:
tx: false
Updated about 2 years ago