vania-janet/multiturn-rag-retrieval-data huggingface dataset:
The specified custom model is used for all requests that are sent over the connection.

var access_token = {access_token};
var wsURI = '{ws_url}/v1/recognize'
+ '?access_token=' + access_token
+ '&model=en-US_NarrowbandModel'
+ '&acoustic_customization_id={customization_id}';
var websocket = new WebSocket(wsURI);
* For the [synchronous HTTP interface](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-http), use the POST /v1/recognize method. The specified custom model is used for that request.

IBM Cloud

curl -X POST -u "apikey:{apikey}" --header "Content-Type: audio/flac" --data-binary @audio-file1.flac "{url}/v1/recognize?acoustic_customization_id={customization_id}"

IBM Cloud Pak for Data

curl -X POST --header "Authorization: Bearer {token}" --header "Content-Type: audio/flac" --data-binary @audio-file1.flac "{url}/v1/recognize?acoustic_customization_id={customization_id}"
* For the [asynchronous HTTP interface](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-async), use the POST /v1/recognitions method. The specified custom model is used for that request.

IBM Cloud

curl -X POST -u "apikey:{apikey}" --header "Content-Type: audio/flac" --data-binary @audio-file.flac "{url}/v1/recognitions?acoustic_customization_id={customization_id}"

IBM Cloud Pak for Data
* With the HTTP interfaces, the service waits for all of the audio to arrive before sending a response. It then sends a single stream of bytes in response. The response can include multiple transcription elements with multiple final results, and it can be sent incrementally. But it is a single stream of data.
* With the WebSocket interface, the service sends final results as they become available. It can send multiple independent responses in the form of different streams of bytes. The connection is bidirectional and full duplex, and requests and responses can continue to flow back and forth over a single connection for as long as it remains active.





 Low-latency restrictions 

The low-latency feature has the following usage restrictions:



* Low latency is available only for some next-generation models. For next-generation models that do not support low-latency, if you include the low_latency parameter with a request, the service fails with status code 400:

{
"code": 400,
"code_description": "Bad Request",
"error": "low_latency is not a supported feature for model {model_id}"
}
* Low latency is not available for previous-generation models. For previous-generation models, if you include the low_latency parameter with a request, the service generates a warning:

"warnings": [
"Unknown arguments: low_latency."
]







 Low-latency example 

The following synchronous HTTP example requests low latency with the en-US_Telephony model. The example sets the low_latency query parameter to true.

IBM Cloud

curl -X POST -u "apikey:{apikey}" --header "Content-Type: audio/wav" --data-binary @{path}audio-file.wav "{url}/v1/recognize?model=en-US_Telephony&low_latency=true"

IBM Cloud Pak for Data
* The HTTP POST /v1/synthesize method:

IBM Cloud

curl -X POST -u "apikey:{apikey}" --header "Content-Type: application/json" --header "Accept: audio/flac" --data "{"text":"IEEE"}" --output ieee.flac "{url}/v1/synthesize?customization_id={customization_id}"

IBM Cloud Pak for Data

curl -X POST --header "Authorization: Bearer {token}" --header "Content-Type: application/json" --header "Accept: audio/flac" --data "{"text":"IEEE"}" --output ieee.flac "{url}/v1/synthesize?customization_id={customization_id}"



The third example establishes a WebSocket connection with the /v1/synthesize method. The request uses the indicated custom model to synthesize text that is passed over the connection.

var access_token = '{access_token}';
var wsURI = '{ws_url}/v1/synthesize'
+ '?access_token=' + access_token
+ '&voice=en-US_AllisonV3Voice'
+ '&customization_id=={customization_id}';
var websocket = new WebSocket(wsURI);
var access_token = '{access_token}';
var wsURI = '{ws_url}/v1/synthesize'
+ '?access_token=' + access_token
+ '&customization_id={customization_id}'
+ '&voice=en-US_AllisonV3Voice';
var websocket = new WebSocket(wsURI);

function onOpen(evt) {
var message = {
text: '<ibm:prompt id="goodbye"/>',
accept: 'audio/ogg;codecs=opus'
};
websocket.send(JSON.stringify(message));
}

. . .
Show more
Slack 

The pre-installed /whisk.system/slack package that is available for IBM Cloud® Functions, offers a convenient way to use the [Slack APIs](https://api.slack.com/).

The package includes the following actions,



Table 1. Slack package entities

 Entity Type Parameters Description 

 /whisk.system/slack Package url, channel, username Interact with the Slack API. 
 /whisk.system/slack/post Action text, url, channel, username Posts a message to a Slack channel. 



Creating a package binding with the username, url, and channel values is suggested. With binding, you don't need to specify the values each time that you invoke the action in the package.



 Posting a message to a Slack channel 

The /whisk.system/slack/post action posts a message to a specified Slack channel. The following parameters are supported.



Table 2. Slack post action parameters

 Parameter Description 

 url The Slack webhook URL. 
 channel The Slack channel to post the message to. 
 username The name to post the message as. 
 text A message to post. 
 token (optional) A Slack [access token](https://api.slack.com/tokens). 



The following example shows how to configure Slack, create a package binding, and post a message to a channel.



1. Configure a Slack [incoming webhook](https://api.slack.com/incoming-webhooks) for your team.

After Slack is configured, you get a webhook URL that looks like https://hooks.slack.com/services/aaaaaaaaa/bbbbbbbbb/cccccccccccccccccccccccc. The webhook is needed in the next step.
2. Create a package binding with your Slack credentials, the channel that you want to post to, and the user name to post as.
Client must support authentication by using the SASL Plain mechanism and use the Server Name Indication (SNI) extension to the TLSv1.2 protocol. Client must support authentication by using the SASL Plain mechanism and use the Server Name Indication (SNI) extension to the TLSv1.2 protocol. 





 Choosing a Kafka client to use with Event Streams 

The official client for the Kafka API is written in Java, and as such contains the latest features and bug fixes. For more information about this API, see [Kafka Producer API 3.3](https://kafka.apache.org/33/javadoc/org/apache/kafka/clients/producer/KafkaProducer.html) and [Kafka Consumer API 3.3](https://kafka.apache.org/33/javadoc/org/apache/kafka/clients/consumer/KafkaConsumer.html).

For other languages, run one of the following clients, all of which are tested with Event Streams.



 Support summary for all recommended clients 



Table 2. Client support summary

 Client Language Recommended version Minimum version supported <br><br>[1] Link to sample 

 Official Apache Kafka client: 
 [Apache Kafka client](http://kafka.apache.org/downloads) Java Latest 0.10.2 [Java console sample](https://cloud.ibm.com/docs/EventStreams?topic=EventStreams-kafka_java_using)<br><br>[Liberty sample](https://github.com/ibm-messaging/event-streams-samples/tree/master/kafka-java-liberty-sample) 
 Third-party clients: 
 [node-rdkafka](https://github.com/Blizzard/node-rdkafka) Node.js Latest 2.2.2 [Node.js sample](https://github.com/ibm-messaging/event-streams-samples/tree/master/kafka-nodejs-console-sample)
Using the Administration REST API 

Event Streams provides an Administration RESTful API that you can use to create, delete, list, and update topics.

You must retrieve the URL and credential details that are needed to connect to the API from a service credentials object or service key for the service instance. For information about creating these objects, see [Connecting to Event Streams](https://cloud.ibm.com/docs/EventStreams?topic=EventStreams-connecting).

The URL for the API's endpoint is provided in the kafka_admin_url property.

The credentials depend on the authentication method and three types of credential are supported.



  Authenticate by using Basic Auth 

Use the user and api_key properties of the objects as the username and password. Place these values into the Authorization header of the HTTP request in the form Basic <base64 encoding of username and password joined by a single colon (:)>.





  Authenticate by using a bearer token 

To obtain your token by using the IBM Cloud CLI, first log in to IBM Cloud then run the following command:

 {: codeblock}
ibmcloud iam oauth-tokens

Place this token in the Authorization header of the HTTP request in the form Bearer<token>. Both API key or JWT tokens are supported.





  Authenticate by using the api_key 

Place the key directly as the value of the X-Auth-Token HTTP header.







  Next steps 

For a description of the API with examples, see [Event Streams admin-rest](https://github.com/ibm-messaging/event-streams-docs/tree/master/admin-rest-api).

You can download the full specification for the API from the [Event Streams Admin REST API YAML file](https://github.com/ibm-messaging/event-streams-docs/blob/master/admin-rest-api/admin-rest-api.yaml). To view the swagger file, use Swagger tools, for example [Swagger editor](http://editor.swagger.io//).
422 Webhook responded with invalid JSON body The webhook's HTTP response body could not be parsed as JSON. 
 422 Webhook responded with [500] status code There's a problem with the external service you called. The code failed or the external server refused the request. 
 500 Processor Exception : [connections to all backends failing] An error occurred in the webhook microservice. It could not connect to backend services. 







 Webhook security 

To authenticate the webhook request, verify the JSON Web Token (JWT) that is sent with the request. The webhook microservice automatically generates a JWT and sends it in the Authorization header with each webhook call. It is your responsibility to add code to the external service that verifies the JWT.

For example, if you specify purple unicorn in the Secret field, you might add code similar to this:

const jwt = require('jsonwebtoken');
...
const token = request.headers.authentication; // grab the "Authentication" header
try {
const decoded = jwt.verify(token, 'purple unicorn');
} catch(err) {
// error thrown if token is invalid
}





 Example request body 

It is useful to know the format of the request postmessage webhook body so that your external code can process it.

The payload contains the response body that is returned by your assistant for the v2 /message (stateful and stateless) API call. The event name message_processed indicates that the request is generated by the postmessage webhook. For more information about the message request body, see the [API reference](https://cloud.ibm.com/apidocs/assistant/assistant-v2message).

The following sample shows how a simple request body is formatted.

{
"event": {
"name": "message_processed"
},
"options": {},
"payload": {
"output": {
"intents": [
{
The new job is owned by the instance of the service whose credentials are used to create it.

In addition to the previous parameters, which are specific to the asynchronous interface, the POST /v1/recognitions method supports most of the same parameters as the WebSocket and synchronous HTTP interfaces. For more information, see the [Parameter summary](https://cloud.ibm.com/docs/speech-to-text?topic=speech-to-text-summary).



 Callback notifications 

If the job is created with a callback URL, the service sends an HTTP POST callback notification to the registered URL when a specified event occurs. The body of a basic notification consists of a JSON object with the following structure:

{
"id": "{job_id}",
"event": "{recognitions_status}",
"user_token": "{user_token}"
}

The id field identifies the ID of the job that generated the callback, and the event field identifies the event that triggered the callback. The user_token field includes the user token for the job if one was specified. Otherwise, the field is an empty string. If the event is recognitions.completed_with_results, the object includes a results field that provides the results of the recognition request. The client can respond to the callback notification with status code 200.

If the callback URL was registered with a user secret, the service also sends the X-Callback-Signature header with the callback notification. The header specifies the HMAC-SHA1 signature of the body of the request. The service calculates the signature by using the user secret as a key. The client can calculate the signature of the payload for the callback notification to be sure that it matches the signature in the header. For example, the following simple Python code computes the signature on the string notification_payload:

from hashlib import sha1
import hmac
hashed = hmac.new(user_secret, notification_payload, sha1)
signature = hashed.digest().encode("base64").rstrip('n')
422 Webhook responded with [500] status code There's a problem with the external service you called. The code failed or the external server refused the request. 
 500 Processor Exception : [connections to all backends failing] An error occurred in the webhook microservice. It could not connect to backend services. 







 Webhook security 

To authenticate the webhook request, verify the JSON Web Token (JWT) that is sent with the request. The webhook microservice automatically generates a JWT and sends it in the Authorization header with each webhook call. It is your responsibility to add code to the external service that verifies the JWT.

For example, if you specify purple unicorn in the Secret field, you might add code similar to this:

const jwt = require('jsonwebtoken');
...
const token = request.headers.authentication; // grab the "Authentication" header
try {
const decoded = jwt.verify(token, 'purple unicorn');
} catch(err) {
// error thrown if token is invalid
}





 Example request body 

It is useful to know the format of the request postmessage webhook body so that your external code can process it.

The payload contains the response body that is returned by your assitant for the v2 /message (stateful and stateless) API call. The event name message_processed indicates that the request is generated by the postmessage webhook. For more information about the message request body, see the [API reference](https://cloud.ibm.com/apidocs/assistant/assistant-data-v2message).

The following sample shows how a simple request body is formatted.

{
"event": {
"name": "message_processed"
},
"options": {},
"payload": {
"output": {
"intents": [
{
"intent": "General_Greetings",
"confidence": 1
}
],
422 Webhook responded with invalid JSON body The webhook's HTTP response body could not be parsed as JSON. 
 422 Webhook responded with [500] status code There's a problem with the external service you called. The code failed or the external server refused the request. 
 500 Processor Exception : [connections to all backends failing] An error occurred in the webhook microservice. It could not connect to backend services. 







 Webhook security 

To authenticate the webhook request, verify the JSON Web Token (JWT) that is sent with the request. The webhook microservice automatically generates a JWT and sends it in the Authorization header with each webhook call. It is your responsibility to add code to the external service that verifies the JWT.

For example, if you specify purple unicorn in the Secret field, you might add code similar to this:

const jwt = require('jsonwebtoken');
...
const token = request.headers.authentication; // grab the "Authentication" header
try {
const decoded = jwt.verify(token, 'purple unicorn');
} catch(err) {
// error thrown if token is invalid
}





 Example request body 

It is useful to know the format of the request postmessage webhook body so that your external code can process it.

The payload contains the response body that is returned by your assitant for the v2 /message (stateful and stateless) API call. The event name message_processed indicates that the request is generated by the postmessage webhook. For more information about the message request body, see the [API reference](https://cloud.ibm.com/apidocs/assistant/assistant-v2message).

The following sample shows how a simple request body is formatted.

{
"event": {
"name": "message_processed"
},
"options": {},
"payload": {
"output": {
"intents": [
{
If this message is displayed, use a REST API tool, such as cURL, to send a test /message API request, so you can see the error code and full message that is returned.



Error code details

 Error code and message Description 

 422 Webhook responded with invalid JSON body The webhook's HTTP response body could not be parsed as JSON. 
 422 Error validating webhook response The webhook's HTTP response body was not a valid /message body. 
 422 Webhook responded with [500] status code There's a problem with the external service you called. The code failed or the external server refused the request. 
 500 Processor Exception : [connections to all backends failing] An error occurred in the webhook microservice. It could not connect to backend services. 







 Webhook security 

To authenticate the webhook request, verify the JSON Web Token (JWT) that is sent with the request. The webhook microservice automatically generates a JWT and sends it in the Authorization header with each webhook call. It is your responsibility to add code to the external service that verifies the JWT.

For example, if you specify purple unicorn in the Secret field, you might add code similar to this:

const jwt = require('jsonwebtoken');
...
const token = request.headers.authentication; // grab the "Authentication" header
try {
const decoded = jwt.verify(token, 'purple unicorn');
} catch(err) {
// error thrown if token is invalid
}





 Request body 

It is useful to know the format of the request body of the premessage webhook so that your external code can process it.

The payload contains the request body of the /message (stateful or stateless) v2 API request. The event name message_received indicates that the request is generated by the premessage webhook. For more information about the message request body, see the [API reference](https://cloud.ibm.com/apidocs/assistant/assistant-v2message).

{
Application load balancers support end-to-end HTTP2 traffic, and works with listener protocols set as either HTTPS or TCP.





 WebSocket support 

WebSocket provides full-duplex communication channels over a single TCP connection. Application load balancers support WebSocket with every type of listener protocol (HTTP/HTTPS/TCP).





 Architecture 

The following diagram illustrates the deployment architecture for the ALB.

Zoom

![Application load balancer for VPC](https://cloud.ibm.com/docs-content/v1/content/f02b9c9adcbb7328d95a45e105cec371d50f15eb/vpc/images/alb_arc.png)

Application load balancer

In this diagram, "Client Resources" represents the resources (VPCs and subnets, for instance) that belong to the client ecosystem.





 Related links 



* [Load balancer CLI reference](https://cloud.ibm.com/docs/vpc?topic=vpc-infrastructure-cli-plugin-vpc-referencealb-anchor)
* [Load balancer API reference](https://cloud.ibm.com/apidocs/vpclist-load-balancer-profiles)
* [ALB for VPC infrastructure resources for Terraform](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/data-sources/is_lb) (VPC infrastructure > Resources)
* [Required permissions for VPC resources](https://cloud.ibm.com/docs/vpc?topic=vpc-resource-authorizations-required-for-api-and-cli-calls)
* [IBM Cloud Activity Tracker events](https://cloud.ibm.com/docs/vpc?topic=vpc-at-eventsevents-load-balancers)
* [FAQs for application load balancers](https://cloud.ibm.com/docs/vpc?topic=vpc-load-balancer-faqs)
curl -X POST -u "apikey:{apikey}" --header "Content-Type: audio/flac" --data-binary @{path}audio-file.flac "{url}/v1/recognize?model=en-US_BroadbandModel&base_model_version=en-US_BroadbandModel.v2018-07-31&language_customization_id={customization_id}"

IBM Cloud Pak for Data

curl -X POST --header "Authorization: Bearer {token}" --header "Content-Type: audio/flac" --data-binary @{path}audio-file.flac "{url}/v1/recognize?model=en-US_BroadbandModel&base_model_version=en-US_BroadbandModel.v2018-07-31&language_customization_id={customization_id}"

For an asynchronous HTTP request, you specify the parameters when you create the asynchronous job. For a WebSocket request, you pass the parameters when you establish a connection.
* Allowing the require-whisk-auth annotation to be set automatically by using the --web-secure flag. When the --web-secure flag is set to true, a random number is generated as the require-whisk-auth annotation value. When set to false, the require-whisk-auth annotation is removed. When set to any other value, that value is used as the require-whisk-auth annotation value.





 Creating a secure web action 

Start by creating a web action with the --web secure set to true.



1. Save the following JavaScript code as hello.js.

function main({name}) {
var msg = 'You did not tell me who you are.';
if (name) {
msg = Hello, ${name}!
}
return {body: <html><body><h3>${msg}</h3></body></html>}
}
2. Update your hello web action with the new version of your hello.js code and set the --web secure option to true.

ibmcloud fn action update demo/hello /<filepath>/hello.js --web true --web-secure true
3. Get the hello web action to view the randomly generated require-whisk-auth value.

ibmcloud fn action get demo/hello

Example output

The require-whisk-auth value was set to 7819991076995522.

{
"namespace": "<namespace_ID>/demo",
"name": "hello",
"version": "0.0.34",
"exec": {
"kind": "nodejs:10",
"binary": false
},
"annotations": [
{
"key": "web-export",
"value": true
},
{
"key": "raw-http",
[openwhisk](https://www.npmjs.com/package/openwhisk) JavaScript client library for the OpenWhisk platform. Provides a wrapper around the OpenWhisk APIs. 
 [path-to-regex](https://www.npmjs.com/package/path-to-regexp) Turn a path string such as /user/:name into a regular expression, which can then be used to match against URL paths. 
 [pg](https://www.npmjs.com/package/pg) Non-blocking PostgreSQL client for Node.js. Pure JavaScript and optional native libpq bindings. 
 [process](https://www.npmjs.com/package/process) require('process');, just like any other module. 
 [pug](https://www.npmjs.com/package/pug) Implements the Pug templating language. 
 [redis](https://www.npmjs.com/package/redis) This package is a complete and feature rich Redis client for Node.js. 
 [request-promise](https://www.npmjs.com/package/request-promise) The simplified HTTP request client 'request' with Promise support. Powered by Bluebird. 
 [rimraf](https://www.npmjs.com/package/rimraf) The UNIX command rm -rf for node. 
 [semver](https://www.npmjs.com/package/semver) Semantic Versioning for Node.js. 
 [serialize-error](https://www.npmjs.com/package/serialize-error) Serialize an error into a plain object. 
 [serve-favicon](https://www.npmjs.com/package/serve-favicon) Node.js middleware for serving a favicon.