Specifying an integration ID

Specifying an integration ID with the API & Webhook integration

By default, entries received from the API & Webhook integration have their integration_id value set to integration.webhook. But what if you want to create an entry as if it had come from a different integration? You can do that by specifying a custom integration ID with the integration_id property.

Example

Let’s say your app is connected to a customer support platform and you want a backend system to issue an agent command and launch a flow for a user. To do this, we’ll create a meya.csp.event.agent.command entry and override the default integration_id with the CSP’s integration ID.

Before you begin

For this example we’ll be using the Zendesk Support integration. If you don’t already have the Zendesk Support integration set up, check out the guide below before proceeding.

How To Set Up a Zendesk Support Integration

Add the agent command trigger

📘

If you already have a flow that uses the meya.csp.trigger.agent.command trigger, you can skip this step.

In your app’s flow/zendesk folder, create a file called agent_command.yaml and copy this code into it:

triggers:
  - agent_command: say_hi

steps:
  - say: The agent says hi!

This very simple flow will be triggered when the agent issues the /say_hi slash command as an internal note on a ticket.

Push the code to the Grid by running these commands in your terminal:

meya format
meya push

In the app’s Simulator, escalate the chat to an agent. Have the agent use the new /say_hi slash command and make sure the agent_command flow runs.

Add the API & Webhook integration

Next, set up the API & Webhook integration using the guide below. Once you’ve tested it and ensured it’s working, continue on to the next step.

How To Setup An API & Webhook Integration

Forming the API payload

We’ll be using the meya.csp.event.agent.command entry. You can read its full definition in the docs.

{
	"entry": {
		"type": "meya.csp.event.agent.command",
		"data": {
			"text": "say_hi"	
		}
	},
	"user": {
		"id": "AGENT_ID"
	},
	"thread": {
		"id": "TICKET_ID"
	},
	"integration_id": "integration.zendesk.support"
}

🚧

Although the agent’s Zendesk Support ID is a number, you’ll need to wrap it in quotes ”” here.

Try it out

Open up the app’s Simulator and create a new ticket.

In another tab, log in to Zendesk Support and open the new ticket.

Using a tool like Postman or Insomnia, call the app’s API endpoint with the above payload. You can also issue this curl statement from your terminal:

curl --request POST \
  --url https://grid.meya.ai/gateway/v2/webhook/APP_ID/integration.webhook \
  --header 'Authorization: Basic API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
	"entry": {
		"type": "meya.csp.event.agent.command",
		"data": {
			"text": "/say_hi"
		}
	},
	"user": {
		"id": "ZDS_AGENT_ID"
	},
	"thread": {
		"id": "ZDS_TICKET_ID"
	},
	"integration_id": "integration.zendesk.support"
}'

The agent_command flow should run. Make sure you see the flow’s output in the Simulator as well as in the Zendesk Support ticket. You can also check the Logs page, and confirm there is a meya.csp.event.agent.command entry.