import request from 'request' import url from 'url' interface RealtimeBody { error?: string payload?: { apiUrl: string directLineSecret: string previewUrl: string } } export default { dispatch: function(botId: string, action: string, body: RealtimeBody) { if (!process.env.REALTIME_SERVER_URL) { console.error('REALTIME_SERVER_URL not set!') return } const dispatchUrl = url.resolve(process.env.REALTIME_SERVER_URL, `dispatch/${botId}/${action}`) request.post( { url: dispatchUrl, json: body }, function(error, response, body) { if (error) { console.error('Realtime dispatch failed') } } ) } }