Generate Hosted ES Flow URL
This code snippet shows how to generate Hosted ES Flow URL.
Example
Find the description for all variables used in each code snippet below:
| Key | Description |
|---|---|
VONAGE_API_KEY | Your Vonage API key (see it on your dashboard). |
VONAGE_API_SECRET | Your Vonage API secret (also available on your dashboard). |
CHANNEL_MANAGER_WHATSAPP_PARTNER_SOLUTION_ID | The partner solution ID. |
CHANNEL_MANAGER_WHATSAPP_PARTNER_API_KEY | Sub-api-key of the end-client that the Partner wants to generate the ES flow URL for. If not provided, this defaults to Partner’s main api-key. |
Prerequisites
A Vonage application contains the required configuration for your project. You can create an application using the Vonage CLI (see below) or via the dashboard. To learn more about applications see our Vonage concepts guide.
Install the CLI
Create an application
Once you have the CLI installed you can use it to create a Vonage application. Run the following command and make a note of the application ID that it returns. This is the value to use in NEXMO_APPLICATION_ID in the example below. It will also create private.key in the current directory which you will need in the Initialize your dependencies step
Vonage needs to connect to your local machine to access your answer_url. We recommend using ngrok to do this. Make sure to change demo.ngrok.io in the examples below to your own ngrok URL.
Write the code
Add the following to generate-hosted-flow.sh:
curl -X POST https://api.nexmo.com/v1/channel-manager/whatsapp/tp-registration/url \
-u "${VONAGE_API_KEY}:${VONAGE_API_SECRET}" \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d $'{
"solution_id": "'${CHANNEL_MANAGER_WAHTSAPP_PARTNER_SOLUTION_ID}'",
"api_key": "'${CHANNEL_MANAGER_WHATSAPP_PARTNER_API_KEY}'",
"ttl": 300
}'Run your code
Save this file to your machine and run it: