Prerequisite
We recommend that you read the following article first:
Context Service
This article adds support for passing context from an Enabler bot when escalating the engagement to Live Assist.
The code samples here are available on the github repository
The scope here is aimed towards getting you up and running as a Web App Bot in an Azure context, instead of locally against a dummy context server.
The code for this sample is below. The main app.js file is extended to pass the context, and there is an additional class file for building up the context data - contextData.js
You need to create a public/private key pair in order to encrypt your context data as a JWT to be sent securely to the context service. Make your private key available to the Node app (this example uses an environment variable, but other methods are available), and configure the public key as a context key in the Live Assist admin portal.
For further information on this step, see: Bot Escalation SDK - Context Service
Also see the useful Node script for generating a suitable key pair in the full sample.
When you have updated your code and generated your key pair, set the following additional environment configuration within your Azure Web App Bot application service settings:
Variable | Setting |
---|---|
BOT_CTX_DATA | true |
BOT_CTX_SGN_KEY_PEM | Your private key string in PEM format with line-breaks replaced with \n |
BOT_CTX_SRV_CERT | accept |
BOT_TARGET_SKILL | yourLiveAssistSkill |
LA_ACCOUNT_ID | yourLiveAssistId |
LA_CTX_DATA_HOST | yourLiveAssistServiceHostURL |
App.js code sample:
contextData.js code sample: